summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2022-06-08 14:27:50 -0700
committerJohannes Schindelin <johannes.schindelin@gmx.de>2023-03-22 18:00:34 +0100
commit0737200a06bc045c20ee07728c2dc4f3229f48ec (patch)
tree1a82444d1c8690219c02125792a2539ba3040753
parent0a1dc55c40533695ab595805675e08a539b20a20 (diff)
parent5843080c85ae9d13f77442bec7bbec8e84a18100 (diff)
downloadgit-0737200a06bc045c20ee07728c2dc4f3229f48ec.tar.gz
Merge branch 'backport/jc/http-clear-finished-pointer' into maint-2.30
Meant to go with js/ci-gcc-12-fixes. source: <xmqq7d68ytj8.fsf_-_@gitster.g> * jc/http-clear-finished-pointer: http.c: clear the 'finished' member once we are done with it
-rw-r--r--http.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/http.c b/http.c
index 8b23a546af..f44209881e 100644
--- a/http.c
+++ b/http.c
@@ -1523,6 +1523,32 @@ void run_active_slot(struct active_request_slot *slot)
finish_active_slot(slot);
}
#endif
+
+ /*
+ * The value of slot->finished we set before the loop was used
+ * to set our "finished" variable when our request completed.
+ *
+ * 1. The slot may not have been reused for another requst
+ * yet, in which case it still has &finished.
+ *
+ * 2. The slot may already be in-use to serve another request,
+ * which can further be divided into two cases:
+ *
+ * (a) If call run_active_slot() hasn't been called for that
+ * other request, slot->finished would have been cleared
+ * by get_active_slot() and has NULL.
+ *
+ * (b) If the request did call run_active_slot(), then the
+ * call would have updated slot->finished at the beginning
+ * of this function, and with the clearing of the member
+ * below, we would find that slot->finished is now NULL.
+ *
+ * In all cases, slot->finished has no useful information to
+ * anybody at this point. Some compilers warn us for
+ * attempting to smuggle a pointer that is about to become
+ * invalid, i.e. &finished. We clear it here to assure them.
+ */
+ slot->finished = NULL;
}
static void release_active_slot(struct active_request_slot *slot)