Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-1-4]: src/usr.sbin/pkg_install/lib Pull up revision 1.18 (request...



details:   https://anonhg.NetBSD.org/src/rev/6db694ff84b5
branches:  netbsd-1-4
changeset: 470429:6db694ff84b5
user:      he <he%NetBSD.org@localhost>
date:      Mon Feb 28 18:58:33 2000 +0000

description:
Pull up revision 1.18 (requested by hubertf):
  Bump timeout in select() to 10 minutes.  Make sure ftp_cmd()
  properly passes up an error value when appropriate.

diffstat:

 usr.sbin/pkg_install/lib/ftpio.c |  28 ++++++++++++++++------------
 1 files changed, 16 insertions(+), 12 deletions(-)

diffs (80 lines):

diff -r 37e3181e5256 -r 6db694ff84b5 usr.sbin/pkg_install/lib/ftpio.c
--- a/usr.sbin/pkg_install/lib/ftpio.c  Mon Feb 28 09:52:42 2000 +0000
+++ b/usr.sbin/pkg_install/lib/ftpio.c  Mon Feb 28 18:58:33 2000 +0000
@@ -1,8 +1,8 @@
-/*     $NetBSD: ftpio.c,v 1.11.2.7 2000/02/22 22:51:10 he Exp $        */
+/*     $NetBSD: ftpio.c,v 1.11.2.8 2000/02/28 18:58:33 he Exp $        */
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: ftpio.c,v 1.11.2.7 2000/02/22 22:51:10 he Exp $");
+__RCSID("$NetBSD: ftpio.c,v 1.11.2.8 2000/02/28 18:58:33 he Exp $");
 #endif
 
 /*
@@ -122,7 +122,7 @@
 
     memset(buf, '\n', sizeof(buf));
 
-    timeout.tv_sec=5*60;
+    timeout.tv_sec=10*60;      /* seconds until next message from tar */
     timeout.tv_usec=0;
     done=0;
     retval=0;
@@ -139,8 +139,8 @@
            retval = -1;
            break;
        case 0:
-           warnx("expect: select() timeout!");
-           done = 1; /* hope that's ok */
+           warnx("expect: select() timeout");
+           done = 1;   /* hope that's ok */
            retval = -1;
            break;
        default:
@@ -190,26 +190,30 @@
 
 /*
  * send a certain ftp-command "cmd" to our FTP coprocess, and wait for
- * "expectstr" to be returned. Return numeric FTP return code. 
+ * "expectstr" to be returned. Return numeric FTP return code or -1
+ * in case of an error (usually expect() timeout) 
  */
 static int
 ftp_cmd(const char *cmd, const char *expectstr)
 {
     int rc=0, verbose_ftp=0;
+    int len;
 
     if (Verbose)
            verbose_ftp=1;
     
     if (verbose_ftp)
-      fprintf(stderr, "\nftp> %s", cmd);
+           fprintf(stderr, "\nftp> %s", cmd);
     
     fflush(stdout);
-    rc=write(ftpio.command, cmd, strlen(cmd));
-    if (rc == strlen(cmd)) {
+    len = write(ftpio.command, cmd, strlen(cmd));
+    if (len == strlen(cmd)) {
            if (expectstr) {
-                   expect(ftpio.answer, expectstr, &rc);
+                   /* set "rc" to the FTP error code: */
+                   if (expect(ftpio.answer, expectstr, &rc) == -1)
+                           rc = -1;    /* some error occured */
            }
-    } else {
+    } else {   
            if (Verbose)
                    warn("short write");
     }
@@ -391,7 +395,7 @@
                }
                
                rc = ftp_cmd("prompt off\n", "\n(Interactive mode off|221).*\n");
-               if (rc == 221) {
+               if ((rc == 221) || (rc == -1)) {
                        /* something is wrong */
                        ftp_started=1; /* not really, but for ftp_stop() */
                        ftp_stop();



Home | Main Index | Thread Index | Old Index