]> sjero.net Git - wget/blobdiff - src/retr.c
[svn] New function xsleep that resumes sleeps interrupted by signals
[wget] / src / retr.c
index 35286111e2020cd2bb7d5ff330425c5dadf2a150..c3da16417072f1400268443d126fe4428feb9fdb 100644 (file)
@@ -114,7 +114,7 @@ limit_bandwidth (long bytes, double *dltime, struct wget_timer *timer)
               slp, limit_data.chunk_bytes, limit_data.sleep_adjust));
 
       t0 = *dltime;
-      usleep ((unsigned long) (1000 * slp));
+      xsleep (slp / 1000);
       t1 = wtimer_elapsed (timer);
 
       /* Due to scheduling, we probably slept slightly longer (or
@@ -531,7 +531,7 @@ retrieve_url (const char *origurl, char **file, char **newloc,
   if (file)
     *file = local_file ? local_file : NULL;
   else
-    FREE_MAYBE (local_file);
+    xfree_null (local_file);
 
   url_free (u);
 
@@ -559,7 +559,8 @@ retrieve_url (const char *origurl, char **file, char **newloc,
    them.  If HTML is non-zero, treat the file as HTML, and construct
    the URLs accordingly.
 
-   If opt.recursive is set, call recursive_retrieve() for each file.  */
+   If opt.recursive is set, call retrieve_tree() for each file.  */
+
 uerr_t
 retrieve_from_file (const char *file, int html, int *count)
 {
@@ -584,7 +585,8 @@ retrieve_from_file (const char *file, int html, int *count)
          status = QUOTEXC;
          break;
        }
-      if (opt.recursive && cur_url->url->scheme != SCHEME_FTP)
+      if ((opt.recursive || opt.page_requisites)
+         && cur_url->url->scheme != SCHEME_FTP)
        status = retrieve_tree (cur_url->url->url);
       else
        status = retrieve_url (cur_url->url->url, &filename, &new_file, NULL, &dt);
@@ -599,8 +601,8 @@ retrieve_from_file (const char *file, int html, int *count)
          dt &= ~RETROKF;
        }
 
-      FREE_MAYBE (new_file);
-      FREE_MAYBE (filename);
+      xfree_null (new_file);
+      xfree_null (filename);
     }
 
   /* Free the linked list of URL-s.  */
@@ -640,9 +642,9 @@ sleep_between_retrievals (int count)
       /* If opt.waitretry is specified and this is a retry, wait for
         COUNT-1 number of seconds, or for opt.waitretry seconds.  */
       if (count <= opt.waitretry)
-       sleep (count - 1);
+       xsleep (count - 1);
       else
-       usleep (1000000L * opt.waitretry);
+       xsleep (opt.waitretry);
     }
   else if (opt.wait)
     {
@@ -650,7 +652,7 @@ sleep_between_retrievals (int count)
        /* If random-wait is not specified, or if we are sleeping
           between retries of the same download, sleep the fixed
           interval.  */
-       usleep (1000000L * opt.wait);
+       xsleep (opt.wait);
       else
        {
          /* Sleep a random amount of time averaging in opt.wait
@@ -659,7 +661,7 @@ sleep_between_retrievals (int count)
          double waitsecs = 2 * opt.wait * random_float ();
          DEBUGP (("sleep_between_retrievals: avg=%f,sleep=%f\n",
                   opt.wait, waitsecs));
-         usleep (1000000L * waitsecs);
+         xsleep (waitsecs);
        }
     }
 }
@@ -673,7 +675,7 @@ free_urlpos (struct urlpos *l)
       struct urlpos *next = l->next;
       if (l->url)
        url_free (l->url);
-      FREE_MAYBE (l->local_name);
+      xfree_null (l->local_name);
       xfree (l);
       l = next;
     }