summaryrefslogtreecommitdiff
path: root/src/feature
diff options
context:
space:
mode:
authorTaylor Yu <catalyst@torproject.org>2018-08-31 17:54:09 -0500
committerTaylor Yu <catalyst@torproject.org>2018-09-10 13:18:32 -0500
commit687bf3ea645ef8c5ce8c9f02a25274121ca13318 (patch)
treecf14609ef1c3d4af8d2a6f7ce9188628d6f6b880 /src/feature
parent5733d3f71f0094c2eade64795521321cd653855b (diff)
downloadtor-687bf3ea645ef8c5ce8c9f02a25274121ca13318.tar.gz
tor-687bf3ea645ef8c5ce8c9f02a25274121ca13318.zip
Track bootstrap phase independently of progress
Track bootstrap phase (enumerated by bootstrap_status_t) independently from the bootstrap progress (which can represent intermediate progress). This allows control_event_bootstrap_problem() to avoid doing a linear search through the bootstrap progress space to find the current bootstrap phase.
Diffstat (limited to 'src/feature')
-rw-r--r--src/feature/control/control.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/feature/control/control.c b/src/feature/control/control.c
index 64785a758d..d68f1e3b07 100644
--- a/src/feature/control/control.c
+++ b/src/feature/control/control.c
@@ -7073,6 +7073,11 @@ bootstrap_status_to_string(bootstrap_status_t s, const char **tag,
* Tor initializes. */
static int bootstrap_percent = BOOTSTRAP_STATUS_UNDEF;
+/** Like bootstrap_percent, but only takes on the enumerated values in
+ * bootstrap_status_t.
+ */
+static int bootstrap_phase = BOOTSTRAP_STATUS_UNDEF;
+
/** As bootstrap_percent, but holds the bootstrapping level at which we last
* logged a NOTICE-level message. We use this, plus BOOTSTRAP_PCT_INCREMENT,
* to avoid flooding the log with a new message every time we get a few more
@@ -7158,7 +7163,8 @@ control_event_bootstrap(bootstrap_status_t status, int progress)
control_event_bootstrap_core(loglevel, status, progress);
if (status > bootstrap_percent) {
- bootstrap_percent = status; /* new milestone reached */
+ bootstrap_phase = status; /* new milestone reached */
+ bootstrap_percent = status;
}
if (progress > bootstrap_percent) {
/* incremental progress within a milestone */
@@ -7206,9 +7212,7 @@ control_event_bootstrap_problem(const char *warn, const char *reason,
if (we_are_hibernating())
dowarn = 0;
- while (status>=0 && bootstrap_status_to_string(status, &tag, &summary) < 0)
- status--; /* find a recognized status string based on current progress */
- status = bootstrap_percent; /* set status back to the actual number */
+ tor_assert(bootstrap_status_to_string(bootstrap_phase, &tag, &summary) == 0);
severity = dowarn ? LOG_WARN : LOG_INFO;