mirror of
https://github.com/moparisthebest/curl
synced 2024-12-25 09:38:54 -05:00
conn_shutdown: if closed during CONNECT cleanup properly
Reported-by: Alex Xu Reported-by: Phil E. Taylor Fixes #7236 Closes #7237
This commit is contained in:
parent
02dfe71937
commit
14a2ca85ec
@ -129,13 +129,13 @@ CURLcode Curl_proxy_connect(struct Curl_easy *data, int sockindex)
|
|||||||
bool Curl_connect_complete(struct connectdata *conn)
|
bool Curl_connect_complete(struct connectdata *conn)
|
||||||
{
|
{
|
||||||
return !conn->connect_state ||
|
return !conn->connect_state ||
|
||||||
(conn->connect_state->tunnel_state == TUNNEL_COMPLETE);
|
(conn->connect_state->tunnel_state >= TUNNEL_COMPLETE);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Curl_connect_ongoing(struct connectdata *conn)
|
bool Curl_connect_ongoing(struct connectdata *conn)
|
||||||
{
|
{
|
||||||
return conn->connect_state &&
|
return conn->connect_state &&
|
||||||
(conn->connect_state->tunnel_state != TUNNEL_COMPLETE);
|
(conn->connect_state->tunnel_state <= TUNNEL_COMPLETE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* when we've sent a CONNECT to a proxy, we should rather either wait for the
|
/* when we've sent a CONNECT to a proxy, we should rather either wait for the
|
||||||
@ -202,14 +202,17 @@ static void connect_done(struct Curl_easy *data)
|
|||||||
{
|
{
|
||||||
struct connectdata *conn = data->conn;
|
struct connectdata *conn = data->conn;
|
||||||
struct http_connect_state *s = conn->connect_state;
|
struct http_connect_state *s = conn->connect_state;
|
||||||
s->tunnel_state = TUNNEL_COMPLETE;
|
if(s->tunnel_state != TUNNEL_EXIT) {
|
||||||
|
s->tunnel_state = TUNNEL_EXIT;
|
||||||
Curl_dyn_free(&s->rcvbuf);
|
Curl_dyn_free(&s->rcvbuf);
|
||||||
Curl_dyn_free(&s->req);
|
Curl_dyn_free(&s->req);
|
||||||
|
|
||||||
/* retore the protocol pointer */
|
/* retore the protocol pointer */
|
||||||
data->req.p.http = s->prot_save;
|
data->req.p.http = s->prot_save;
|
||||||
|
s->prot_save = NULL;
|
||||||
infof(data, "CONNECT phase completed!\n");
|
infof(data, "CONNECT phase completed!\n");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static CURLcode CONNECT_host(struct Curl_easy *data,
|
static CURLcode CONNECT_host(struct Curl_easy *data,
|
||||||
struct connectdata *conn,
|
struct connectdata *conn,
|
||||||
|
@ -67,7 +67,8 @@ struct http_connect_state {
|
|||||||
enum {
|
enum {
|
||||||
TUNNEL_INIT, /* init/default/no tunnel state */
|
TUNNEL_INIT, /* init/default/no tunnel state */
|
||||||
TUNNEL_CONNECT, /* CONNECT has been sent off */
|
TUNNEL_CONNECT, /* CONNECT has been sent off */
|
||||||
TUNNEL_COMPLETE /* CONNECT response received completely */
|
TUNNEL_COMPLETE, /* CONNECT response received completely */
|
||||||
|
TUNNEL_EXIT
|
||||||
} tunnel_state;
|
} tunnel_state;
|
||||||
BIT(chunked_encoding);
|
BIT(chunked_encoding);
|
||||||
BIT(close_connection);
|
BIT(close_connection);
|
||||||
|
@ -727,6 +727,15 @@ static void conn_shutdown(struct Curl_easy *data, struct connectdata *conn)
|
|||||||
DEBUGASSERT(data);
|
DEBUGASSERT(data);
|
||||||
infof(data, "Closing connection %ld\n", conn->connection_id);
|
infof(data, "Closing connection %ld\n", conn->connection_id);
|
||||||
|
|
||||||
|
#ifndef USE_HYPER
|
||||||
|
if(conn->connect_state && conn->connect_state->prot_save) {
|
||||||
|
/* If this was closed with a CONNECT in progress, cleanup this temporary
|
||||||
|
struct arrangement */
|
||||||
|
data->req.p.http = NULL;
|
||||||
|
Curl_safefree(conn->connect_state->prot_save);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* possible left-overs from the async name resolvers */
|
/* possible left-overs from the async name resolvers */
|
||||||
Curl_resolver_cancel(data);
|
Curl_resolver_cancel(data);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user