Subject: [libssh2] #185: libssh2_sftp_write still returns wrong value

[libssh2] #185: libssh2_sftp_write still returns wrong value

From: libssh2 Trac <trac_at_libssh2.stuge.se>
Date: Wed, 08 Sep 2010 17:46:15 -0000

#185: libssh2_sftp_write still returns wrong value
--------------------+-------------------------------------------------------
 Reporter: mstrsn | Owner:
     Type: defect | Status: new
 Priority: normal | Milestone: 1.2.7
Component: SFTP | Version: 1.2.7
 Keywords: | Blocks:
Blocked By: |
--------------------+-------------------------------------------------------
 This is related to bug #158 which I submitted against 1.2.4 back in April.
 I believe the changes made to close that bug were insufficient. When
 _libssh2_channel_write() fails because there is no room in local storage
 (i.e. channel->local.window_size is 0), I believe it should be treated as
 a blocking situation and _libssh2_channel_write should return
 LIBSSH2_ERROR_EAGAIN. Currently, it returns 0 which libssh2_sftp_write
 interprets as an error. This patch fixes the problem for my SFTP client
 application:

 %diff -u channel.c.orig channel.c
 --- channel.c.orig Wed Sep 8 13:30:57 2010
 +++ channel.c Wed Sep 8 13:24:20 2010
 @@ -1958,6 +1958,7 @@
      /* Deduct the amount that has already been sent, and set buf
 accordingly. */
      buflen -= channel->write_bufwrote;
      buf += channel->write_bufwrote;
 + wrote = channel->write_bufwrote;

      while (buflen > 0) {
          if (channel->write_state == libssh2_NB_state_allocated) {
 @@ -1969,7 +1970,8 @@

              if(channel->local.window_size <= 0) {
                  /* there's no more room for data so we stop sending now
 */
 - break;
 + /* and tell the caller to try again later */
 + return LIBSSH2_ERROR_EAGAIN;
              }

              channel->write_bufwrite = buflen;

-- 
Ticket URL: <http://trac.libssh2.org/ticket/185>
libssh2 <http://trac.libssh2.org/>
C library for writing portable SSH2 clients
_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
Received on 2010-09-08