Fix: clear orphaned "Transfer complete" from ftp control channel if
authorjbj <devnull@localhost>
Thu, 21 Jan 1999 19:14:31 +0000 (19:14 +0000)
committerjbj <devnull@localhost>
Thu, 21 Jan 1999 19:14:31 +0000 (19:14 +0000)
using ftpGetFileDesc() access with cached control connection.

CVS patchset: 2730
CVS date: 1999/01/21 19:14:31

ftp.c
po/rpm.pot
url.h

diff --git a/ftp.c b/ftp.c
index 5d9c84a..41185bb 100644 (file)
--- a/ftp.c
+++ b/ftp.c
@@ -52,10 +52,12 @@ int inet_aton(const char *cp, struct in_addr *inp);
 static int ftpDebug = 0;
 static int ftpTimeoutSecs = TIMEOUT_SECS;
 
+#ifdef DYING
 static int ftpCheckResponse(urlinfo *u, char ** str);
 static int ftpCommand(urlinfo *u, char * command, ...);
 static int copyData(FD_t sfd, FD_t tfd);
 static int getHostAddress(const char * host, struct in_addr * address);
+#endif
 
 static int ftpCheckResponse(urlinfo *u, char ** str) {
     static char buf[BUFFER_SIZE + 1];
@@ -148,7 +150,7 @@ fprintf(stderr, "<- %s\n", buf);
     return 0;
 }
 
-int ftpCommand(urlinfo *u, char * command, ...) {
+static int ftpCommand(urlinfo *u, char * command, ...) {
     va_list ap;
     int len;
     char * s;
@@ -347,7 +349,7 @@ int ftpOpen(urlinfo *u)
     return u->ftpControl;
 }
 
-int copyData(FD_t sfd, FD_t tfd) {
+static int copyData(FD_t sfd, FD_t tfd) {
     char buf[BUFFER_SIZE];
     fd_set emptySet, readSet;
     struct timeval timeout;
@@ -424,6 +426,13 @@ fprintf(stderr, "-> ABOR\n");
     return 0;
 }
 
+static int ftpGetFileDone(urlinfo *u) {
+    if (u->ftpGetFileDoneNeeded && ftpCheckResponse(u, NULL))
+       return FTPERR_BAD_SERVER_RESPONSE;
+    u->ftpGetFileDoneNeeded = 0;
+    return 0;
+}
+
 int ftpGetFileDesc(FD_t fd)
 {
     urlinfo *u;
@@ -438,6 +447,15 @@ int ftpGetFileDesc(FD_t fd)
     u = (urlinfo *)fd->fd_url;
     remotename = u->path;
 
+/*
+ * XXX When ftpGetFileDesc() is called, there may be a lurking
+ * XXX transfer complete message (if ftpGetFileDone() was not
+ * XXX called to clear that message). Clear that message now.
+ */
+
+    if (u->ftpGetFileDoneNeeded)
+       rc = ftpGetFileDone(u);
+
 if (ftpDebug)
 fprintf(stderr, "-> PASV\n");
     if (write(u->ftpControl, "PASV\r\n", 6) != 6) {
@@ -507,12 +525,7 @@ fprintf(stderr, "-> %s", retrCommand);
        return rc;
     }
 
-    return 0;
-}
-
-static int ftpGetFileDone(urlinfo *u) {
-    if (ftpCheckResponse(u, NULL))
-       return FTPERR_BAD_SERVER_RESPONSE;
+    u ->ftpGetFileDoneNeeded = 1;
     return 0;
 }
 
index 4f49f3a..f73618c 100644 (file)
@@ -7,7 +7,7 @@
 msgid ""
 msgstr ""
 "Project-Id-Version: PACKAGE VERSION\n"
-"POT-Creation-Date: 1999-01-21 10:57-0500\n"
+"POT-Creation-Date: 1999-01-21 14:10-0500\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Language-Team: LANGUAGE <LL@li.org>\n"
@@ -175,55 +175,55 @@ msgstr ""
 msgid "OK"
 msgstr ""
 
-#: ../ftp.c:554
+#: ../ftp.c:567
 msgid "Success"
 msgstr ""
 
-#: ../ftp.c:557
+#: ../ftp.c:570
 msgid "Bad server response"
 msgstr ""
 
-#: ../ftp.c:560
+#: ../ftp.c:573
 msgid "Server IO error"
 msgstr ""
 
-#: ../ftp.c:563
+#: ../ftp.c:576
 msgid "Server timeout"
 msgstr ""
 
-#: ../ftp.c:566
+#: ../ftp.c:579
 msgid "Unable to lookup server host address"
 msgstr ""
 
-#: ../ftp.c:569
+#: ../ftp.c:582
 msgid "Unable to lookup server host name"
 msgstr ""
 
-#: ../ftp.c:572
+#: ../ftp.c:585
 msgid "Failed to connect to server"
 msgstr ""
 
-#: ../ftp.c:575
+#: ../ftp.c:588
 msgid "Failed to establish data connection to server"
 msgstr ""
 
-#: ../ftp.c:578
+#: ../ftp.c:591
 msgid "IO error to local file"
 msgstr ""
 
-#: ../ftp.c:581
+#: ../ftp.c:594
 msgid "Error setting remote server to passive mode"
 msgstr ""
 
-#: ../ftp.c:584
+#: ../ftp.c:597
 msgid "File not found on server"
 msgstr ""
 
-#: ../ftp.c:587
+#: ../ftp.c:600
 msgid "Abort in progress"
 msgstr ""
 
-#: ../ftp.c:591
+#: ../ftp.c:604
 msgid "Unknown or unexpected error"
 msgstr ""
 
diff --git a/url.h b/url.h
index 63e0772..9d5b6ad 100644 (file)
--- a/url.h
+++ b/url.h
@@ -18,6 +18,7 @@ typedef struct urlinfo {
     const char *path;
     int        port;
     int ftpControl;
+    int ftpGetFileDoneNeeded;
 } urlinfo;
 
 #ifndef        IPPORT_HTTP