Skip to content

Commit 4c9b052

Browse files
committed
Merge branch 'jc/http-clear-finished-pointer'
Meant to go with js/ci-gcc-12-fixes. * jc/http-clear-finished-pointer: http.c: clear the 'finished' member once we are done with it
2 parents db5b7c3 + 05e280c commit 4c9b052

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
@@ -1385,6 +1385,32 @@ void run_active_slot(struct active_request_slot *slot)
13851385
select(max_fd+1, &readfds, &writefds, &excfds, &select_timeout);
13861386
}
13871387
}
1388+
1389+
/*
1390+
* The value of slot->finished we set before the loop was used
1391+
* to set our "finished" variable when our request completed.
1392+
*
1393+
* 1. The slot may not have been reused for another requst
1394+
* yet, in which case it still has &finished.
1395+
*
1396+
* 2. The slot may already be in-use to serve another request,
1397+
* which can further be divided into two cases:
1398+
*
1399+
* (a) If call run_active_slot() hasn't been called for that
1400+
* other request, slot->finished would have been cleared
1401+
* by get_active_slot() and has NULL.
1402+
*
1403+
* (b) If the request did call run_active_slot(), then the
1404+
* call would have updated slot->finished at the beginning
1405+
* of this function, and with the clearing of the member
1406+
* below, we would find that slot->finished is now NULL.
1407+
*
1408+
* In all cases, slot->finished has no useful information to
1409+
* anybody at this point. Some compilers warn us for
1410+
* attempting to smuggle a pointer that is about to become
1411+
* invalid, i.e. &finished. We clear it here to assure them.
1412+
*/
1413+
slot->finished = NULL;
13881414
}
13891415

13901416
static void release_active_slot(struct active_request_slot *slot)

0 commit comments

Comments
 (0)