1
0
mirror of https://github.com/moparisthebest/curl synced 2024-12-21 23:58:49 -05:00

T. Bharath pointed out the flaw in ConnectionExists() for how we didn't

check proxy connections for "deadness" before they were re-used
This commit is contained in:
Daniel Stenberg 2002-04-04 12:23:14 +00:00
parent 1cfcbc50a6
commit a03fd7b81c

View File

@ -1062,6 +1062,7 @@ ConnectionExists(struct SessionHandle *data,
struct connectdata *check; struct connectdata *check;
for(i=0; i< data->state.numconnects; i++) { for(i=0; i< data->state.numconnects; i++) {
bool match = FALSE;
/* /*
* Note that if we use a HTTP proxy, we check connections to that * Note that if we use a HTTP proxy, we check connections to that
* proxy and not to the actual remote server. * proxy and not to the actual remote server.
@ -1082,7 +1083,6 @@ ConnectionExists(struct SessionHandle *data,
if(strequal(needle->protostr, check->protostr) && if(strequal(needle->protostr, check->protostr) &&
strequal(needle->name, check->name) && strequal(needle->name, check->name) &&
(needle->remote_port == check->remote_port) ) { (needle->remote_port == check->remote_port) ) {
bool dead;
if(strequal(needle->protostr, "FTP")) { if(strequal(needle->protostr, "FTP")) {
/* This is FTP, verify that we're using the same name and /* This is FTP, verify that we're using the same name and
password as well */ password as well */
@ -1092,27 +1092,7 @@ ConnectionExists(struct SessionHandle *data,
continue; continue;
} }
} }
dead = SocketIsDead(check->firstsocket); match = TRUE;
if(dead) {
/*
* Even though the connection seems to have passed away, we could
* still make an effort to get the name information, as we intend to
* connect to the same host again.
*
* This is now subject to discussion. What do you think?
*/
infof(data, "Connection %d seems to be dead!\n", i);
Curl_disconnect(check); /* disconnect resources */
data->state.connects[i]=NULL; /* nothing here */
/* There's no need to continue search, because we only store
one connection for each unique set of identifiers */
return FALSE;
}
*usethis = check;
return TRUE; /* yes, we found one to use! */
} }
} }
else { /* The requested needle connection is using a proxy, else { /* The requested needle connection is using a proxy,
@ -1121,10 +1101,27 @@ ConnectionExists(struct SessionHandle *data,
strequal(needle->proxyhost, check->proxyhost) && strequal(needle->proxyhost, check->proxyhost) &&
needle->port == check->port) { needle->port == check->port) {
/* This is the same proxy connection, use it! */ /* This is the same proxy connection, use it! */
*usethis = check; match = TRUE;
return TRUE;
} }
} }
if(match) {
bool dead = SocketIsDead(check->firstsocket);
if(dead) {
/*
*/
infof(data, "Connection %d seems to be dead!\n", i);
Curl_disconnect(check); /* disconnect resources */
data->state.connects[i]=NULL; /* nothing here */
/* There's no need to continue searching, because we only store
one connection for each unique set of identifiers */
return FALSE;
}
*usethis = check;
return TRUE; /* yes, we found one to use! */
}
} }
return FALSE; /* no matching connecting exists */ return FALSE; /* no matching connecting exists */
} }