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

pleaseWaitBox() in http-fetch.c ?



 I would like to commit the following (still untested) patch, but want
 to check with yous first...  In particular, I wonder if the wording
 in the pleaseWaitBox()'s is Ok with everyone?  It needs to be tested
 first also.

 The problem is, is that if, for instance, there's two NIC's and you
 configure the wrong one, or the cable's not plugged in, and it goes
 to do the DNS lookup, it leaves you sitting there with a blue screen,
 wondering what's going on.  It eventually times out, but there's no
 indication that it will, or any indication of what it's doing, and it
 can take quite a while to time out and print the perrorBox() about
 the DNS lookup failure.

 This patch attempts to fix that.  Look ok?

karlheg@bittersweet:/usr/local/src/cvs.debian.org/debian-boot/boot-floppies/utilities/dbootstrap
% cvs diff -u http-fetch.c
Index: http-fetch.c
===================================================================
RCS file: /var/cvs/debian-boot/boot-floppies/utilities/dbootstrap/http-fetch.c,v
retrieving revision 1.16
diff -u -u -r1.16 http-fetch.c
--- http-fetch.c	2000/05/17 03:50:19	1.16
+++ http-fetch.c	2000/05/18 06:58:44
@@ -215,6 +215,13 @@
   newtRefresh();
 #endif
 
+  /* Let them know it might take a minute if gethostbyname() fails. */
+  snprintf(sbuf, sizeof sbuf - 1,
+	   _("Resolving %s via DNS ...\n\nIf there is an error it will eventually time out and return control."),
+	   con_host);
+  pleaseWaitBox(sbuf);
+  /* pause long enough to read it in case gethostbyname() returns instantly. */
+  sleep(2);
   svr.sin_family = AF_INET;
   svr.sin_port = htons(con_port);
   hst = gethostbyname(con_host);
@@ -226,12 +233,18 @@
     problemBox(sbuf, _("Problem"));
     return -1;
   }
+  boxPopWindow();
 
 #if defined (_TESTING_) && defined (_DEBUG_)
   newtDrawRootText(2, 2, "Connecting ... [connect]    ");
   newtRefresh();
 #endif
 
+  snprintf(sbuf, sizeof sbuf - 1,
+	   _("Connecting to %s ...\n\nIf there is an error it will eventually time out and return control."),
+	   con_host);
+  pleaseWaitBox(sbuf);
+  sleep(2);
   svr.sin_addr = *(struct in_addr *) hst->h_addr;
   if (connect(sock, (struct sockaddr *) &svr, sizeof(svr))
    && errno != EINPROGRESS) {
@@ -239,16 +252,24 @@
     perrorBox("nf_http_fetchfile :: connect");
     return -1;
   }
+  boxPopWindow();
 
 #if defined (_TESTING_) && defined (_DEBUG_)
   newtDrawRootText(2, 2, "Connecting ... [non-block]  ");
   newtRefresh();
 #endif
 
+  snprintf(sbuf, sizeof sbuf - 1,
+	   _("Requesting %s ...\n\nIf there is an error it will eventually time out and return control."),
+	   remote_filename);
+  pleaseWaitBox(sbuf);
+  sleep(2);
+
   /* @@ Marcel TODO: connect sequence unfinished. finish EINPROGRESS handling. */
 
   if (nf_http_set_nonblock(sock, 1) < 0) {
     close(sock);
+    boxPopWindow();		/* Requesting <remote_filename> ... */
     perrorBox("nf_http_fetchfile :: nf_http_set_nonblock");
     return -1;
   }
@@ -267,6 +288,7 @@
 
   /* see if the file already exists; if so, try to resume - randolph */
   if (stat(target_path(local_filename), &statbuf) >= 0) {
+    boxPopWindow();		/* Requesting <remote_filename> ... */
     if (yesNoBox(_("Previous download detected. Attempt to resume?"),
 	         _("Resume download?")) == DLG_YES) { 
       char tmpbuf[256];
@@ -280,6 +302,7 @@
       newtRefresh();
 #endif
     }
+    pleaseWaitBox(sbuf);	/* Assumes that sbuf hasn't been changed!! */
   }
 
   /* End the request header */
@@ -287,6 +310,7 @@
   
   if (nf_http_write(sock, buf) < 0) {
     close(sock);
+    boxPopWindow();		/* Requesting <remote_filename> ... */
     return -1;
   }
 
@@ -295,6 +319,7 @@
              "nf_http_fetchfile :: couldn't open file %s for writing\n",
              target_path(local_filename));
     close(sock);
+    boxPopWindow();		/* Requesting <remote_filename> ... */
     problemBox(sbuf, _("Problem"));
     return -1;
   }
@@ -314,6 +339,8 @@
   content_length = -1;
   seen_http_ok = 0;
   bytes_read = 0;
+
+  boxPopWindow();		/* Requesting <remote_filename> ... */
 
   for (;;) {
     int r, eof;

-- 
Those who do not study dbootstrap are doomed to reimplement it - Poorly.
A few months in the laboratory often saves several hours at the library.

mailto:karlheg@debian.org (Karl M. Hegbloom)



Reply to: