diff options
author | Lindley French <lindleyf@gmail.com> | 2014-06-12 11:36:41 -0700 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2014-06-13 15:05:24 +0200 |
commit | 964e43c5e21482f9a0ff8f0be135c4ab8afa9330 (patch) | |
tree | ae87b7fa23ca7952fd1ef902d79bb72efb8b5a97 /lib | |
parent | d5d98c1297dd7ed2c6d649e064ad694823829076 (diff) |
conncache: move the connection counter to the cache struct
The static connection counter caused a race condition. Moving the
connection id counter into conncache solves it, as well as simplifying
the related logic.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/conncache.c | 1 | ||||
-rw-r--r-- | lib/conncache.h | 1 | ||||
-rw-r--r-- | lib/url.c | 14 |
3 files changed, 3 insertions, 13 deletions
diff --git a/lib/conncache.c b/lib/conncache.c index 3ee64157f..290638ea0 100644 --- a/lib/conncache.c +++ b/lib/conncache.c @@ -149,6 +149,7 @@ CURLcode Curl_conncache_add_conn(struct conncache *connc, return result; } + conn->connection_id = connc->next_connection_id++; connc->num_connections++; return CURLE_OK; diff --git a/lib/conncache.h b/lib/conncache.h index f5e41f187..691f061f9 100644 --- a/lib/conncache.h +++ b/lib/conncache.h @@ -25,6 +25,7 @@ struct conncache { struct curl_hash *hash; size_t num_connections; + size_t next_connection_id; }; struct conncache *Curl_conncache_init(int size); @@ -3254,19 +3254,7 @@ ConnectionDone(struct SessionHandle *data, struct connectdata *conn) static CURLcode ConnectionStore(struct SessionHandle *data, struct connectdata *conn) { - static int connection_id_counter = 0; - - CURLcode result; - - /* Assign a number to the connection for easier tracking in the log - output */ - conn->connection_id = connection_id_counter++; - - result = Curl_conncache_add_conn(data->state.conn_cache, conn); - if(result != CURLE_OK) - conn->connection_id = -1; - - return result; + return Curl_conncache_add_conn(data->state.conn_cache, conn); } /* after a TCP connection to the proxy has been verified, this function does |