Subject: Re: [libssh2] R: Transferring large files with SCP fails

Re: [libssh2] R: Transferring large files with SCP fails

From: Gavrie Philipson <gavrie_at_gmail.com>
Date: Thu, 8 Nov 2007 11:55:18 +0000 (UTC)

Daniel Stenberg <daniel@...> writes:

...
> Anyway, since these changes didn't fix the problem you see we should rather
> dive in and start debugging your case I guess. I'm a bit limited on time
> myself why I haven't made much sound about this issue so far. My time limit
> makes me focus on my core projects and unfortunately this makes me less active
> in libssh2.
>
> So, get your hard hat on and dive in!

I've done just that, and think I've solved the problem.

The problem is that in nonblocking mode, the TCP window size adjustments from
the other size are sometimes not received, causing the local window size to
remain at zero.

In libssh2/src/channel.c, in the function libssh2_channel_write_ex, the
following lines appear:

        if (!channel->session->socket_block &&
            (channel->local.window_size <= 0)) {
            /* Can't write anything */
            return 0;
        }

The logic behind this is that in nonblocking mode, if the local window size has
shrunk to zero, there's no point in trying to send anything more. However,
exiting the function at that point does not allow any adjusts from the remote
side to be received, since libssh2_packet_read (that is called further on in
this function) is never called in this case.

Removing this bit of code fixes the problem. This should not cause busy waiting,
since after the libssh2_packet_read, the function correctly returns
PACKET_EAGAIN if the window size was not adjusted.

Incidentally, the reason this happened at 192k was that the initial remote
window size was 128k and when it approached (but not reached) zero, an update of
64k was received from the remote side. However, when window size got to zero
exactly, no more updates could be received and the sender hung.

PS: I wanted to attach the patch here, but gmane won't let me since it has lines
longer than 80 chars. However, the description above should be enough.

-- Gavrie

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
libssh2-devel mailing list
libssh2-devel_at_lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libssh2-devel
Received on 2007-11-08