Hi Daniel,

On Tue August 18 2009 17:55:04 Daniel Stenberg wrote:
> On Tue, 18 Aug 2009, Vourhey wrote:
> > I use static linking to the libssh2. Old libssh2 can not cause any
> > issues.
>
> Yes it could, if it would base the configure tests on an older version. But
> Kamil said he can repeat it too so I think we can rule out the "old lib
> used for test" as a probable cause.

I don't think it's a libssh2 bug. I've debugged it for a while and it seems 
libssh2 is returning correct transfer direction info. However curl is not 
willing to use the value.

libcurl saves the direction properly to conn->proto.sshc.waitfor, but the 
variable is not accessed during transfer at all. The common layer (transfer.c) 
then expects an outgoing transfer during upload while libssh2 is waiting for 
ACK (incoming transfer).

The attached patch fixes the problem, but I am not going to apply it as it's 
more likely a workaround than a fix. I think it should be somehow rewritten
to pass the direction info to functions from transfer.c to perform the poll. 
Or am I completely wrong?

Note that it doesn't loop with SCP upload, but only with SFTP upload for me.

Kamil

Index: lib/ssh.c
===================================================================
RCS file: /cvsroot/curl/curl/lib/ssh.c,v
retrieving revision 1.136
diff -u -p -r1.136 ssh.c
--- lib/ssh.c	23 Jul 2009 02:15:00 -0000	1.136
+++ lib/ssh.c	20 Aug 2009 13:39:10 -0000
@@ -2753,8 +2753,13 @@ ssize_t Curl_sftp_send(struct connectdat
 
   ssh_block2waitfor(conn, (nwrite == LIBSSH2_ERROR_EAGAIN)?TRUE:FALSE);
 
-  if(nwrite == LIBSSH2_ERROR_EAGAIN)
+  if(nwrite == LIBSSH2_ERROR_EAGAIN) {
+    if (conn->proto.sshc.waitfor & KEEP_RECV)
+      /* wait for the socket to become ready */
+      Curl_socket_ready(conn->sock[FIRSTSOCKET], CURL_SOCKET_BAD, 1000);
+
     return 0;
+  }
 
   return nwrite;
 }

Reply via email to