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 <e@80x24.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Eric Wong committed Sep 13, 2016 at 00:25 UTC d8b6b84df024b4ce2c10d7e5c725da24dcb19ff6
1 file changed +10 -7
http.c
+10 -7
@@ -167,6 +167,13 @@ static void finish_active_slot(struct active_request_slot *slot)
167 slot->callback_func(slot->callback_data);
168 }
169
170 +static void xmulti_remove_handle(struct active_request_slot *slot)
171 +{
172 +#ifdef USE_CURL_MULTI
173 + curl_multi_remove_handle(curlm, slot->curl);
174 +#endif
175 +}
176 +
177 #ifdef USE_CURL_MULTI
178 static void process_curl_messages(void)
179 {
@@ -182,7 +189,7 @@ static void process_curl_messages(void)
189 slot->curl != curl_message->easy_handle)
190 slot = slot->next;
191 if (slot != NULL) {
185 - curl_multi_remove_handle(curlm, slot->curl);
192 + xmulti_remove_handle(slot);
193 slot->curl_result = curl_result;
194 finish_active_slot(slot);
195 } else {
@@ -588,9 +595,7 @@ void http_cleanup(void)
595 while (slot != NULL) {
596 struct active_request_slot *next = slot->next;
597 if (slot->curl != NULL) {
591 -#ifdef USE_CURL_MULTI
592 - curl_multi_remove_handle(curlm, slot->curl);
593 -#endif
598 + xmulti_remove_handle(slot);
599 curl_easy_cleanup(slot->curl);
600 }
601 free(slot);
@@ -851,9 +856,7 @@ static void release_active_slot(struct active_request_slot *slot)
856 {
857 closedown_active_slot(slot);
858 if (slot->curl && curl_session_count > min_curl_sessions) {
854 -#ifdef USE_CURL_MULTI
855 - curl_multi_remove_handle(curlm, slot->curl);
856 -#endif
859 + xmulti_remove_handle(slot);
860 curl_easy_cleanup(slot->curl);
861 slot->curl = NULL;
862 curl_session_count--;