mirror of
https://github.com/moparisthebest/curl
synced 2024-12-21 23:58:49 -05:00
Fixed an out of memory handling issue with HTTP pipelines.
This commit is contained in:
parent
acc4868b78
commit
9f72db13c4
51
lib/multi.c
51
lib/multi.c
@ -121,9 +121,9 @@ struct Curl_one_easy {
|
|||||||
#define CURL_MULTI_HANDLE 0x000bab1e
|
#define CURL_MULTI_HANDLE 0x000bab1e
|
||||||
|
|
||||||
#define GOOD_MULTI_HANDLE(x) \
|
#define GOOD_MULTI_HANDLE(x) \
|
||||||
((x)&&(((struct Curl_multi *)x)->type == CURL_MULTI_HANDLE))
|
((x)&&(((struct Curl_multi *)(x))->type == CURL_MULTI_HANDLE))
|
||||||
#define GOOD_EASY_HANDLE(x) \
|
#define GOOD_EASY_HANDLE(x) \
|
||||||
(((struct SessionHandle *)x)->magic == CURLEASY_MAGIC_NUMBER)
|
(((struct SessionHandle *)(x))->magic == CURLEASY_MAGIC_NUMBER)
|
||||||
|
|
||||||
/* This is the struct known as CURLM on the outside */
|
/* This is the struct known as CURLM on the outside */
|
||||||
struct Curl_multi {
|
struct Curl_multi {
|
||||||
@ -180,7 +180,7 @@ static void add_closure(struct Curl_multi *multi,
|
|||||||
static int update_timer(struct Curl_multi *multi);
|
static int update_timer(struct Curl_multi *multi);
|
||||||
|
|
||||||
#ifdef CURLDEBUG
|
#ifdef CURLDEBUG
|
||||||
static const char *statename[]={
|
static const char * const statename[]={
|
||||||
"INIT",
|
"INIT",
|
||||||
"CONNECT",
|
"CONNECT",
|
||||||
"WAITRESOLVE",
|
"WAITRESOLVE",
|
||||||
@ -896,29 +896,30 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
|
|||||||
|
|
||||||
if(CURLE_OK == easy->result) {
|
if(CURLE_OK == easy->result) {
|
||||||
/* Add this handle to the send pipeline */
|
/* Add this handle to the send pipeline */
|
||||||
Curl_addHandleToPipeline(easy->easy_handle,
|
easy->result = Curl_addHandleToPipeline(easy->easy_handle,
|
||||||
easy->easy_conn->send_pipe);
|
easy->easy_conn->send_pipe);
|
||||||
|
if(CURLE_OK == easy->result) {
|
||||||
|
if(async)
|
||||||
|
/* We're now waiting for an asynchronous name lookup */
|
||||||
|
multistate(easy, CURLM_STATE_WAITRESOLVE);
|
||||||
|
else {
|
||||||
|
/* after the connect has been sent off, go WAITCONNECT unless the
|
||||||
|
protocol connect is already done and we can go directly to
|
||||||
|
WAITDO! */
|
||||||
|
result = CURLM_CALL_MULTI_PERFORM;
|
||||||
|
|
||||||
if(async)
|
if(protocol_connect)
|
||||||
/* We're now waiting for an asynchronous name lookup */
|
multistate(easy, CURLM_STATE_WAITDO);
|
||||||
multistate(easy, CURLM_STATE_WAITRESOLVE);
|
else {
|
||||||
else {
|
|
||||||
/* after the connect has been sent off, go WAITCONNECT unless the
|
|
||||||
protocol connect is already done and we can go directly to
|
|
||||||
WAITDO! */
|
|
||||||
result = CURLM_CALL_MULTI_PERFORM;
|
|
||||||
|
|
||||||
if(protocol_connect)
|
|
||||||
multistate(easy, CURLM_STATE_WAITDO);
|
|
||||||
else {
|
|
||||||
#ifndef CURL_DISABLE_HTTP
|
#ifndef CURL_DISABLE_HTTP
|
||||||
if (easy->easy_conn->bits.tunnel_connecting)
|
if (easy->easy_conn->bits.tunnel_connecting)
|
||||||
multistate(easy, CURLM_STATE_WAITPROXYCONNECT);
|
multistate(easy, CURLM_STATE_WAITPROXYCONNECT);
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
multistate(easy, CURLM_STATE_WAITCONNECT);
|
multistate(easy, CURLM_STATE_WAITCONNECT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -1153,8 +1154,8 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
|
|||||||
Curl_removeHandleFromPipeline(easy->easy_handle,
|
Curl_removeHandleFromPipeline(easy->easy_handle,
|
||||||
easy->easy_conn->send_pipe);
|
easy->easy_conn->send_pipe);
|
||||||
/* Add ourselves to the recv pipeline */
|
/* Add ourselves to the recv pipeline */
|
||||||
Curl_addHandleToPipeline(easy->easy_handle,
|
easy->result = Curl_addHandleToPipeline(easy->easy_handle,
|
||||||
easy->easy_conn->recv_pipe);
|
easy->easy_conn->recv_pipe);
|
||||||
multistate(easy, CURLM_STATE_WAITPERFORM);
|
multistate(easy, CURLM_STATE_WAITPERFORM);
|
||||||
result = CURLM_CALL_MULTI_PERFORM;
|
result = CURLM_CALL_MULTI_PERFORM;
|
||||||
|
|
||||||
|
11
lib/url.c
11
lib/url.c
@ -1925,8 +1925,8 @@ static bool IsPipeliningEnabled(struct SessionHandle *handle)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Curl_addHandleToPipeline(struct SessionHandle *data,
|
CURLcode Curl_addHandleToPipeline(struct SessionHandle *data,
|
||||||
struct curl_llist *pipe)
|
struct curl_llist *pipe)
|
||||||
{
|
{
|
||||||
#ifdef CURLDEBUG
|
#ifdef CURLDEBUG
|
||||||
if(!IsPipeliningPossible(data)) {
|
if(!IsPipeliningPossible(data)) {
|
||||||
@ -1935,7 +1935,9 @@ void Curl_addHandleToPipeline(struct SessionHandle *data,
|
|||||||
infof(data, "PIPE when no PIPE supposed!\n");
|
infof(data, "PIPE when no PIPE supposed!\n");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
Curl_llist_insert_next(pipe, pipe->tail, data);
|
if (!Curl_llist_insert_next(pipe, pipe->tail, data))
|
||||||
|
return CURLE_OUT_OF_MEMORY;
|
||||||
|
return CURLE_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1995,6 +1997,9 @@ static void signalPipeClose(struct curl_llist *pipe)
|
|||||||
{
|
{
|
||||||
struct curl_llist_element *curr;
|
struct curl_llist_element *curr;
|
||||||
|
|
||||||
|
if (!pipe)
|
||||||
|
return;
|
||||||
|
|
||||||
curr = pipe->head;
|
curr = pipe->head;
|
||||||
while (curr) {
|
while (curr) {
|
||||||
struct curl_llist_element *next = curr->next;
|
struct curl_llist_element *next = curr->next;
|
||||||
|
@ -62,8 +62,8 @@ int Curl_doing_getsock(struct connectdata *conn,
|
|||||||
curl_socket_t *socks,
|
curl_socket_t *socks,
|
||||||
int numsocks);
|
int numsocks);
|
||||||
|
|
||||||
void Curl_addHandleToPipeline(struct SessionHandle *handle,
|
CURLcode Curl_addHandleToPipeline(struct SessionHandle *handle,
|
||||||
struct curl_llist *pipe);
|
struct curl_llist *pipe);
|
||||||
int Curl_removeHandleFromPipeline(struct SessionHandle *handle,
|
int Curl_removeHandleFromPipeline(struct SessionHandle *handle,
|
||||||
struct curl_llist *pipe);
|
struct curl_llist *pipe);
|
||||||
bool Curl_isHandleAtHead(struct SessionHandle *handle,
|
bool Curl_isHandleAtHead(struct SessionHandle *handle,
|
||||||
|
Loading…
Reference in New Issue
Block a user