[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor/master] Use download_status_get_next_attempt_at() more often



commit 344f5a71c5a2a697050c7e6545578c5a01eee0a5
Author: teor <teor2345@xxxxxxxxx>
Date:   Wed Jul 5 01:29:35 2017 +1000

    Use download_status_get_next_attempt_at() more often
    
    This guards against future occurrences of 17750.
---
 src/or/directory.c | 11 +++++++----
 src/or/directory.h |  5 +++--
 2 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/src/or/directory.c b/src/or/directory.c
index 3eb56c2..ea9d69b 100644
--- a/src/or/directory.c
+++ b/src/or/directory.c
@@ -3983,14 +3983,16 @@ download_status_increment_failure(download_status_t *dls, int status_code,
 
   download_status_log_helper(item, !dls->increment_on, "failed",
                              "concurrently", dls->n_download_failures,
-                             increment, dls->next_attempt_at, now);
+                             increment,
+                             download_status_get_next_attempt_at(dls),
+                             now);
 
   if (dls->increment_on == DL_SCHED_INCREMENT_ATTEMPT) {
     /* stop this schedule retrying on failure, it will launch concurrent
      * connections instead */
     return TIME_MAX;
   } else {
-    return dls->next_attempt_at;
+    return download_status_get_next_attempt_at(dls);
   }
 }
 
@@ -4034,9 +4036,10 @@ download_status_increment_attempt(download_status_t *dls, const char *item,
 
   download_status_log_helper(item, dls->increment_on, "attempted",
                              "on failure", dls->n_download_attempts,
-                             delay, dls->next_attempt_at, now);
+                             delay, download_status_get_next_attempt_at(dls),
+                             now);
 
-  return dls->next_attempt_at;
+  return download_status_get_next_attempt_at(dls);
 }
 
 static time_t
diff --git a/src/or/directory.h b/src/or/directory.h
index 8ff16b3..c473d8e 100644
--- a/src/or/directory.h
+++ b/src/or/directory.h
@@ -108,6 +108,8 @@ time_t download_status_increment_attempt(download_status_t *dls,
 void download_status_reset(download_status_t *dls);
 static int download_status_is_ready(download_status_t *dls, time_t now,
                                     int max_failures);
+time_t download_status_get_next_attempt_at(const download_status_t *dls);
+
 /** Return true iff, as of <b>now</b>, the resource tracked by <b>dls</b> is
  * ready to get its download reattempted. */
 static inline int
@@ -127,7 +129,7 @@ download_status_is_ready(download_status_t *dls, time_t now,
     if (!under_failure_limit)
       return 0;
   }
-  return dls->next_attempt_at <= now;
+  return download_status_get_next_attempt_at(dls) <= now;
 }
 
 static void download_status_mark_impossible(download_status_t *dl);
@@ -141,7 +143,6 @@ download_status_mark_impossible(download_status_t *dl)
 
 int download_status_get_n_failures(const download_status_t *dls);
 int download_status_get_n_attempts(const download_status_t *dls);
-time_t download_status_get_next_attempt_at(const download_status_t *dls);
 
 /* Yes, these two functions are confusingly similar.
  * Let's sort that out in #20077. */



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits