mirror of
https://github.com/moparisthebest/curl
synced 2024-11-12 04:25:08 -05:00
url: check Curl_conncache_add_conn return code
... it was previously unchecked in two places and thus errors could remain undetected and cause trouble. Closes #2681
This commit is contained in:
parent
13120f28b3
commit
f762fec323
@ -96,14 +96,13 @@ static void bundle_destroy(struct connectbundle *cb_ptr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Add a connection to a bundle */
|
/* Add a connection to a bundle */
|
||||||
static CURLcode bundle_add_conn(struct connectbundle *cb_ptr,
|
static void bundle_add_conn(struct connectbundle *cb_ptr,
|
||||||
struct connectdata *conn)
|
struct connectdata *conn)
|
||||||
{
|
{
|
||||||
Curl_llist_insert_next(&cb_ptr->conn_list, cb_ptr->conn_list.tail, conn,
|
Curl_llist_insert_next(&cb_ptr->conn_list, cb_ptr->conn_list.tail, conn,
|
||||||
&conn->bundle_node);
|
&conn->bundle_node);
|
||||||
conn->bundle = cb_ptr;
|
conn->bundle = cb_ptr;
|
||||||
cb_ptr->num_connections++;
|
cb_ptr->num_connections++;
|
||||||
return CURLE_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Remove a connection from a bundle */
|
/* Remove a connection from a bundle */
|
||||||
@ -263,7 +262,7 @@ static void conncache_remove_bundle(struct conncache *connc,
|
|||||||
CURLcode Curl_conncache_add_conn(struct conncache *connc,
|
CURLcode Curl_conncache_add_conn(struct conncache *connc,
|
||||||
struct connectdata *conn)
|
struct connectdata *conn)
|
||||||
{
|
{
|
||||||
CURLcode result;
|
CURLcode result = CURLE_OK;
|
||||||
struct connectbundle *bundle;
|
struct connectbundle *bundle;
|
||||||
struct connectbundle *new_bundle = NULL;
|
struct connectbundle *new_bundle = NULL;
|
||||||
struct Curl_easy *data = conn->data;
|
struct Curl_easy *data = conn->data;
|
||||||
@ -290,13 +289,7 @@ CURLcode Curl_conncache_add_conn(struct conncache *connc,
|
|||||||
bundle = new_bundle;
|
bundle = new_bundle;
|
||||||
}
|
}
|
||||||
|
|
||||||
result = bundle_add_conn(bundle, conn);
|
bundle_add_conn(bundle, conn);
|
||||||
if(result) {
|
|
||||||
if(new_bundle)
|
|
||||||
conncache_remove_bundle(data->state.conn_cache, new_bundle);
|
|
||||||
goto unlock;
|
|
||||||
}
|
|
||||||
|
|
||||||
conn->connection_id = connc->next_connection_id++;
|
conn->connection_id = connc->next_connection_id++;
|
||||||
connc->num_conn++;
|
connc->num_conn++;
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* | (__| |_| | _ <| |___
|
* | (__| |_| | _ <| |___
|
||||||
* \___|\___/|_| \_\_____|
|
* \___|\___/|_| \_\_____|
|
||||||
*
|
*
|
||||||
* Copyright (C) 2015 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
|
* Copyright (C) 2015 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||||
* Copyright (C) 2012 - 2014, Linus Nielsen Feltzing, <linus@haxx.se>
|
* Copyright (C) 2012 - 2014, Linus Nielsen Feltzing, <linus@haxx.se>
|
||||||
*
|
*
|
||||||
* This software is licensed as described in the file COPYING, which
|
* This software is licensed as described in the file COPYING, which
|
||||||
@ -63,7 +63,7 @@ size_t Curl_conncache_bundle_size(struct connectdata *conn);
|
|||||||
|
|
||||||
bool Curl_conncache_return_conn(struct connectdata *conn);
|
bool Curl_conncache_return_conn(struct connectdata *conn);
|
||||||
CURLcode Curl_conncache_add_conn(struct conncache *connc,
|
CURLcode Curl_conncache_add_conn(struct conncache *connc,
|
||||||
struct connectdata *conn);
|
struct connectdata *conn) WARN_UNUSED_RESULT;
|
||||||
void Curl_conncache_remove_conn(struct connectdata *conn,
|
void Curl_conncache_remove_conn(struct connectdata *conn,
|
||||||
bool lock);
|
bool lock);
|
||||||
bool Curl_conncache_foreach(struct Curl_easy *data,
|
bool Curl_conncache_foreach(struct Curl_easy *data,
|
||||||
|
@ -4308,7 +4308,9 @@ static CURLcode create_conn(struct Curl_easy *data,
|
|||||||
conn->data = data;
|
conn->data = data;
|
||||||
conn->bits.tcpconnect[FIRSTSOCKET] = TRUE; /* we are "connected */
|
conn->bits.tcpconnect[FIRSTSOCKET] = TRUE; /* we are "connected */
|
||||||
|
|
||||||
Curl_conncache_add_conn(data->state.conn_cache, conn);
|
result = Curl_conncache_add_conn(data->state.conn_cache, conn);
|
||||||
|
if(result)
|
||||||
|
goto out;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Setup whatever necessary for a resumed transfer
|
* Setup whatever necessary for a resumed transfer
|
||||||
@ -4531,7 +4533,9 @@ static CURLcode create_conn(struct Curl_easy *data,
|
|||||||
* This is a brand new connection, so let's store it in the connection
|
* This is a brand new connection, so let's store it in the connection
|
||||||
* cache of ours!
|
* cache of ours!
|
||||||
*/
|
*/
|
||||||
Curl_conncache_add_conn(data->state.conn_cache, conn);
|
result = Curl_conncache_add_conn(data->state.conn_cache, conn);
|
||||||
|
if(result)
|
||||||
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(USE_NTLM)
|
#if defined(USE_NTLM)
|
||||||
|
Loading…
Reference in New Issue
Block a user