Subject: Re: libssh2_sftp_write now hangs eventually

Re: libssh2_sftp_write now hangs eventually

From: Daniel Stenberg <>
Date: Wed, 10 Nov 2010 23:34:23 +0100 (CET)

On Wed, 10 Nov 2010, Mark Riordan wrote:

>>> Please pull these two commits and see what happens!
> Alas, it still hangs the same way.

Ok, so my latest analysis wasn't correct then! :-(

The fact that the log ends with two lines saying "Would block sftp_write"
should still be some kind of clue I think.

Perhaps you can add some debug output next to where that is returned and
output the value of the 'eagain' variable there. I'm curious what the value is
for the last output.

> I did a Wireshark trace and noticed a very large number of full-sized
> outbound packets before it hung, even though the program thought it had sent
> only 12000 bytes before it hung. Of course, the SSH Wireshark trace is
> encrypted, and unlike with SSL, there's no Wireshark plug-in to decrypt it.
> So I looked a bit further by running mitm-ssh (Man in the Middle SSH), which
> decrypts the SSH stream. It turned out the Windows client was sending the
> same data over and over.

I'm puzzled and I have no explanation for that right now. I can only think
that something in the sftp_write() function isn't handling the 'chunks'
properly so that it somehow believes it should send the same chunk again even
though it was already sent.

I've read through the code a few more times and it made me clean it up
somewhat more and do some minor fixes but I don't think any of those are
reason for what you experience.

I can't understand how the code would resend a block. Anyone else?

Received on 2010-11-10