Skip to content

Commit 79d1e6d

Browse files
committed
Merge branch 'jc/http-clear-finished-pointer' into maint
Meant to go with js/ci-gcc-12-fixes. source: <[email protected]> * jc/http-clear-finished-pointer: http.c: clear the 'finished' member once we are done with it
2 parents 596838d + 05e280c commit 79d1e6d

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
@@ -1367,6 +1367,32 @@ void run_active_slot(struct active_request_slot *slot)
13671367
select(max_fd+1, &readfds, &writefds, &excfds, &select_timeout);
13681368
}
13691369
}
1370+
1371+
/*
1372+
* The value of slot->finished we set before the loop was used
1373+
* to set our "finished" variable when our request completed.
1374+
*
1375+
* 1. The slot may not have been reused for another requst
1376+
* yet, in which case it still has &finished.
1377+
*
1378+
* 2. The slot may already be in-use to serve another request,
1379+
* which can further be divided into two cases:
1380+
*
1381+
* (a) If call run_active_slot() hasn't been called for that
1382+
* other request, slot->finished would have been cleared
1383+
* by get_active_slot() and has NULL.
1384+
*
1385+
* (b) If the request did call run_active_slot(), then the
1386+
* call would have updated slot->finished at the beginning
1387+
* of this function, and with the clearing of the member
1388+
* below, we would find that slot->finished is now NULL.
1389+
*
1390+
* In all cases, slot->finished has no useful information to
1391+
* anybody at this point. Some compilers warn us for
1392+
* attempting to smuggle a pointer that is about to become
1393+
* invalid, i.e. &finished. We clear it here to assure them.
1394+
*/
1395+
slot->finished = NULL;
13701396
}
13711397

13721398
static void release_active_slot(struct active_request_slot *slot)

0 commit comments

Comments
 (0)