Skip to content

Commit

Permalink
url: use a fresh easy handle with connections from the cache
Browse files Browse the repository at this point in the history
... and make sure to NULLify the ->data pointer when the connection is put
into the cache to make this mistake easier to detect in the future.

Reported-by: Will Dietz
Closes #2669
  • Loading branch information
bagder committed Jun 20, 2018
1 parent dfb873e commit 3475034
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion lib/conncache.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* \___|\___/|_| \_\_____|
*
* Copyright (C) 2012 - 2016, Linus Nielsen Feltzing, <linus@haxx.se>
* Copyright (C) 2012 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
* Copyright (C) 2012 - 2018, 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
Expand Down Expand Up @@ -451,6 +451,7 @@ bool Curl_conncache_return_conn(struct connectdata *conn)
}
CONN_LOCK(data);
conn->inuse = FALSE; /* Mark the connection unused */
conn->data = NULL; /* no owner */
CONN_UNLOCK(data);

return (conn_candidate == conn) ? FALSE : TRUE;
Expand Down
2 changes: 1 addition & 1 deletion lib/url.c
Original file line number Diff line number Diff line change
Expand Up @@ -965,6 +965,7 @@ static bool extract_if_dead(struct connectdata *conn,
use */
bool dead;

conn->data = data;
if(conn->handler->connection_check) {
/* The protocol has a special method for checking the state of the
connection. Use it to check if the connection is dead. */
Expand All @@ -979,7 +980,6 @@ static bool extract_if_dead(struct connectdata *conn,
}

if(dead) {
conn->data = data;
infof(data, "Connection %ld seems to be dead!\n", conn->connection_id);
Curl_conncache_remove_conn(conn, FALSE);
return TRUE;
Expand Down

0 comments on commit 3475034

Please sign in to comment.