Subject: RE: libssh2_sftp_write doesn't hang anymore

RE: libssh2_sftp_write doesn't hang anymore

From: Daniel Stenberg <>
Date: Fri, 12 Nov 2010 15:17:47 +0100 (CET)

On Thu, 11 Nov 2010, Mark Riordan wrote:

> At any rate, the same principle applies. The NoDebugSlow capture showing
> 30517591 uploaded raw bytes is still much larger than would be necessary for
> a 479988-byte file.

We need to figure out where all that data comes from. I mean which layer that
decides it needs to get sent. The fact that it doesn't ruin the file in the
server end is funny, which means all the necessary packets are at least sent.

For the purpose of debugging this, can you make _libssh2_send() increase a
global variable with the amount of data it thinks send() has sent and then
output that global variable at the end of the test? That's the raw sender,
which then should be ~15-20% larger than the file size. See my suggested patch

If that counter gets crazy big, we continue and add the similar counter to
more upper layer functions. Within channel_write and _libssh2_channel_write
and then finally within sftp_write.

--- a/src/misc.c
+++ b/src/misc.c
@@ -119,6 +119,7 @@ _libssh2_recv(libssh2_socket_t socket, void *buffer,
   * Wrapper around standard send to allow WIN32 systems
   * to set errno
+size_t filecounter;
  _libssh2_send(libssh2_socket_t socket, const void *buffer, size_t length,
                int flags)
@@ -127,6 +128,8 @@ _libssh2_send(libssh2_socket_t socket, const void *buffer,
  #ifdef WIN32
      if (rc < 0 )
          errno = wsa2errno();
+ else
+ filecounter += rc;
  #ifdef VMS
      if (rc < 0 ){

Received on 2010-11-12