Skip to content

Commit 402b28e

Browse files
committed
Merge branch 'jc/http-clear-finished-pointer'
This work-around shuts up GCC when it complains about a local variable's address being assigned to a struct that lives on after returning from the function. Technically, GCC is wrong not to complain that the pointer could have been copied and used later, but hey, the code compiles so we're happy. Signed-off-by: Johannes Schindelin <[email protected]>
2 parents 9343226 + 342119d commit 402b28e

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

http.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1403,6 +1403,32 @@ void run_active_slot(struct active_request_slot *slot)
14031403
select(max_fd+1, &readfds, &writefds, &excfds, &select_timeout);
14041404
}
14051405
}
1406+
1407+
/*
1408+
* The value of slot->finished we set before the loop was used
1409+
* to set our "finished" variable when our request completed.
1410+
*
1411+
* 1. The slot may not have been reused for another requst
1412+
* yet, in which case it still has &finished.
1413+
*
1414+
* 2. The slot may already be in-use to serve another request,
1415+
* which can further be divided into two cases:
1416+
*
1417+
* (a) If call run_active_slot() hasn't been called for that
1418+
* other request, slot->finished may still have the
1419+
* address of our &finished.
1420+
*
1421+
* (b) If the request did call run_active_slot(), then the
1422+
* call would have updated slot->finished at the beginning
1423+
* of this function, and with the clearing of the member
1424+
* below, we would find that slot->finished is now NULL.
1425+
*
1426+
* In all cases, slot->finished has no useful information to
1427+
* anybody at this point. Some compilers warn us for
1428+
* attempting to smuggle a pointer that is about to become
1429+
* invalid, i.e. &finished. We clear it here to assure them.
1430+
*/
1431+
slot->finished = NULL;
14061432
}
14071433

14081434
static void release_active_slot(struct active_request_slot *slot)

0 commit comments

Comments
 (0)