From 5c7c9a768d009319520142fcaee1dea33625060f Mon Sep 17 00:00:00 2001 From: Kamil Dudka Date: Fri, 19 Nov 2010 13:43:20 +0100 Subject: url: provide dead_connection flag in Curl_handler::disconnect It helps to prevent a hangup with some FTP servers in case idle session timeout has exceeded. But it may be useful also for other protocols that send any quit message on disconnect. Currently used by FTP, POP3, IMAP and SMTP. --- lib/url.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'lib/url.c') diff --git a/lib/url.c b/lib/url.c index f1ab21c2d..93a56002d 100644 --- a/lib/url.c +++ b/lib/url.c @@ -651,7 +651,7 @@ CURLcode Curl_ch_connc(struct SessionHandle *data, close handles not in use. */ for(i=newamount; i< c->num; i++) - Curl_disconnect(c->connects[i]); + Curl_disconnect(c->connects[i], /* dead_connection */ FALSE); /* If the most recent connection is no longer valid, mark it invalid. */ @@ -2587,7 +2587,7 @@ static void conn_free(struct connectdata *conn) free(conn); /* free all the connection oriented data */ } -CURLcode Curl_disconnect(struct connectdata *conn) +CURLcode Curl_disconnect(struct connectdata *conn, bool dead_connection) { struct SessionHandle *data; if(!conn) @@ -2647,7 +2647,7 @@ CURLcode Curl_disconnect(struct connectdata *conn) if(conn->handler->disconnect) /* This is set if protocol-specific cleanups should be made */ - conn->handler->disconnect(conn); + conn->handler->disconnect(conn, dead_connection); if(-1 != conn->connectindex) { /* unlink ourselves! */ @@ -2915,7 +2915,8 @@ ConnectionExists(struct SessionHandle *data, check->data = data; infof(data, "Connection #%ld seems to be dead!\n", i); - Curl_disconnect(check); /* disconnect resources */ + /* disconnect resources */ + Curl_disconnect(check, /* dead_connection */ TRUE); data->state.connc->connects[i]=NULL; /* nothing here */ continue; @@ -3102,7 +3103,7 @@ ConnectionKillOne(struct SessionHandle *data) conn->data = data; /* the winner gets the honour of being disconnected */ - (void)Curl_disconnect(conn); + (void)Curl_disconnect(conn, /* dead_connection */ FALSE); /* clean the array entry */ data->state.connc->connects[connindex] = NULL; @@ -5116,7 +5117,7 @@ CURLcode Curl_connect(struct SessionHandle *data, if(code && *in_connect) { /* We're not allowed to return failure with memory left allocated in the connectdata struct, free those here */ - Curl_disconnect(*in_connect); /* close the connection */ + Curl_disconnect(*in_connect, FALSE); /* close the connection */ *in_connect = NULL; /* return a NULL */ } @@ -5236,7 +5237,7 @@ CURLcode Curl_done(struct connectdata **connp, */ if(data->set.reuse_forbid || conn->bits.close || premature || (-1 == conn->connectindex)) { - CURLcode res2 = Curl_disconnect(conn); /* close the connection */ + CURLcode res2 = Curl_disconnect(conn, FALSE); /* close the connection */ /* If we had an error already, make sure we return that one. But if we got a new error, return that. */ -- cgit v1.2.3