client :windows 7,32bit,vs 2005,libssh2 server: Red Hat Enterprise Linux AS release 4,Linux version 2.6.9-55,OpenSSH_3.9p1, OpenSSL 0.9.7a Feb 19 2003
Test code (off track, otherwise, the problem does not occur so easily): Buffer length should be long enough. //libssh2_trace(session, LIBSSH2_TRACE_ERROR); const int mem_len = 500 * 2000; char *mem = new char[mem_len]; do { while ((rc = libssh2_sftp_read(sftp_handle, mem, mem_len)) == LIBSSH2_ERROR_EAGAIN) { waitsocket(sock, session); } if (rc >= 0) { total += rc; fwrite(mem, rc, 1, local); } else { break; } } while (rc > 0); The function sftp_read() have the following code: if((buffer_size*4) > already) count = (buffer_size*4) - already; So, in fact the size of the request will be: 4 * 500 * 2000 = 2000 * 2000 The nodes number in handle->packet_list will be:2000 * 2000 / 2000 = 2000 Each request size of node is 292 bits in my test,totally 2000 * 292 / 1024 = 570K to be sent which is much bigger than the socket send buffer 8K,so blocking is normal while sending. the receive window adjust packet will send failed with error code LIBSSH2_ERROR_BAD_USE because of the previous blocking,transport.c:599: if ((data != p->odata) || (data_len != p->olen)) { return LIBSSH2_ERROR_BAD_USE; } if the blocking is continued until the remote.window_size reduce to 0 , then no incoming data anymore because channel.c:1853 if (!bytes_read) { return .. } will return anyway,there is no chance to expand the receive window. Hope someone can understand what I mean for my english is pool.
_______________________________________________ libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel