_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
This commit is contained in:
Daniel Stenberg 2010-12-11 22:43:22 +01:00
parent 6875285b71
commit 811cce09b5

View File

@ -2304,10 +2304,10 @@ 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) {
/* set the local close state first when we're perfectly confirmed to not