From c672b837f83a77742db503ae40596278412d35d3 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 12 Feb 2009 11:46:28 +0000 Subject: [PATCH] - (Feb 12 2009) Romain Bondue extended Markus Moeller fix from Feb 8, based on a previous (uncommitted) patch by Erik Brossler. It improves libssh2_channel_write_ex in blocking situations when the socket is set non- blocking. --- NEWS | 10 +++++++--- src/channel.c | 4 +++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/NEWS b/NEWS index 341a22de..f5b3abeb 100644 --- a/NEWS +++ b/NEWS @@ -1,7 +1,11 @@ -- (Deb 8 2009) - Markus Moeller fixed a flaw in libssh2_channel_write_ex() that would occur - on EAGAIN situations. +- (Feb 12 2009) Romain Bondue extended Markus Moeller fix from Feb 8, based on + a previous (uncommitted) patch by Erik Brossler. It improves + libssh2_channel_write_ex in blocking situations when the socket is set non- + blocking. + +- (Feb 8 2009) Markus Moeller fixed a flaw in libssh2_channel_write_ex() that + would occur on EAGAIN situations. Version 1.0 ( ) ------------------------------- diff --git a/src/channel.c b/src/channel.c index 0c7c5e2c..7e1ab070 100644 --- a/src/channel.c +++ b/src/channel.c @@ -1771,8 +1771,9 @@ libssh2_channel_write_ex(LIBSSH2_CHANNEL * channel, int stream_id, channel->write_state = libssh2_NB_state_allocated; } - /* deduct the amount thet has already been sent */ + /* Deduct the amount that has already been sent, and set buf accordingly. */ buflen -= channel->write_bufwrote; + buf += channel->write_bufwrote; while (buflen > 0) { if (channel->write_state == libssh2_NB_state_allocated) { @@ -1798,6 +1799,7 @@ libssh2_channel_write_ex(LIBSSH2_CHANNEL * channel, int stream_id, if (rc < 0) { /* Error or EAGAIN occurred, disconnect? */ if (rc != PACKET_EAGAIN) { + LIBSSH2_FREE(session, channel->write_packet); channel->write_state = libssh2_NB_state_idle; } return rc;