[PATCH] ftpfs.c linear_abort workaround for dumb servers



Hello,
I recently encountered some ftp servers, which keep sending data even after reporting ABOR cmd complete. This patch adds a timeout after which a reconnect is performed instead of further fetching of the remaining data.

Regards,

--
Jindrich Makovicka

--- orig/ftpfs.c	2002-10-06 17:12:10.000000000 +0200
+++ ftpfs.c	2002-10-07 10:17:14.000000000 +0200
@@ -1003,8 +1003,17 @@
     if (dsock != -1) {
 	FD_ZERO(&mask);
 	FD_SET(dsock, &mask);
-	if (select(dsock + 1, &mask, NULL, NULL, NULL) > 0)
-	    while (read(dsock, buf, sizeof(buf)) > 0);
+	if (select(dsock + 1, &mask, NULL, NULL, NULL) > 0) {
+	    struct timeval start_tim, tim;
+	    gettimeofday(&start_tim, NULL);
+	    while (read(dsock, buf, sizeof(buf)) > 0) {
+		gettimeofday(&tim, NULL);
+		if (tim.tv_sec > start_tim.tv_sec+1) {
+		    reconnect (me, super);
+		    return;
+		}
+	    }
+	}
     }
     if ((get_reply(me, SUP.sock, NULL, 0) == TRANSIENT) && (code == 426))
 	get_reply(me, SUP.sock, NULL, 0);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]