From c4b7f0394b2603402b7cfab0691d9b74e58b3b8c Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 16 Sep 2009 13:49:04 +0200 Subject: [PATCH] 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. --- src/channel.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/channel.c b/src/channel.c index 71583a0..d584bac 100644 --- a/src/channel.c +++ b/src/channel.c @@ -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;