From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS63949 80.85.84.0/22 X-Spam-Status: No, score=-3.3 required=3.0 tests=AWL,BAYES_00,RCVD_IN_XBL, SPF_FAIL,SPF_HELO_FAIL shortcircuit=no autolearn=no autolearn_force=no version=3.4.0 Received: from 80x24.org (tor-exit2.mcintosh.network [80.85.84.23]) by dcvr.yhbt.net (Postfix) with ESMTP id 9DEFE20991 for ; Mon, 12 Sep 2016 22:42:58 +0000 (UTC) From: Eric Wong To: spew@80x24.org Subject: [PATCH 2/3] http: check curl_multi_remove_handle for errors Date: Mon, 12 Sep 2016 22:42:48 +0000 Message-Id: <20160912224249.2520-3-e@80x24.org> In-Reply-To: <20160912224249.2520-1-e@80x24.org> References: <20160912224249.2520-1-e@80x24.org> List-Id: This should help us catch usage errors as well as consolidating the number of #ifdefs in our code. --- http.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/http.c b/http.c index cac5db9..f972ff3 100644 --- a/http.c +++ b/http.c @@ -201,6 +201,17 @@ 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 + CURLMcode code = curl_multi_remove_handle(curlm, slot->curl); + + if (code != CURLM_OK) + die("curl_multi_remove_handle failed: %s", + curl_multi_strerror(code)); +#endif +} + #ifdef USE_CURL_MULTI static void process_curl_messages(void) { @@ -216,7 +227,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 { @@ -881,9 +892,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); @@ -1164,9 +1173,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--; -- EW