mirror of https://github.com/moparisthebest/curl
libssh2: ignore timeout during disconnect
... to avoid memory leaks! libssh2 is tricky as we have to deal with the non-blockiness even in close and shutdown cases. In the cases when we shutdown after a timeout already expired, it is crucial that curl doen't let the timeout abort the shutdown process as that then leaks memory! Reported-by: Benjamin Riefenstahl Fixes #6990
This commit is contained in:
parent
7d7a0a8b09
commit
7645324072
|
@ -2931,7 +2931,7 @@ static CURLcode ssh_multi_statemach(struct Curl_easy *data, bool *done)
|
||||||
|
|
||||||
static CURLcode ssh_block_statemach(struct Curl_easy *data,
|
static CURLcode ssh_block_statemach(struct Curl_easy *data,
|
||||||
struct connectdata *conn,
|
struct connectdata *conn,
|
||||||
bool duringconnect)
|
bool disconnect)
|
||||||
{
|
{
|
||||||
struct ssh_conn *sshc = &conn->proto.sshc;
|
struct ssh_conn *sshc = &conn->proto.sshc;
|
||||||
CURLcode result = CURLE_OK;
|
CURLcode result = CURLE_OK;
|
||||||
|
@ -2945,17 +2945,19 @@ static CURLcode ssh_block_statemach(struct Curl_easy *data,
|
||||||
if(result)
|
if(result)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if(Curl_pgrsUpdate(data))
|
if(!disconnect) {
|
||||||
return CURLE_ABORTED_BY_CALLBACK;
|
if(Curl_pgrsUpdate(data))
|
||||||
|
return CURLE_ABORTED_BY_CALLBACK;
|
||||||
|
|
||||||
result = Curl_speedcheck(data, now);
|
result = Curl_speedcheck(data, now);
|
||||||
if(result)
|
if(result)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
left = Curl_timeleft(data, NULL, duringconnect);
|
left = Curl_timeleft(data, NULL, FALSE);
|
||||||
if(left < 0) {
|
if(left < 0) {
|
||||||
failf(data, "Operation timed out");
|
failf(data, "Operation timed out");
|
||||||
return CURLE_OPERATION_TIMEDOUT;
|
return CURLE_OPERATION_TIMEDOUT;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(block) {
|
if(block) {
|
||||||
|
@ -3278,10 +3280,8 @@ static CURLcode scp_disconnect(struct Curl_easy *data,
|
||||||
|
|
||||||
if(sshc->ssh_session) {
|
if(sshc->ssh_session) {
|
||||||
/* only if there's a session still around to use! */
|
/* only if there's a session still around to use! */
|
||||||
|
|
||||||
state(data, SSH_SESSION_DISCONNECT);
|
state(data, SSH_SESSION_DISCONNECT);
|
||||||
|
result = ssh_block_statemach(data, conn, TRUE);
|
||||||
result = ssh_block_statemach(data, conn, FALSE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
@ -3295,10 +3295,9 @@ static CURLcode ssh_done(struct Curl_easy *data, CURLcode status)
|
||||||
struct SSHPROTO *sshp = data->req.p.ssh;
|
struct SSHPROTO *sshp = data->req.p.ssh;
|
||||||
struct connectdata *conn = data->conn;
|
struct connectdata *conn = data->conn;
|
||||||
|
|
||||||
if(!status) {
|
if(!status)
|
||||||
/* run the state-machine */
|
/* run the state-machine */
|
||||||
result = ssh_block_statemach(data, conn, FALSE);
|
result = ssh_block_statemach(data, conn, FALSE);
|
||||||
}
|
|
||||||
else
|
else
|
||||||
result = status;
|
result = status;
|
||||||
|
|
||||||
|
@ -3438,7 +3437,7 @@ static CURLcode sftp_disconnect(struct Curl_easy *data,
|
||||||
if(sshc->ssh_session) {
|
if(sshc->ssh_session) {
|
||||||
/* only if there's a session still around to use! */
|
/* only if there's a session still around to use! */
|
||||||
state(data, SSH_SFTP_SHUTDOWN);
|
state(data, SSH_SFTP_SHUTDOWN);
|
||||||
result = ssh_block_statemach(data, conn, FALSE);
|
result = ssh_block_statemach(data, conn, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUGF(infof(data, "SSH DISCONNECT is done\n"));
|
DEBUGF(infof(data, "SSH DISCONNECT is done\n"));
|
||||||
|
|
Loading…
Reference in New Issue