Subject: Re: select timeouts after libssh2_sftp_open_ex

Re: select timeouts after libssh2_sftp_open_ex

From: Maxime Larocque <>
Date: Mon, 15 Oct 2012 08:59:06 -0400

Hi Anton,

Le 12/10/2012 23:53, Anton Obukhov a écrit :
> The code uses non-blocking API. For file sizes between 1000 and 20000
> bytes it works great. However, when data size is 30000 bytes, the
> upload happens successfully, but the following download results in a
> timeout in select after the call to libssh2_sftp_open_ex returns

I have a doubt about your usage of select (which, incidentally, is
identical to the libssh2 examples). Is it safe to call select with the
readfds and the writefds being a pointer to the same structure? The
select man page does not say anything about this, but the select_tut
always uses 2 fdsets.

 From the man page:
On success, *select*() and *pselect*() return the number of file
descriptors contained in the three returned descriptor sets (that is,
the total number of bits that are set in /readfds/, /writefds/,
/exceptfds/) which may be zero if the timeout expires before anything
interesting happens.

 From what I understand of this (it can depend on the implementation),
but if you pass the same fdset to read and write, and if one of them gets cleared (not ready),
it could effectively return 0, even if one of them is ready.

Maxime Larocque

Received on 2012-10-15