Skip to content

Commit

Permalink
multi: remove_handle: move pending connections
Browse files Browse the repository at this point in the history
If the handle removed from the multi handle happens to be the one
"owning" the pipeline other transfers will be waiting indefinitely. Now
we move such handles back to connect to have them race (again) for
getting the connection and thus avoid hanging.

Bug: http://curl.haxx.se/bug/view.cgi?id=1465
Reported-by: Jiri Dvorak
  • Loading branch information
bagder committed Mar 29, 2015
1 parent 31987c3 commit 787c2ae
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/multi.c
Expand Up @@ -504,18 +504,22 @@ CURLMcode curl_multi_remove_handle(CURLM *multi_handle,
if(!data->multi)
return CURLM_OK; /* it is already removed so let's say it is fine! */


premature = (data->mstate < CURLM_STATE_COMPLETED) ? TRUE : FALSE;
easy_owns_conn = (data->easy_conn && (data->easy_conn->data == easy)) ?
TRUE : FALSE;

/* If the 'state' is not INIT or COMPLETED, we might need to do something
nice to put the easy_handle in a good known state when this returns. */
if(premature)
if(premature) {
/* this handle is "alive" so we need to count down the total number of
alive connections when this is removed */
multi->num_alive--;

/* When this handle gets removed, other handles may be able to get the
connection */
Curl_multi_process_pending_handles(multi);
}

if(data->easy_conn &&
data->mstate > CURLM_STATE_DO &&
data->mstate < CURLM_STATE_COMPLETED) {
Expand Down

0 comments on commit 787c2ae

Please sign in to comment.