astepano / rpms / curl

Forked from rpms/curl 6 years ago
Clone
a3e77b6
diff -rup curl-7.19.6.orig/lib/ssh.c curl-7.19.6/lib/ssh.c
a3e77b6
--- curl-7.19.6.orig/lib/ssh.c	2009-07-25 00:21:50.000000000 +0200
a3e77b6
+++ curl-7.19.6/lib/ssh.c	2009-09-02 15:43:13.337644271 +0200
a3e77b6
@@ -2235,10 +2235,10 @@ static int ssh_perform_getsock(const str
a3e77b6
 
a3e77b6
   sock[0] = conn->sock[FIRSTSOCKET];
a3e77b6
 
a3e77b6
-  if(conn->proto.sshc.waitfor & KEEP_RECV)
a3e77b6
+  if(conn->waitfor & KEEP_RECV)
a3e77b6
     bitmap |= GETSOCK_READSOCK(FIRSTSOCKET);
a3e77b6
 
a3e77b6
-  if(conn->proto.sshc.waitfor & KEEP_SEND)
a3e77b6
+  if(conn->waitfor & KEEP_SEND)
a3e77b6
     bitmap |= GETSOCK_WRITESOCK(FIRSTSOCKET);
a3e77b6
 
a3e77b6
   return bitmap;
a3e77b6
@@ -2282,15 +2282,17 @@ static void ssh_block2waitfor(struct con
a3e77b6
 {
a3e77b6
   struct ssh_conn *sshc = &conn->proto.sshc;
a3e77b6
   int dir;
a3e77b6
-  if(block && (dir = libssh2_session_block_directions(sshc->ssh_session))) {
a3e77b6
+  if(!block)
a3e77b6
+    conn->waitfor = 0;
a3e77b6
+  else if((dir = libssh2_session_block_directions(sshc->ssh_session))) {
a3e77b6
     /* translate the libssh2 define bits into our own bit defines */
a3e77b6
-    sshc->waitfor = ((dir&LIBSSH2_SESSION_BLOCK_INBOUND)?KEEP_RECV:0) |
a3e77b6
+    conn->waitfor = ((dir&LIBSSH2_SESSION_BLOCK_INBOUND)?KEEP_RECV:0) |
a3e77b6
       ((dir&LIBSSH2_SESSION_BLOCK_OUTBOUND)?KEEP_SEND:0);
a3e77b6
   }
a3e77b6
   else
a3e77b6
     /* It didn't block or libssh2 didn't reveal in which direction, put back
a3e77b6
        the original set */
a3e77b6
-    sshc->waitfor = sshc->orig_waitfor;
a3e77b6
+    conn->waitfor = sshc->orig_waitfor;
a3e77b6
 }
a3e77b6
 #else
a3e77b6
   /* no libssh2 directional support so we simply don't know */
a3e77b6
diff -rup curl-7.19.6.orig/lib/transfer.c curl-7.19.6/lib/transfer.c
a3e77b6
--- curl-7.19.6.orig/lib/transfer.c	2009-07-22 22:09:53.000000000 +0200
a3e77b6
+++ curl-7.19.6/lib/transfer.c	2009-09-02 15:43:13.338644150 +0200
a3e77b6
@@ -1884,33 +1884,46 @@ Transfer(struct connectdata *conn)
a3e77b6
     return CURLE_OK;
a3e77b6
 
a3e77b6
   while(!done) {
a3e77b6
-    curl_socket_t fd_read;
a3e77b6
-    curl_socket_t fd_write;
a3e77b6
+    curl_socket_t fd_read = conn->sockfd;
a3e77b6
+    curl_socket_t fd_write = conn->writesockfd;
a3e77b6
+    int keepon = k->keepon;
a3e77b6
+
a3e77b6
+#if defined(USE_LIBSSH2)
a3e77b6
+    if(conn->protocol & (PROT_SCP|PROT_SFTP)) {
a3e77b6
+      fd_read = conn->sock[FIRSTSOCKET];
a3e77b6
+      fd_write = conn->sock[FIRSTSOCKET];
a3e77b6
+    }
a3e77b6
+#endif /* USE_LIBSSH2 */
a3e77b6
+
a3e77b6
+    if(conn->waitfor) {
a3e77b6
+      /* if waitfor is set, get the RECV and SEND bits from that but keep the
a3e77b6
+         other bits */
a3e77b6
+      keepon &= ~ (KEEP_RECV|KEEP_SEND);
a3e77b6
+      keepon |= conn->waitfor & (KEEP_RECV|KEEP_SEND);
a3e77b6
+    }
a3e77b6
 
a3e77b6
     /* limit-rate logic: if speed exceeds threshold, then do not include fd in
a3e77b6
        select set. The current speed is recalculated in each Curl_readwrite()
a3e77b6
        call */
a3e77b6
-    if((k->keepon & KEEP_SEND) &&
a3e77b6
+    if((keepon & KEEP_SEND) &&
a3e77b6
         (!data->set.max_send_speed ||
a3e77b6
          (data->progress.ulspeed < data->set.max_send_speed) )) {
a3e77b6
-      fd_write = conn->writesockfd;
a3e77b6
       k->keepon &= ~KEEP_SEND_HOLD;
a3e77b6
     }
a3e77b6
     else {
a3e77b6
       fd_write = CURL_SOCKET_BAD;
a3e77b6
-      if(k->keepon & KEEP_SEND)
a3e77b6
+      if(keepon & KEEP_SEND)
a3e77b6
         k->keepon |= KEEP_SEND_HOLD; /* hold it */
a3e77b6
     }
a3e77b6
 
a3e77b6
-    if((k->keepon & KEEP_RECV) &&
a3e77b6
+    if((keepon & KEEP_RECV) &&
a3e77b6
         (!data->set.max_recv_speed ||
a3e77b6
          (data->progress.dlspeed < data->set.max_recv_speed)) ) {
a3e77b6
-      fd_read = conn->sockfd;
a3e77b6
       k->keepon &= ~KEEP_RECV_HOLD;
a3e77b6
     }
a3e77b6
     else {
a3e77b6
       fd_read = CURL_SOCKET_BAD;
a3e77b6
-      if(k->keepon & KEEP_RECV)
a3e77b6
+      if(keepon & KEEP_RECV)
a3e77b6
         k->keepon |= KEEP_RECV_HOLD; /* hold it */
a3e77b6
     }
a3e77b6
 
a3e77b6
diff -rup curl-7.19.6.orig/lib/urldata.h curl-7.19.6/lib/urldata.h
a3e77b6
--- curl-7.19.6.orig/lib/urldata.h	2009-07-23 00:49:56.000000000 +0200
a3e77b6
+++ curl-7.19.6/lib/urldata.h	2009-09-02 15:43:13.339644227 +0200
a3e77b6
@@ -565,7 +565,6 @@ struct ssh_conn {
a3e77b6
   LIBSSH2_CHANNEL *ssh_channel; /* Secure Shell channel handle */
a3e77b6
   LIBSSH2_SFTP *sftp_session;   /* SFTP handle */
a3e77b6
   LIBSSH2_SFTP_HANDLE *sftp_handle;
a3e77b6
-  int waitfor;                  /* current READ/WRITE bits to wait for */
a3e77b6
   int orig_waitfor;             /* default READ/WRITE bits wait for */
a3e77b6
 
a3e77b6
   /* note that HAVE_LIBSSH2_KNOWNHOST_API is a define set in the libssh2.h
a3e77b6
@@ -1070,6 +1069,8 @@ struct connectdata {
a3e77b6
   } proto;
a3e77b6
 
a3e77b6
   int cselect_bits; /* bitmask of socket events */
a3e77b6
+  int waitfor;      /* current READ/WRITE bits to wait for */
a3e77b6
+
a3e77b6
 #if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI)
a3e77b6
   int socks5_gssapi_enctype;
a3e77b6
 #endif