From eb0f9de05d27d0c7c41b1300a84dfb3cd49442c9 Mon Sep 17 00:00:00 2001 From: hniksic Date: Mon, 17 Dec 2001 07:00:25 -0800 Subject: [PATCH] [svn] Simplify indentation in sleep_between_retrievals. --- src/ChangeLog | 4 ++++ src/retr.c | 61 +++++++++++++++++++++++++++------------------------ 2 files changed, 36 insertions(+), 29 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 974ba611..e5dc98bc 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,7 @@ +2001-12-17 Hrvoje Niksic + + * retr.c (sleep_between_retrievals): Simplify indentation. + 2001-12-17 Hrvoje Niksic * gen_sslfunc.c (ssl_init_prng): Use random_number to get a byte diff --git a/src/retr.c b/src/retr.c index 6bd88589..dabb407e 100644 --- a/src/retr.c +++ b/src/retr.c @@ -653,38 +653,41 @@ sleep_between_retrievals (int count) { static int first_retrieval = 1; - if (!first_retrieval && (opt.wait || opt.waitretry)) + if (first_retrieval) { - if (opt.waitretry && count > 1) - { - /* 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); - else - sleep (opt.waitretry); - } - else if (opt.wait) - { - /* Otherwise, check if opt.wait is specified. If so, sleep. */ - if (count > 1 || !opt.random_wait) - sleep (opt.wait); - else - { - /* Sleep a random amount of time averaging in opt.wait - seconds. The sleeping amount ranges from 0 to - opt.wait*2, inclusive. */ - int waitsecs = random_number (opt.wait * 2 + 1); + /* Don't sleep before the very first retrieval. */ + first_retrieval = 0; + return; + } - DEBUGP (("sleep_between_retrievals: norm=%ld,fuzz=%ld,sleep=%d\n", - opt.wait, waitsecs - opt.wait, waitsecs)); + if (opt.waitretry && count > 1) + { + /* 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); + else + sleep (opt.waitretry); + } + else if (opt.wait) + { + if (!opt.random_wait || count > 1) + /* If random-wait is not specified, or if we are sleeping + between retries of the same download, sleep the fixed + interval. */ + sleep (opt.wait); + else + { + /* Sleep a random amount of time averaging in opt.wait + seconds. The sleeping amount ranges from 0 to + opt.wait*2, inclusive. */ + int waitsecs = random_number (opt.wait * 2 + 1); - if (waitsecs) - sleep (waitsecs); - } + DEBUGP (("sleep_between_retrievals: norm=%ld,fuzz=%ld,sleep=%d\n", + opt.wait, waitsecs - opt.wait, waitsecs)); + + if (waitsecs) + sleep (waitsecs); } } - if (first_retrieval) - first_retrieval = 0; }