]> asedeno.scripts.mit.edu Git - PuTTY.git/commitdiff
The xfer mechanism wasn't gracefully terminating when an error was
authorSimon Tatham <anakin@pobox.com>
Fri, 17 Dec 2004 13:39:41 +0000 (13:39 +0000)
committerSimon Tatham <anakin@pobox.com>
Fri, 17 Dec 2004 13:39:41 +0000 (13:39 +0000)
encountered part way through transfer. In particular, this caused
psftp to hang (waiting for FXP_READ replies which had already
arrived) if you try `get' (without -r) on a remote directory.

[originally from svn r5005]

psftp.c
sftp.c

diff --git a/psftp.c b/psftp.c
index 7bc556ee55b9a587922070f0802f6fd165004c91..0eedf9d2237a7fd2f1090b5261f3ddc2e92fd7af 100644 (file)
--- a/psftp.c
+++ b/psftp.c
@@ -201,7 +201,7 @@ int sftp_get_file(char *fname, char *outfname, int recurse, int restart,
     struct fxp_xfer *xfer;
     uint64 offset;
     FILE *fp;
-    int ret;
+    int ret, shown_err = FALSE;
 
     /*
      * In recursive mode, see if we're dealing with a directory.
@@ -443,7 +443,10 @@ int sftp_get_file(char *fname, char *outfname, int recurse, int restart,
        ret = xfer_download_gotpkt(xfer, pktin);
 
        if (ret < 0) {
-            printf("error while reading: %s\n", fxp_error());
+           if (!shown_err) {
+               printf("error while reading: %s\n", fxp_error());
+               shown_err = TRUE;
+           }
             ret = 0;
        }
 
diff --git a/sftp.c b/sftp.c
index 66e96b44c3e3a01c76ab64a607f5281c54e9ae67..a55262a7ced228b66bdcc732f848754a60657f95 100644 (file)
--- a/sftp.c
+++ b/sftp.c
@@ -1089,7 +1089,8 @@ int xfer_done(struct fxp_xfer *xfer)
 
 void xfer_download_queue(struct fxp_xfer *xfer)
 {
-    while (xfer->req_totalsize < xfer->req_maxsize && !xfer->eof) {
+    while (xfer->req_totalsize < xfer->req_maxsize &&
+          !xfer->eof && !xfer->err) {
        /*
         * Queue a new read request.
         */
@@ -1155,6 +1156,8 @@ int xfer_download_gotpkt(struct fxp_xfer *xfer, struct sftp_packet *pktin)
 #endif
     } else if (rr->retlen < 0) {
        /* some error other than EOF; signal it back to caller */
+       xfer_set_error(xfer);
+       rr->complete = -1;
        return -1;
     }