On Thu, 11 Aug 2011, Henrik Nordström wrote:

_libssh2_channel_write() clearly do return 0 immedately if the window
have collapsed after draining the incoming transport.

       if(channel->local.window_size <= 0)
           /* there's no room for data so we stop */
           return 0;


I guess it should
a) Block if not non-blocking.
b) Return EAGAIN if non-blocking and indicate it needs to read from the
transport (wait for window update)

I agree.

As it calls _libssh2_transport_read() just before that, I'm thinking that perhaps we should just make a patch like below. It would work because _libssh2_transport_read() itself stores the correct bits that the app should wait for after EAGAIN is returned.

diff --git a/src/channel.c b/src/channel.c
index efb2b48..be6a680 100644
--- a/src/channel.c
+++ b/src/channel.c
@@ -2022,7 +2022,7 @@ _libssh2_channel_write(LIBSSH2_CHANNEL *channel, int strea

         if(channel->local.window_size <= 0)
             /* there's no room for data so we stop */
-            return 0;
+            return (rc==LIBSSH2_ERROR_EAGAIN?rc:0);

         channel->write_bufwrite = buflen;


--

 / daniel.haxx.se
_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel

Reply via email to