Subject: Antw: Re: Select (function _libssh2_wait_socket) issue on some on an embedded platform

Antw: Re: Select (function _libssh2_wait_socket) issue on some on an embedded platform

From: Sebastien Fricker <>
Date: Fri, 26 Mar 2010 14:29:38 +0100

On RTOS select always return 0 if readfd and writefd are pointing to
the same variable.

if you have a look on the prototype of the select function you can see
that the df_set pointer are not const pointers:

int select(int nfds, fd_set *readfds, fd_set *writefds,
                  fd_set *exceptfds, struct timeval *timeout);

This mean that select can modify the contain of readfd and writefd. In
the manual of select on Linux, I also found:
" On exit, the sets are modified in place to indicate which file
descriptors actually changed status. "

I guess that this is the problem: &fd is modified twice, and this could
be a problem on some OS.

>>> Daniel Stenberg <> schrieb am 26.03.2010 um 14:13 in
> On Fri, 26 Mar 2010, Sebastien Fricker wrote:
>> If readfd and writefd are pointing to 2 different variables, select
>> well.
> ...
>> The modification should not create any regression to libssh2, and if
>> are seeing any problem about this code, I will provide a patch.
> I wouldn't mind that minor work-around to make it run better. But
please, add
> an explanatory comment about the reason for this weirdness, as
> someone will just optimize it away again in the future...
Received on 2010-03-26