git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: maybe breakage with latest git-pull and http protocol

From
NHNick Hengeveld <nickh@reactrix.com>
Date
Oct 20, 2005, 17:43 UTC
Message-ID
<20051020174324.GD6160@reactrix.com>
In-Reply-To
<867jciz18w.fsf@blue.stonehenge.com>

Can you try using the following patch? This cleans up curl handles for active request slots that are no longer in use. If all other prefetched requests finish while a large transfer is happening, the active slots currently keep open connections to the server and I'm guessing that perhaps by the time additional objects are prefetched the server has timed out some of those keepalive connections.

---
 http-fetch.c |   26 ++++++++++++++++++++------
 1 files changed, 20 insertions(+), 6 deletions(-)

applies-to: ce9a5a0fdd52a29e370d849a132b4509c844aca1 04b4353279eaceb7e7c3d73a9565b219aa7a10a9

diff --git a/http-fetch.c b/http-fetch.c
index a7dc2cc..d26fae8 100644
--- a/http-fetch.c
+++ b/http-fetch.c
@@ -291,11 +291,7 @@ static struct active_request_slot *get_a
 	}
 	if (slot == NULL) {
 		newslot = xmalloc(sizeof(*newslot));
-#ifdef NO_CURL_EASY_DUPHANDLE
-		newslot->curl = get_curl_handle();
-#else
-		newslot->curl = curl_easy_duphandle(curl_default);
-#endif
+		newslot->curl = NULL;
 		newslot->in_use = 0;
 		newslot->next = NULL;
 
@@ -311,6 +307,14 @@ static struct active_request_slot *get_a
 		slot = newslot;
 	}
 
+	if (slot->curl == NULL) {
+#ifdef NO_CURL_EASY_DUPHANDLE
+		slot->curl = get_curl_handle();
+#else
+		slot->curl = curl_easy_duphandle(curl_default);
+#endif
+	}
+
 	active_requests++;
 	slot->in_use = 1;
 	slot->done = 0;
@@ -612,6 +616,7 @@ void process_curl_messages(void)
 void process_request_queue(void)
 {
 	struct transfer_request *request = request_queue_head;
+	struct active_request_slot *slot = active_queue_head;
 	int num_transfers;
 
 	while (active_requests < max_requests && request != NULL) {
@@ -624,6 +629,14 @@ void process_request_queue(void)
 		}
 		request = request->next;
 	}
+
+	while (slot != NULL) {
+		if (!slot->in_use && slot->curl != NULL) {
+			curl_easy_cleanup(slot->curl);
+			slot->curl = NULL;
+		}
+		slot = slot->next;
+	}				
 }
 #endif
 
@@ -1297,7 +1310,8 @@ int main(int argc, char **argv)
 #endif
 	slot = active_queue_head;
 	while (slot != NULL) {
-		curl_easy_cleanup(slot->curl);
+		if (slot->curl != NULL)
+			curl_easy_cleanup(slot->curl);
 		slot = slot->next;
 	}
 #ifdef USE_CURL_MULTI
---
0.99.8.GIT
-- 
For a successful technology, reality must take precedence over public
relations, for nature cannot be fooled.
Previous: Randal L. Schwartz
Message 17 of 17 in “maybe breakage with latest git-pull and http protocol”
  1. Randal L. SchwartzOct 13, 2005
  2. Junio C HamanoOct 13, 2005
  3. Randal L. SchwartzOct 14, 2005
  4. Junio C HamanoOct 14, 2005
  5. Randal L. SchwartzOct 14, 2005
  6. Daniel BarkalowOct 14, 2005
  7. Randal L. SchwartzOct 15, 2005
  8. Junio C HamanoOct 15, 2005
  9. Junio C HamanoOct 15, 2005
  10. Daniel BarkalowOct 15, 2005
  11. Nick HengeveldOct 15, 2005
  12. Nick HengeveldOct 15, 2005
  13. Junio C HamanoOct 15, 2005
  14. Junio C HamanoOct 15, 2005
  15. Nick HengeveldOct 15, 2005
  16. Randal L. SchwartzOct 15, 2005
  17. Nick HengeveldOct 20, 2005

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.