cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: curl sftp shutdown error with MessageWay server

From: Matt Wixson <mwixson_at_ceclabs.com>
Date: Thu, 1 Apr 2010 14:02:43 -0400

I believe I have isolated the problem and have a fix. After applying the
following code change to remove || (nread == 0), file downloads from
MessageWay and OpenSSH work fine without hanging:

curl-7.20.0: sendf.c, line 551

#ifdef LIBSSH2CHANNEL_EAGAIN
if 0
    /* OLD CODE retries on a 0 byte read (EOF) */
    if((nread == LIBSSH2CHANNEL_EAGAIN) || (nread == 0))
#else
   /* NEW CODE only retries on EAGAIN */
    if((nread == LIBSSH2CHANNEL_EAGAIN))
#endif
      /* EWOULDBLOCK */
      return -1;
#endif

I would appreciate independent validation. Is this correct or am I missing
something?

Thanks,
Matt

On Thu, Apr 1, 2010 at 7:55 AM, Matt Wixson <mwixson_at_ceclabs.com> wrote:

> Please see my responses below >>
>
> On Fri, Mar 26, 2010 at 9:10 AM, Daniel Stenberg <daniel_at_haxx.se> wrote:
>
>> On Fri, 26 Mar 2010, Matt Wixson wrote:
>>
>> As suggested in the libssh2 group, I ran libssh2's sftp.c example. The
>>> libssh2 example works consistently with the MessageWay server, I can
>>> download any file without issue. Curl and libcurl, however, consistently
>>> hang after receiving the data and immediately before the message "SSH
>>> DISCONNECT starts now".
>>>
>>
>> That of course hints that this is indeed a libcurl-problem.
>>
>>
>> It appears there several differences between the sftp.c example and
>>> libcurl, such as blocking vs non-blocking.
>>>
>>
>> You could try the non-blocking libssh2 example just to verify that it too
>> is working.
>
>
> >> sftp_nonblock also worked fine.
>
>>
>>
>> I tried enabling blocking in libcurl
>>>
>>
>> That's not really a sensible way forward anyway, not even as a
>> work-around.
>
>
> >> acknowledged
>
>>
>>
>> Please let me know if there is anything else I can try...this seems to be
>>> an issue in libcurl with MessageWay.
>>>
>>
>> You should stop trying to find a work-around and instead try to help us
>> debug the case. Extract information about what happened immediately before
>> the hang and please research exactly what the hang is and why and what
>> libcurl does when it hangs.
>>
>> Does it only do this against this particular server or have to experienced
>> it on other servers?
>
>
> >> I only have access to one MessageWay server, but curl sftp (as we know)
> works fine with non-MessageWay servers (such as openssh).
>
> >> Running in debug mode a Ctrl-C'd when the process hangs. Here is a
> stack trace gdb using curl-7.20.0:
> #0 0x005dc7a2 in _dl_sysinfo_int80 () from /lib/ld-linux.so.2
> #1 0x006b4dbd in poll () from /lib/tls/libc.so.6
> #2 0x0059ac3d in Curl_socket_ready (readfd=6, writefd=-1, timeout_ms=1000)
> at select.c:218
> #3 0x0058dd48 in Transfer (conn=0x9c82dec) at transfer.c:1272
> #4 0x0058ea90 in Curl_perform (data=0x9c796ec) at transfer.c:1966
> #5 0x0058f467 in curl_easy_perform (curl=0x9c796ec) at easy.c:557
> #6 0x08051f08 in operate (config=0xbff80280, argc=4, argv=0xbff80514) at
> main.c:5177
> #7 0x080527cd in main (argc=4, argv=0xbff80514) at main.c:5502
>
> >> I will continue researching this but any advice is welcome!
>
> Thanks,
> Matt
>
>
>>
>> --
>>
>> / daniel.haxx.se
>> -------------------------------------------------------------------
>> List admin: http://cool.haxx.se/list/listinfo/curl-library
>> Etiquette: http://curl.haxx.se/mail/etiquette.html
>>
>
>

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2010-04-01