> -----Original Message-----
> From: [email protected] 
> [mailto:[email protected]] On Behalf Of 
> Daniel Stenberg
> Sent: Monday, May 03, 2010 8:04 PM
> To: libcurl development
> Subject: RE: Reflection for Secure IT Server
> 
> On Mon, 3 May 2010, Xu, Qiang (FXSGSC) wrote:
> 
> > Just tried the latest curl snapshot, with the same result:
> 
> > The file sitting in the remote folder is still 16KB, while 
> the local 
> > file's size is 512KB. :-(
> 
> Are those 16KB the first 16KB of the source file or are they 
> broken somehow?
> 
> I would think you need to instrument how lissh2_sftp_write() 
> that libcurl uses acts, and what libcurl then does after the 
> working ones etc. Possibly in combination with enabling 
> libssh2 debug tracing.

Coz I've had no luck with "libssh2_trace(sshc->sftp_session, ~0)" so far, some 
other method has been tried:
=====================================================
/* code in curl-7.20.1/src/ssh.c */
ssize_t Curl_sftp_send(struct connectdata *conn, int sockindex,
                       const void *mem, size_t len)
{
  ssize_t nwrite;   /* libssh2_sftp_write() used to return size_t in 0.14
                       but is changed to ssize_t in 0.15. These days we don't
                       support libssh2 0.15*/
  (void)sockindex;

  nwrite = libssh2_sftp_write(conn->proto.sshc.sftp_handle, mem, len);

//xq.0
  if (nwrite == LIBSSH2_ERROR_EAGAIN)
        infof(conn->data, "libssh2_sftp_write() returns 
LIBSSH2_ERROR_EAGAIN\n");
  else
        infof(conn->data, "libssh2_sftp_write() writes [%d] bytes\n", nwrite);
//xq.1

  ssh_block2waitfor(conn, (nwrite == LIBSSH2_ERROR_EAGAIN)?TRUE:FALSE);

  if(nwrite == LIBSSH2_ERROR_EAGAIN)
    return 0;

  return nwrite;
}



/* log for transfer success */
q...@durian(pts/1):~/opensrc/curl-7.20.1/src[253]$ ./curl -v -k -u 
<user>:<pass> -T testSmall.pdf sftp://13.121.8.133/Home/Scans/
* About to connect() to 13.198.98.190 port 22 (#0)
*   Trying 13.198.98.190...   % Total    % Received % Xferd  Average Speed   
Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     
0connected
* Connected to 13.198.98.190 (13.198.98.190) port 22 (#0)
...
* Initialized password authentication
* Authentication complete
* libssh2_sftp_write() returns LIBSSH2_ERROR_EAGAIN
} [data not shown]
* libssh2_sftp_write() writes [16384] bytes
} [data not shown]
...
* libssh2_sftp_write() returns LIBSSH2_ERROR_EAGAIN
} [data not shown]
* libssh2_sftp_write() writes [16384] bytes
} [data not shown]
* libssh2_sftp_write() returns LIBSSH2_ERROR_EAGAIN
} [data not shown]
* libssh2_sftp_write() writes [15436] bytes
} [data not shown]
100  511k    0     0  100  511k      0  1111k --:--:-- --:--:-- --:--:-- 
1115k100  511k    0     0  100  511k      0  1111k --:--:-- --:--:-- --:--:-- 
1111k* 
Connection #0 to host 13.198.98.190 left intact

* Closing connection #0



/* log for transfer failure */
q...@durian(pts/1):~/opensrc/curl-7.20.1/src[254]$ ./curl -v -k -u 
<user>:<pass> -T testSmall.pdf sftp://13.121.8.133/Home/Scans/
* About to connect() to 13.121.8.133 port 22 (#0)
*   Trying 13.121.8.133...   % Total    % Received % Xferd  Average Speed   Time
    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     
0connected
* Connected to 13.121.8.133 (13.121.8.133) port 22 (#0)
* SSH authentication methods available: password
* Initialized password authentication
* Authentication complete
* libssh2_sftp_write() writes [16311] bytes
} [data not shown]
  3  511k    0     0    3 16311      0   1422  0:06:08  0:00:11  0:05:57  1492  
3  511k    0     0    3 16311      0   1307  0:06:40  0:00:12  0:06:28  1367* 
libssh2_sftp_write() writes [-7] bytes
} [data not shown]
* libssh2_sftp_write() writes [-7] bytes
} [data not shown]
* libssh2_sftp_write() writes [-7] bytes
} [data not shown]
... /* this -7 bytes pattern repeated endlessly */
=====================================================
For the successful case, libssh2_sftp_write() returns LIBSSH2_ERROR_EAGAIN, 
then writes 16KB (16,384 bytes) to the server. This pattern repeats itself 
again and again, untill the whole file has been transferred to the destination. 
For the failure case, libssh2_sftp_write() firstly writes 16311 bytes to the 
server, then it just returns -7. LIBSSH2_ERROR_EAGAIN never appears, strangely.

How come libssh2_sftp_write() returns -7 rather than -37 
(LIBSSH2_ERROR_EAGAIN)? From libssh2.h, it can be seen -7 is 
LIBSSH2_ERROR_SOCKET_SEND. Is it suggesting the response from the server is not 
what we expected?

Thanks,
Xu Qiang
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html

Reply via email to