sharing experiences with nonblocking exec and NVAL from libssh2_channel_wait_closed() with community
I have a state machine which does the following:
In the case thet libssh2_channel_wait_closed() returns
LIBSSH2_ERROR_INVAL, the code goes back to the READ state and schedules
more reads until WAIT_CLOSED returns 0. This will cause the
wait_closed() operation to finally return 0 (rather then -34 or -37).
The reason for the enter back into the read state is that
libssh2_channel_wait_closed() checks for eof, and even though the code
has already checked and passed the EOF state, further packets appear to
be sent on the channel. This causes the internal code to mask the EOF
state which can only be corrected by reading packets.
This seems like some kind of odd race condition to me, but fwiw I hope
others find this state machine helpful if implementing nonblocking ssh
connecting software of their own:
Received on 2012-02-25