libssh2_channel_wait_closed() could hang

libssh2_channel_wait_closed() had a bad loop waiting for the
channel to close, as it could easily miss the info and then if
the socket would be silent from that moment the funtion would
hang if in blocking-mode or just return EAGAIN wrongly to the
app. The drain-transport loop now correctly checks if the close
has arrived.
This commit is contained in:
Daniel Stenberg 2009-09-16 13:49:04 +02:00
parent 9e84b999a5
commit c4b7f0394b

View File

@ -2334,6 +2334,9 @@ static int channel_wait_closed(LIBSSH2_CHANNEL *channel)
if (!channel->remote.close) {
do {
rc = _libssh2_transport_read(session);
if (channel->remote.close)
/* it is now closed, move on! */
break;
} while (rc > 0);
if(rc < 0)
return rc;