cURL / Mailing Lists / curl-library / Single Mail

curl-library

Stall when uploading to sftp using multi interface

From: Henry Ludemann <misc_at_hl.id.au>
Date: Wed, 23 Feb 2011 14:36:07 +0800

Hi,

When uploading to an sftp server using the multi interface, curl
7.21.4 hangs before it starts transferring the payload. Turning on
verbose logs shows it hangs when changing to the PERFORM state. On the
server the file has been created, but is empty. The transfer now
stalls; the function set with CURLOPT_READFUNCTION is never called.
Other protocols (eg: http / https with get / post / put requests)
work. Attempting the sftp upload using the 'simple' interface works.

I've tested with two ssh servers, 'Sun_SSH_1.1' (localhost) and
'SSH-2.0-1.03 FlowSsh: WinSSHD 5.10' (a remote server).

The verbose logs, with ssh debug logs enabled;

[2011-02-23 14:16:06] Curl timer: 1ms
[2011-02-23 14:16:09] Got a timeout
[2011-02-23 14:16:09] Curl: About to connect() to 127.0.0.1 port 10023 (#0)
[2011-02-23 14:16:09] Curl: Trying 127.0.0.1...
[2011-02-23 14:16:09] Curl: connected
[2011-02-23 14:16:09] Curl: Connected to 127.0.0.1 (127.0.0.1) port 10023 (#0)
[2011-02-23 14:16:09] Curl: User: cecilia
[2011-02-23 14:16:09] Curl: Password:
[2011-02-23 14:16:09] Curl: SSH socket: 6
[2011-02-23 14:16:09] Curl: SFTP 0x8160cbc state change from SSH_STOP
to SSH_S_STARTUP
[2011-02-23 14:16:09] Curl: SFTP 0x8160cbc state change from
SSH_S_STARTUP to SSH_HOSTKEY
[2011-02-23 14:16:09] Curl: Fingerprint:
<removed verbose fingerprint>
[2011-02-23 14:16:09] Curl: SFTP 0x8160cbc state change from
SSH_HOSTKEY to SSH_AUTHLIST
[2011-02-23 14:16:09] Curl: 0x81580b4 is at send pipe head!
[2011-02-23 14:16:09] Curl: STATE: CONNECT => WAITCONNECT handle
0x81608fc; (connection #0)
[2011-02-23 14:16:09] Curl: STATE: WAITCONNECT => PROTOCONNECT handle
0x81608fc; (connection #0)
[2011-02-23 14:16:09] Socket action: poll in (6)
[2011-02-23 14:16:09] Curl timer: 1ms
[2011-02-23 14:16:09] Got a read on socket: 6
[2011-02-23 14:16:09] Curl: SSH authentication methods available:
gssapi-keyex,gssapi-with-mic,publickey,password,keyboard-interactive
[2011-02-23 14:16:09] Curl: SFTP 0x8160cbc state change from
SSH_AUTHLIST to SSH_AUTH_PKEY_INIT
[2011-02-23 14:16:09] Curl: Using ssh public key file key.pub
[2011-02-23 14:16:09] Curl: Using ssh private key file key.prv
[2011-02-23 14:16:09] Curl: SFTP 0x8160cbc state change from
SSH_AUTH_PKEY_INIT to SSH_AUTH_PKEY
[2011-02-23 14:16:09] Curl timer: -1ms
[2011-02-23 14:16:09] Got a read on socket: 6
[2011-02-23 14:16:09] Got a read on socket: 6
[2011-02-23 14:16:09] Curl: Initialized SSH public key authentication
[2011-02-23 14:16:09] Curl: SFTP 0x8160cbc state change from
SSH_AUTH_PKEY to SSH_AUTH_DONE
[2011-02-23 14:16:09] Curl: Authentication complete
[2011-02-23 14:16:09] Curl: SFTP 0x8160cbc state change from
SSH_AUTH_DONE to SSH_SFTP_INIT
[2011-02-23 14:16:09] Got a read on socket: 6
[2011-02-23 14:16:09] Got a read on socket: 6
[2011-02-23 14:16:09] Got a read on socket: 6
[2011-02-23 14:16:09] Curl: SFTP 0x8160cbc state change from
SSH_SFTP_INIT to SSH_SFTP_REALPATH
[2011-02-23 14:16:09] Got a read on socket: 6
[2011-02-23 14:16:09] Curl: SSH CONNECT phase done
[2011-02-23 14:16:09] Curl: SFTP 0x8160cbc state change from
SSH_SFTP_REALPATH to SSH_STOP
[2011-02-23 14:16:09] Curl: STATE: PROTOCONNECT => DO handle
0x81608fc; (connection #0)
[2011-02-23 14:16:09] Curl: DO phase starts
[2011-02-23 14:16:09] Curl: SFTP 0x8160cbc state change from SSH_STOP
to SSH_SFTP_QUOTE_INIT
[2011-02-23 14:16:09] Curl: SFTP 0x8160cbc state change from
SSH_SFTP_QUOTE_INIT to SSH_SFTP_TRANS_INIT
[2011-02-23 14:16:09] Curl: SFTP 0x8160cbc state change from
SSH_SFTP_TRANS_INIT to SSH_SFTP_UPLOAD_INIT
[2011-02-23 14:16:09] Curl: STATE: DO => DOING handle 0x81608fc; (connection #0)
[2011-02-23 14:16:09] Got a read on socket: 6
[2011-02-23 14:16:09] Curl: SFTP 0x8160cbc state change from
SSH_SFTP_UPLOAD_INIT to SSH_STOP
[2011-02-23 14:16:09] Curl: DO phase is complete
[2011-02-23 14:16:09] Curl: STATE: DOING => DO_DONE handle 0x81608fc;
(connection #0)
[2011-02-23 14:16:09] Curl: STATE: DO_DONE => WAITPERFORM handle
0x81608fc; (connection #0)
[2011-02-23 14:16:09] Curl: STATE: WAITPERFORM => PERFORM handle
0x81608fc; (connection #0)
[2011-02-23 14:16:09] Socket action: poll remove (6)
<hangs here>

It hangs because curl hasn't asked for any timeouts or sockets to be
polled (note that final 'poll remove' message and the earlier 'Curl
timer: -1ms' message), but I still don't know how it got into this
state. It happens every time.

I'm going to continue to debug the issue, but if you have any
suggestions, questions (or ideally, a patch :-) ), please don't
hesitate to let me know!

Cheers,
Henry
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2011-02-23