From 74f4b7817b83eee9873aedb9ed1c256405d53f36 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 31 Mar 2009 08:52:25 +0000 Subject: [PATCH] Uh, it is important that we don't set the local state 'local.close' to TRUE until _after_ we're done as otherwise we might not get called again properly to clean the entire thing since the close state is checked in libssh2_channel_free --- src/channel.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/channel.c b/src/channel.c index d9a54d6..ef5da4c 100644 --- a/src/channel.c +++ b/src/channel.c @@ -2305,8 +2305,6 @@ channel_close(LIBSSH2_CHANNEL * channel) _libssh2_debug(session, LIBSSH2_DBG_CONN, "Closing channel %lu/%lu", channel->local.id, channel->remote.id); - channel->local.close = 1; - channel->close_packet[0] = SSH_MSG_CHANNEL_CLOSE; _libssh2_htonu32(channel->close_packet + 1, channel->remote.id); @@ -2342,6 +2340,10 @@ channel_close(LIBSSH2_CHANNEL * channel) } } + /* set the local close state first when we're perfectly confirmed to not + do any more EAGAINs */ + channel->local.close = 1; + /* We call the callback last in this function to make it keep the local data as long as EAGAIN is returned. */ if (channel->close_cb) {