This patch works around the sftp-server bug in sshfs:

Index: sshfs.c
===================================================================
RCS file: /cvsroot/fuse/sshfs/sshfs.c,v
retrieving revision 1.80
diff -u -r1.80 sshfs.c
--- sshfs.c     20 Dec 2006 17:48:08 -0000      1.80
+++ sshfs.c     19 Feb 2007 15:13:38 -0000
@@ -124,6 +124,7 @@
     struct timeval start;
     void *data;
     request_func end_func;
+    size_t len;
     struct list_head list;
 };
 
@@ -186,6 +187,9 @@
     unsigned blksize;
     char *progname;
     long modifver;
+    unsigned outstanding_len;
+    unsigned max_outstanding_len;
+    pthread_cond_t outstanding_cond;
 };
 
 static struct sshfs sshfs;
@@ -958,8 +966,13 @@
                                                      GUINT_TO_POINTER(id));
         if (req == NULL)
             fprintf(stderr, "request %i not found\n", id);
-        else
+        else {
+            int was_over = sshfs.outstanding_len > sshfs.max_outstanding_len;
+            sshfs.outstanding_len -= req->len;
+            if (was_over && sshfs.outstanding_len <= sshfs.max_outstanding_len)
+                pthread_cond_broadcast(&sshfs.outstanding_cond);
             g_hash_table_remove(sshfs.reqtab, GUINT_TO_POINTER(id));
+        }
         pthread_mutex_unlock(&sshfs.lock);
         if (req != NULL) {
             struct timeval now;
@@ -1353,6 +1366,11 @@
         pthread_mutex_unlock(&sshfs.lock);
         goto out;
     }
+    req->len = iov_length(iov, count) + 9;
+    sshfs.outstanding_len += req->len;
+    while (sshfs.outstanding_len > sshfs.max_outstanding_len)
+        pthread_cond_wait(&sshfs.outstanding_cond, &sshfs.lock);
+
     g_hash_table_insert(sshfs.reqtab, GUINT_TO_POINTER(id), req);
     gettimeofday(&req->start, NULL);
     DEBUG("[%05i] %s\n", id, type_name(type));
@@ -2356,6 +2374,7 @@
 {
     pthread_mutex_init(&sshfs.lock, NULL);
     pthread_mutex_init(&sshfs.lock_write, NULL);
+    pthread_cond_init(&sshfs.outstanding_cond, NULL);
     sshfs.reqtab = g_hash_table_new(NULL, NULL);
     if (!sshfs.reqtab) {
         fprintf(stderr, "failed to create hash table\n");
@@ -2580,6 +2601,7 @@
 
     sshfs.blksize = 4096;
     sshfs.max_read = 65536;
+    sshfs.max_outstanding_len = 8388608; /* buggy sftp-server in OpenSSH */
     sshfs.nodelay_workaround = 1;
     sshfs.nodelaysrv_workaround = 1;
     sshfs.rename_workaround = 0;


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to