I was on the second paragraph of my or-dev mail explaining why I chose to

set starting=1 to avoid potential bugs with having it conflict with 0,
which I used to mean uninitialized, when I realized I would be writing
many more lame-sounding paragraphs in the future. Just start it at 0
and handle the bugs.


svn:r15346
This commit is contained in:
Roger Dingledine 2008-06-18 05:35:19 +00:00
parent ed174245c6
commit 50d3adb819
3 changed files with 13 additions and 7 deletions

View File

@ -55,7 +55,7 @@ Status: Open
the same order. Some phases might also be skipped (not reported) if the the same order. Some phases might also be skipped (not reported) if the
associated bootstrap step is already complete. associated bootstrap step is already complete.
Phase 1: Phase 0:
tag=starting summary="starting" tag=starting summary="starting"
Tor starts out in this phase. Tor starts out in this phase.

View File

@ -3715,6 +3715,10 @@ bootstrap_status_to_string(bootstrap_status_t s, const char **tag,
const char **summary) const char **summary)
{ {
switch (s) { switch (s) {
case BOOTSTRAP_STATUS_UNDEF:
*tag = "undef";
*summary = "Undefined";
break;
case BOOTSTRAP_STATUS_STARTING: case BOOTSTRAP_STATUS_STARTING:
*tag = "starting"; *tag = "starting";
*summary = "Starting"; *summary = "Starting";
@ -3782,8 +3786,9 @@ bootstrap_status_to_string(bootstrap_status_t s, const char **tag,
/** What percentage through the bootstrap process are we? We remember /** What percentage through the bootstrap process are we? We remember
* this so we can avoid sending redundant bootstrap status events, and * this so we can avoid sending redundant bootstrap status events, and
* so we can guess context for the bootstrap messages which are * so we can guess context for the bootstrap messages which are
* ambiguous. */ * ambiguous. It starts at 'undef', but gets set to 'starting' while
static int bootstrap_percent = 0; * Tor initializes. */
static int bootstrap_percent = BOOTSTRAP_STATUS_UNDEF;
/** How many problems have we had getting to the next bootstrapping phase? /** How many problems have we had getting to the next bootstrapping phase?
* These include failure to establish a connection to a Tor relay, * These include failure to establish a connection to a Tor relay,
@ -3807,7 +3812,7 @@ control_event_bootstrap(bootstrap_status_t status, int progress)
const char *tag, *summary; const char *tag, *summary;
char buf[BOOTSTRAP_MSG_LEN]; char buf[BOOTSTRAP_MSG_LEN];
if (bootstrap_percent == 100) if (bootstrap_percent == BOOTSTRAP_STATUS_DONE)
return; /* already bootstrapped; nothing to be done here. */ return; /* already bootstrapped; nothing to be done here. */
/* special case for handshaking status, since our TLS handshaking code /* special case for handshaking status, since our TLS handshaking code
@ -3860,7 +3865,7 @@ control_event_bootstrap_problem(const char *warn, int reason)
if (++bootstrap_problems != BOOTSTRAP_PROBLEM_THRESHOLD) if (++bootstrap_problems != BOOTSTRAP_PROBLEM_THRESHOLD)
return; /* no worries yet */ return; /* no worries yet */
while (bootstrap_status_to_string(status, &tag, &summary) < 0) while (status>=0 && bootstrap_status_to_string(status, &tag, &summary) < 0)
status--; /* find a recognized status string based on current progress */ status--; /* find a recognized status string based on current progress */
log_warn(LD_CONTROL, "Problem bootstrapping. Stuck at %d%%: %s. (%s; %s)", log_warn(LD_CONTROL, "Problem bootstrapping. Stuck at %d%%: %s. (%s; %s)",

View File

@ -3057,9 +3057,10 @@ void enable_control_logging(void);
/** Enum describing various stages of bootstrapping, for use with controller /** Enum describing various stages of bootstrapping, for use with controller
* bootstrap status events. The values range from 0 to 100. */ * bootstrap status events. The values range from 0 to 100. */
typedef enum { typedef enum {
BOOTSTRAP_STATUS_STARTING=1, BOOTSTRAP_STATUS_UNDEF=-1,
BOOTSTRAP_STATUS_STARTING=0,
BOOTSTRAP_STATUS_CONN_DIR=5, BOOTSTRAP_STATUS_CONN_DIR=5,
BOOTSTRAP_STATUS_HANDSHAKE=-1, BOOTSTRAP_STATUS_HANDSHAKE=-2,
BOOTSTRAP_STATUS_HANDSHAKE_DIR=10, BOOTSTRAP_STATUS_HANDSHAKE_DIR=10,
BOOTSTRAP_STATUS_ONEHOP_CREATE=15, BOOTSTRAP_STATUS_ONEHOP_CREATE=15,
BOOTSTRAP_STATUS_REQUESTING_STATUS=20, BOOTSTRAP_STATUS_REQUESTING_STATUS=20,