Subject: Re: [libssh2] #214: sftp_write hangs following an error

Re: [libssh2] #214: sftp_write hangs following an error

From: libssh2 Trac <>
Date: Tue, 12 Apr 2011 21:45:28 -0000

#214: sftp_write hangs following an error
  Reporter: mts | Owner: bagder
      Type: defect | Status: assigned
  Priority: normal | Milestone: 1.2.9
 Component: SFTP | Version: 1.2.8
Resolution: | Keywords: sftp write hang
    Blocks: | Blocked By:
Changes (by bagder):

  * owner: => bagder
  * status: new => assigned


 Ok, a question and some comments around what we see in the trace:

 We see that we get a 101 (hex 65) response back from the server when
 FXP_WRITE was sent. The following log snippet shows this:

 [libssh2] 6.738287 SFTP: Received packet 101 (len 24)
 [libssh2] 6.738287 SFTP: Got 101
 [libssh2] 6.738287 Failure Event: -31 - FXP write failed

 Ok, and the last line there is a call to _libssh2_error() and a return out
 from sftp_write() with LIBSSH2_ERROR_SFTP_PROTOCOL as error.

 when sftp_write() returns, it goes back to the libssh2_sftp_write()
 function where there's a macro that checks if it should hang around and
 wait for more data or not. This macro would not match the
 LIBSSH2_ERROR_SFTP_PROTOCOL return code but should return immediately.

 However, the next trace log shows:

 [libssh2] 50.989703 SFTP: Requiring packet 101 id 80

 Is that a new call to libssh2_sftp_write() after the previous one failed?
 I think so, and it would be great to get this confirmed to properly
 understand what's going on.

Ticket URL: <>
libssh2 <>
C library for writing portable SSH2 clients
Received on 2011-04-12