From 8b63dc9e59c676991ce62316d203849bc56e2a6c Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 14 Apr 2010 23:34:06 +0200 Subject: [PATCH] channel_write: if data has been sent, don't return EAGAIN When sending data in a loop, we must not return EAGAIN if we managed to send data in an earlier round. This was reported in bug #126 => http://libssh2.stuge.se/ticket/126 --- src/channel.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/channel.c b/src/channel.c index 2866402..7cabf27 100644 --- a/src/channel.c +++ b/src/channel.c @@ -2038,6 +2038,11 @@ _libssh2_channel_write(LIBSSH2_CHANNEL *channel, int stream_id, channel->write_s - channel->write_packet); if (rc == PACKET_EAGAIN) { + if(wrote) + /* some pieces of data was sent before the EAGAIN so + we return that amount! */ + goto _channel_write_done; + return libssh2_error(session, rc, "Unable to send channel data"); } @@ -2061,6 +2066,8 @@ _libssh2_channel_write(LIBSSH2_CHANNEL *channel, int stream_id, } } + _channel_write_done: + LIBSSH2_FREE(session, channel->write_packet); channel->write_packet = NULL;