Subject: sftp_read problems with large buffer

sftp_read problems with large buffer

From: Alexander Lamaison <>
Date: Tue, 4 Aug 2009 15:47:14 +0100

It appears that the latest libssh2 code has a problem reading from
SFTP with a large buffer (in blocking mode). On Windows the
libssh2_sftp_read call fails with a "Timeout waiting for status
message" error when the buffer size goes above about 1500 bytes (YMMV)
though this is not consistent between calls. On linux, the call just
hangs at about 2500 bytes (YMMV, again) on a call to select():

select(4, [3], NULL, NULL, NULL) = 1 (in [3])
recv(3, "\342\261\354\263\243\250i@\367\375\372ylHm\36\364\300\216J\316\1\241@>\252r\227\10\335\270\372\22"...,
16384, MSG_NOSIGNAL) = 1408
select(4, NULL, NULL, NULL, NULL

Attached is the little test program I'm using. Invoke it like this:
      ./libssh2_bigread username password reasonably_large_file
I can only reproduce the symptoms if the target file is on a *remote*
machine although, it may happen when connecting to localhost of your
machine is slow enough.

I was hoping to track down the cause a little better but haven't had
the time. All I know is it occurred somewhere between commit
6409bb53ba2fd937260caf1cb2cdbf40d782180c (post RELEASE 1.1), which
works, and the current master HEAD, which doesn't. I'll try and pin
this down a little more later.

Are any changes likely candidates for having caused this?



Received on 2009-08-04