Merge branch 'ew/http-do-not-forget-to-call-curl-multi-remove-handle'
The http transport (with curl-multi option, which is the default these days) failed to remove curl-easy handle from a curlm session, which led to unnecessary API failures. * ew/http-do-not-forget-to-call-curl-multi-remove-handle: http: always remove curl easy from curlm session on release http: consolidate #ifdefs for curl_multi_remove_handle http: warn on curl_multi_add_handle failures
This commit is contained in:
commit
ac8ddd7ba3
29
http.c
29
http.c
@ -201,6 +201,13 @@ static void finish_active_slot(struct active_request_slot *slot)
|
|||||||
slot->callback_func(slot->callback_data);
|
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
|
#ifdef USE_CURL_MULTI
|
||||||
static void process_curl_messages(void)
|
static void process_curl_messages(void)
|
||||||
{
|
{
|
||||||
@ -216,7 +223,7 @@ static void process_curl_messages(void)
|
|||||||
slot->curl != curl_message->easy_handle)
|
slot->curl != curl_message->easy_handle)
|
||||||
slot = slot->next;
|
slot = slot->next;
|
||||||
if (slot != NULL) {
|
if (slot != NULL) {
|
||||||
curl_multi_remove_handle(curlm, slot->curl);
|
xmulti_remove_handle(slot);
|
||||||
slot->curl_result = curl_result;
|
slot->curl_result = curl_result;
|
||||||
finish_active_slot(slot);
|
finish_active_slot(slot);
|
||||||
} else {
|
} else {
|
||||||
@ -881,9 +888,7 @@ void http_cleanup(void)
|
|||||||
while (slot != NULL) {
|
while (slot != NULL) {
|
||||||
struct active_request_slot *next = slot->next;
|
struct active_request_slot *next = slot->next;
|
||||||
if (slot->curl != NULL) {
|
if (slot->curl != NULL) {
|
||||||
#ifdef USE_CURL_MULTI
|
xmulti_remove_handle(slot);
|
||||||
curl_multi_remove_handle(curlm, slot->curl);
|
|
||||||
#endif
|
|
||||||
curl_easy_cleanup(slot->curl);
|
curl_easy_cleanup(slot->curl);
|
||||||
}
|
}
|
||||||
free(slot);
|
free(slot);
|
||||||
@ -1022,6 +1027,8 @@ int start_active_slot(struct active_request_slot *slot)
|
|||||||
|
|
||||||
if (curlm_result != CURLM_OK &&
|
if (curlm_result != CURLM_OK &&
|
||||||
curlm_result != CURLM_CALL_MULTI_PERFORM) {
|
curlm_result != CURLM_CALL_MULTI_PERFORM) {
|
||||||
|
warning("curl_multi_add_handle failed: %s",
|
||||||
|
curl_multi_strerror(curlm_result));
|
||||||
active_requests--;
|
active_requests--;
|
||||||
slot->in_use = 0;
|
slot->in_use = 0;
|
||||||
return 0;
|
return 0;
|
||||||
@ -1161,13 +1168,13 @@ void run_active_slot(struct active_request_slot *slot)
|
|||||||
static void release_active_slot(struct active_request_slot *slot)
|
static void release_active_slot(struct active_request_slot *slot)
|
||||||
{
|
{
|
||||||
closedown_active_slot(slot);
|
closedown_active_slot(slot);
|
||||||
if (slot->curl && curl_session_count > min_curl_sessions) {
|
if (slot->curl) {
|
||||||
#ifdef USE_CURL_MULTI
|
xmulti_remove_handle(slot);
|
||||||
curl_multi_remove_handle(curlm, slot->curl);
|
if (curl_session_count > min_curl_sessions) {
|
||||||
#endif
|
curl_easy_cleanup(slot->curl);
|
||||||
curl_easy_cleanup(slot->curl);
|
slot->curl = NULL;
|
||||||
slot->curl = NULL;
|
curl_session_count--;
|
||||||
curl_session_count--;
|
}
|
||||||
}
|
}
|
||||||
#ifdef USE_CURL_MULTI
|
#ifdef USE_CURL_MULTI
|
||||||
fill_active_slots();
|
fill_active_slots();
|
||||||
|
Loading…
Reference in New Issue
Block a user