cURL / Mailing Lists / curl-users / Single Mail

curl-users

Re: Bug in sftp timeout detection.

From: Skrzyniarz Alexandre <alexandre.skrzyniarz_at_fr.thalesgroup.com>
Date: Wed, 5 Jan 2011 09:43:32 +0100

On Thu, 4 Nov 2010 16:39:05 +0100
Skrzyniarz Alexandre <alexandre.skrzyniarz_at_fr.thalesgroup.com> wrote:

> On Thu, 4 Nov 2010 14:23:38 +0100 (CET)
> Daniel Stenberg <daniel_at_haxx.se> wrote:
>
> > On Thu, 4 Nov 2010, Skrzyniarz Alexandre wrote:
> >
> > > Timeout setting with -Y and -y options doesn't work with sftp
> > > protocol.
> >
> > > curl -y 10 -Y 1 --connect-timeout 10 -o /dest/file -m 1200 -u
> > > user:password sftp://server//from//file.txt
> >
> > How curious. Does the progress meter still continue to update itself
> > during this time?
> >
>
> Yes. The displayed download speed falls to zero, but the download
> isn't aborted.
>

I had some time to track this issue: the download is not aborted
because there is an infinite loop in ssh_easy_statematch when ssh
connection state is SSH_SFTP_SHUTDOWN.

By the way, there is a similar problem with ssh
(infinite loop with state SSH_SESSION_HANDLED).

And for the progress meter: It updates itself with SFTP, but is stuck
with SSH after authentication.

This simple patch fixes the timeout (I guess there is a more graceful
way to handle disconnections):

diff --git a/lib/ssh.c b/lib/ssh.c
index a0ca4c5..9e10317 100644
--- a/lib/ssh.c
+++ b/lib/ssh.c
@@ -2458,7 +2458,7 @@ static CURLcode ssh_easy_statemach(struct
connectdata *conn, return CURLE_ABORTED_BY_CALLBACK;
 
     left = Curl_timeleft(conn, NULL, duringconnect);
- if(left < 0) {
+ if((left < 0) || (sshc->state == SSH_SESSION_DISCONNECT) ||
(sshc->state == SSH_SFTP_SHUTDOWN)){ failf(data, "Operation timed
out\n"); return CURLE_OPERATION_TIMEDOUT;
     }

-- 
Alexandre SKRZYNIARZ, PhD.
[EXPERTS] Domain Design Authority, Radar & Warfare Systems.
THALES AIRBORNE SYSTEMS
10 Av 1ere DFL, 29200 BREST, France
email: alexandre.skrzyniarz_at_fr.thalesgroup.com
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-users
FAQ:        http://curl.haxx.se/docs/faq.html
Etiquette:  http://curl.haxx.se/mail/etiquette.html
Received on 2011-01-05