From 811cce09b5c885a40b6b3ee6cf4a1562322f4b2d Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Sat, 11 Dec 2010 22:43:22 +0100 Subject: [PATCH] _libssh2_channel_close: don't call transport read if disconnected The loop that waits for remote.close to get set may end up looping forever since session->socket_state gets set to LIBSSH2_SOCKET_DISCONNECTED by the packet_add() function called from the transport_read() function and after having been set to LIBSSH2_SOCKET_DISCONNECTED, the transport_read() function will only return 0. Bug: http://trac.libssh2.org/ticket/198 --- src/channel.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/channel.c b/src/channel.c index ff1fb4df..efe95e6e 100644 --- a/src/channel.c +++ b/src/channel.c @@ -2304,9 +2304,9 @@ int _libssh2_channel_close(LIBSSH2_CHANNEL * channel) if (channel->close_state == libssh2_NB_state_sent) { /* We must wait for the remote SSH_MSG_CHANNEL_CLOSE message */ - while (!channel->remote.close && !rc) { + while (!channel->remote.close && !rc && + (session->socket_state != LIBSSH2_SOCKET_DISCONNECTED)) rc = _libssh2_transport_read(session); - } } if(rc != LIBSSH2_ERROR_EAGAIN) {