From 1e80194b9761004d80862f89c388e745adb5a318 Mon Sep 17 00:00:00 2001 From: Juzna Date: Sun, 18 Oct 2009 03:41:25 +0200 Subject: [PATCH] libssh2_channel_forward_accept() and listening fixes The forward accepting was not done right before, and the packet_queue_listener function didn't assign a necessary variable. All fixed by Juzna. I (Daniel) modified the forward_accept() change somewhat. --- src/channel.c | 14 +++++++------- src/packet.c | 2 ++ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/channel.c b/src/channel.c index 0a840da..06e0e77 100644 --- a/src/channel.c +++ b/src/channel.c @@ -725,11 +725,6 @@ channel_forward_accept(LIBSSH2_LISTENER *listener) do { rc = _libssh2_transport_read(listener->session); - if (rc == PACKET_EAGAIN) { - libssh2_error(listener->session, LIBSSH2_ERROR_EAGAIN, - "Would block waiting for packet", 0); - return NULL; - } } while (rc > 0); if (_libssh2_list_first(&listener->queue)) { @@ -746,8 +741,13 @@ channel_forward_accept(LIBSSH2_LISTENER *listener) return channel; } - libssh2_error(listener->session, LIBSSH2_ERROR_CHANNEL_UNKNOWN, - "Channel not found", 0); + if (rc == PACKET_EAGAIN) { + libssh2_error(listener->session, LIBSSH2_ERROR_EAGAIN, + "Would block waiting for packet", 0); + } + else + libssh2_error(listener->session, LIBSSH2_ERROR_CHANNEL_UNKNOWN, + "Channel not found", 0); return NULL; } diff --git a/src/packet.c b/src/packet.c index 0e50e2b..d16209c 100644 --- a/src/packet.c +++ b/src/packet.c @@ -146,6 +146,8 @@ packet_queue_listener(LIBSSH2_SESSION * session, unsigned char *data, listen_state->state = libssh2_NB_state_sent; break; } + listen_state->channel = channel; + memset(channel, 0, sizeof(LIBSSH2_CHANNEL)); channel->session = session;