Ticket #86 (closed defect)

Opened 8 years ago

Last modified 8 years ago

libssh2_poll returns 0 sometimes when using select

Reported by: vtcool Owned by: bagder
Priority: low Milestone:
Component: API Version:
Keywords: Cc: vtcool, bagder
Blocked By: Blocks:


I have encountered an issue where if polling a exec channel for a command like "netstat -a" with libssh2_poll that in some command execution runs, the libssh2_poll will always return 0 and will never change on subsequent polls of the same function on Windows 2003 server.

I have structured my reads to do something like the following:

1) Execute command
2) Read channel first
3) Check if libssh2_poll for availability of data on the channel. If the rc is 0, loop until we get something greater than 0.
4) Continue to read from step 1.

However, in the particular cases where the code execution doesn't successfully return, I get a rc > 0 until a 0 is hit and then it remains 0. I have narrowed it down to the socket select() function on Windows 2003, but am unable to understand why there would be no data available when there is really data available. To me it would seem select() is behaving incorrectly.

Change History

comment:1 Changed 8 years ago by anonymous

You're not the first to observe that Windows and select() are not the best of friends.

Peter <peter@…>

comment:2 Changed 8 years ago by bagder

comment:3 Changed 8 years ago by vtcool

Not quite, but mine is pretty much the opposite. I know there is data on the channel, but unfortunately the select function internal to the libssh2_poll function returns nothing is there from time to time. The only way that I figured I could workaround this problem is to involve a retry count of subsequent no interesting events available and kick out and try to read from the channel again anyways.

comment:4 Changed 8 years ago by bagder

I'm now advocating we deprecate libssh2_poll() completely.

Is there any reason why you don't just use poll() or select() on the socket libssh2 operates on?

Note: See TracTickets for help on using tickets.