From 9f1b58842a44e8f0dc8fb4a447449cb31957b4bf Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Tue, 13 Sep 2016 00:25:55 +0000 Subject: http: warn on curl_multi_add_handle failures This will be useful for tracking down curl usage errors. Signed-off-by: Eric Wong Signed-off-by: Junio C Hamano --- http.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'http.c') diff --git a/http.c b/http.c index c29ce81cc..d20e9c108 100644 --- a/http.c +++ b/http.c @@ -709,6 +709,8 @@ int start_active_slot(struct active_request_slot *slot) if (curlm_result != CURLM_OK && curlm_result != CURLM_CALL_MULTI_PERFORM) { + warning("curl_multi_add_handle failed: %s", + curl_multi_strerror(curlm_result)); active_requests--; slot->in_use = 0; return 0; -- cgit v1.2.1 From d8b6b84df024b4ce2c10d7e5c725da24dcb19ff6 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Tue, 13 Sep 2016 00:25:56 +0000 Subject: http: consolidate #ifdefs for curl_multi_remove_handle I find #ifdefs makes code difficult-to-follow. An early version of this patch had error checking for curl_multi_remove_handle calls, but caused some tests (e.g. t5541) to fail under curl 7.26.0 on old Debian wheezy. Signed-off-by: Eric Wong Signed-off-by: Junio C Hamano --- http.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'http.c') diff --git a/http.c b/http.c index d20e9c108..a24f0d132 100644 --- a/http.c +++ b/http.c @@ -167,6 +167,13 @@ static void finish_active_slot(struct active_request_slot *slot) slot->callback_func(slot->callback_data); } +static void xmulti_remove_handle(struct active_request_slot *slot) +{ +#ifdef USE_CURL_MULTI + curl_multi_remove_handle(curlm, slot->curl); +#endif +} + #ifdef USE_CURL_MULTI static void process_curl_messages(void) { @@ -182,7 +189,7 @@ static void process_curl_messages(void) slot->curl != curl_message->easy_handle) slot = slot->next; if (slot != NULL) { - curl_multi_remove_handle(curlm, slot->curl); + xmulti_remove_handle(slot); slot->curl_result = curl_result; finish_active_slot(slot); } else { @@ -588,9 +595,7 @@ void http_cleanup(void) while (slot != NULL) { struct active_request_slot *next = slot->next; if (slot->curl != NULL) { -#ifdef USE_CURL_MULTI - curl_multi_remove_handle(curlm, slot->curl); -#endif + xmulti_remove_handle(slot); curl_easy_cleanup(slot->curl); } free(slot); @@ -851,9 +856,7 @@ static void release_active_slot(struct active_request_slot *slot) { closedown_active_slot(slot); if (slot->curl && curl_session_count > min_curl_sessions) { -#ifdef USE_CURL_MULTI - curl_multi_remove_handle(curlm, slot->curl); -#endif + xmulti_remove_handle(slot); curl_easy_cleanup(slot->curl); slot->curl = NULL; curl_session_count--; -- cgit v1.2.1 From 2abc848d5431d028b4a6c643c93c7e371e7fdc7e Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Tue, 13 Sep 2016 00:25:57 +0000 Subject: http: always remove curl easy from curlm session on release We must call curl_multi_remove_handle when releasing the slot to prevent subsequent calls to curl_multi_add_handle from failing with CURLM_ADDED_ALREADY (in curl 7.32.1+; older versions returned CURLM_BAD_EASY_HANDLE) Signed-off-by: Eric Wong Signed-off-by: Junio C Hamano --- http.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'http.c') diff --git a/http.c b/http.c index a24f0d132..6a97783d0 100644 --- a/http.c +++ b/http.c @@ -855,11 +855,13 @@ void run_active_slot(struct active_request_slot *slot) static void release_active_slot(struct active_request_slot *slot) { closedown_active_slot(slot); - if (slot->curl && curl_session_count > min_curl_sessions) { + if (slot->curl) { xmulti_remove_handle(slot); - curl_easy_cleanup(slot->curl); - slot->curl = NULL; - curl_session_count--; + if (curl_session_count > min_curl_sessions) { + curl_easy_cleanup(slot->curl); + slot->curl = NULL; + curl_session_count--; + } } #ifdef USE_CURL_MULTI fill_active_slots(); -- cgit v1.2.1