if(!multi->msglist)
goto error;
+ multi->pending = Curl_llist_alloc(multi_freeamsg);
+ if(!multi->pending)
+ goto error;
+
/* allocate a new easy handle to use when closing cached connections */
multi->closure_handle = curl_easy_init();
if(!multi->closure_handle)
Curl_close(multi->closure_handle);
multi->closure_handle = NULL;
Curl_llist_destroy(multi->msglist, NULL);
+ Curl_llist_destroy(multi->pending, NULL);
free(multi);
return NULL;
/* There was no connection available. We will go to the pending
state and wait for an available connection. */
multistate(data, CURLM_STATE_CONNECT_PEND);
- data->result = CURLE_OK;
+
+ /* add this handle to the list of connect-pending handles */
+ if(!Curl_llist_insert_next(multi->pending, multi->pending->tail, data))
+ data->result = CURLM_OUT_OF_MEMORY;
+ else
+ data->result = CURLE_OK;
break;
}
Curl_llist_destroy(multi->msglist, NULL);
multi->msglist = NULL;
+ /* remove the pending handles queue */
+ Curl_llist_destroy(multi->pending, NULL);
+ multi->msglist = NULL;
+
/* remove all easy handles */
data = multi->easyp;
while(data) {
void Curl_multi_process_pending_handles(struct Curl_multi *multi)
{
- struct SessionHandle *data;
+ struct curl_llist_element *e;
- data=multi->easyp;
- while(data) {
+ for(e = multi->pending->head; e; e = e->next) {
+ struct SessionHandle *data = e->ptr;
if(data->mstate == CURLM_STATE_CONNECT_PEND) {
multistate(data, CURLM_STATE_CONNECT);
+ /* Remove this node from the list */
+ Curl_llist_remove(multi->pending, e, NULL);
/* Make sure that the handle will be processed soonish. */
- Curl_expire(data, 1);
+ Curl_expire_latest(data, 1);
}
- data = data->next; /* operate on next handle */
}
}
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2013, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
struct curl_llist *msglist; /* a list of messages from completed transfers */
+ struct curl_llist *pending; /* SessionHandles that are in the
+ CURLM_STATE_CONNECT_PEND state */
+
/* callback function and user data pointer for the *socket() API */
curl_socket_callback socket_cb;
void *socket_userp;