From 5a0f05423ac3b75a9eac405d82db410c402bcdd7 Mon Sep 17 00:00:00 2001 From: Giuseppe Scrivano Date: Sun, 9 Dec 2012 22:04:58 +0100 Subject: [PATCH] Fix a tight-loop when a recursion level is used. --- src/ChangeLog | 3 +++ src/recur.c | 7 ++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index e1c8d4b7..706e5ec8 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,8 @@ 2012-12-09 Giuseppe Scrivano + * recur.c (retrieve_tree): Do not attempt to re-download a file if + `next_url' is known. + * test.c: Include "wget.h". 2012-12-04 Giuseppe Scrivano diff --git a/src/recur.c b/src/recur.c index f5932de3..60ce8f57 100644 --- a/src/recur.c +++ b/src/recur.c @@ -267,6 +267,7 @@ retrieve_tree (struct url *start_url_parsed, struct iri *pi) char *url = NULL, *referer; int depth; bool html_allowed, css_allowed; + bool dequed = false; #ifdef ENABLE_THREADS int index = 0; #endif @@ -286,10 +287,10 @@ retrieve_tree (struct url *start_url_parsed, struct iri *pi) #else if (next_url == NULL) { - if (! url_dequeue (queue, (struct iri **) &next_i, + if (url_dequeue (queue, (struct iri **) &next_i, (const char **)&next_url, (const char **)&next_referer, &next_depth, &next_html_allowed, &next_css_allowed)) - url = NULL; + dequed = true; } i = next_i; @@ -308,7 +309,7 @@ retrieve_tree (struct url *start_url_parsed, struct iri *pi) and again under URL2, but at a different (possibly smaller) depth, we want the URL's children to be taken into account the second time. */ - if (url && dl_url_file_map && hash_table_contains (dl_url_file_map, url)) + if (dequed && url && dl_url_file_map && hash_table_contains (dl_url_file_map, url)) { file = xstrdup (hash_table_get (dl_url_file_map, url));