summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2005-04-07 21:07:19 +0000
committerNick Mathewson <nickm@torproject.org>2005-04-07 21:07:19 +0000
commit8cc3307e0d240454985154504dfe8852c3cbb66a (patch)
tree59d8d756aa41507388e7edbe545c234f3cdbd28e
parentdd98412ce122b84a01fb01e24068c9d7e95cb04f (diff)
downloadtor-8cc3307e0d240454985154504dfe8852c3cbb66a.tar.gz
tor-8cc3307e0d240454985154504dfe8852c3cbb66a.zip
Improve conn_*_to_string; add circuit_state_to_string; make skewed-descriptor messages better.
svn:r4047
-rw-r--r--src/or/circuitbuild.c2
-rw-r--r--src/or/circuitlist.c24
-rw-r--r--src/or/circuituse.c4
-rw-r--r--src/or/connection.c2
-rw-r--r--src/or/dirserv.c6
-rw-r--r--src/or/or.h2
-rw-r--r--src/or/rendservice.c2
7 files changed, 27 insertions, 15 deletions
diff --git a/src/or/circuitbuild.c b/src/or/circuitbuild.c
index c3e057d6c0..d5afffb537 100644
--- a/src/or/circuitbuild.c
+++ b/src/or/circuitbuild.c
@@ -185,7 +185,7 @@ circuit_dump_details(int severity, circuit_t *circ, int poll_index,
const char *type, int this_circid, int other_circid) {
log(severity,"Conn %d has %s circuit: circID %d (other side %d), state %d (%s), born %d:",
poll_index, type, this_circid, other_circid, circ->state,
- circuit_state_to_string[circ->state], (int)circ->timestamp_created);
+ circuit_state_to_string(circ->state), (int)circ->timestamp_created);
if (CIRCUIT_IS_ORIGIN(circ)) { /* circ starts at this node */
circuit_log_path(severity, circ);
}
diff --git a/src/or/circuitlist.c b/src/or/circuitlist.c
index 482fea44e4..502939956a 100644
--- a/src/or/circuitlist.c
+++ b/src/or/circuitlist.c
@@ -15,14 +15,6 @@ const char circuitlist_c_id[] = "$Id$";
/********* START VARIABLES **********/
-/** Array of strings to make circ-\>state human-readable */
-const char *circuit_state_to_string[] = {
- "doing handshakes", /* 0 */
- "processing the onion", /* 1 */
- "connecting to firsthop", /* 2 */
- "open" /* 3 */
-};
-
/** A global list of all circuits at this hop. */
circuit_t *global_circuitlist=NULL;
@@ -156,6 +148,22 @@ void circuit_close_all_marked(void)
}
}
+/** Function to make circ-\>state human-readable */
+const char *
+circuit_state_to_string(int state) {
+ static buf[64];
+ switch (state) {
+ case CIRCUIT_STATE_BUILDING: return "doing handshakes";
+ case CIRCUIT_STATE_ONIONSKIN_PENDING: return "processing the onion";
+ case CIRCUIT_STATE_OR_WAIT: return "connecting to firsthop";
+ case CIRCUIT_STATE_OPEN: return "open";
+ default:
+ log_fn(LOG_WARN, "Bug: unknown circuit state %d", state);
+ tor_snprintf(buf, sizeof(buf), "unknown state [%d], state");
+ return buf;
+ }
+}
+
/** Allocate space for a new circuit, initializing with <b>p_circ_id</b>
* and <b>p_conn</b>. Add it to the global circuit list.
*/
diff --git a/src/or/circuituse.c b/src/or/circuituse.c
index 257d521683..88ca9249b1 100644
--- a/src/or/circuituse.c
+++ b/src/or/circuituse.c
@@ -240,10 +240,10 @@ void circuit_expire_building(time_t now) {
if (victim->n_conn)
log_fn(LOG_INFO,"Abandoning circ %s:%d:%d (state %d:%s, purpose %d)",
victim->n_conn->address, victim->n_port, victim->n_circ_id,
- victim->state, circuit_state_to_string[victim->state], victim->purpose);
+ victim->state, circuit_state_to_string(victim->state), victim->purpose);
else
log_fn(LOG_INFO,"Abandoning circ %d (state %d:%s, purpose %d)", victim->n_circ_id,
- victim->state, circuit_state_to_string[victim->state], victim->purpose);
+ victim->state, circuit_state_to_string(victim->state), victim->purpose);
circuit_log_path(LOG_INFO,victim);
circuit_mark_for_close(victim);
}
diff --git a/src/or/connection.c b/src/or/connection.c
index 281eca9599..4d81ca91d1 100644
--- a/src/or/connection.c
+++ b/src/or/connection.c
@@ -44,6 +44,7 @@ conn_type_to_string(int type)
case CONN_TYPE_CONTROL_LISTENER: return "Control listener";
case CONN_TYPE_CONTROL: return "Control";
default:
+ log_fn(LOG_WARN, "Bug: unknown connection type %d", type);
tor_snprintf(buf, sizeof(buf), "unknown [%d]", type);
return buf;
}
@@ -117,6 +118,7 @@ conn_state_to_string(int type, int state) {
break;
}
+ log_fn(LOG_WARN, "Bug: unknown connection state %d (type %d)", state, type);
tor_snprintf(buf, sizeof(buf),
"unknown state [%d] on unknown [%s] connection",
state, conn_type_to_string(type));
diff --git a/src/or/dirserv.c b/src/or/dirserv.c
index 56bb0b21b1..eb7fa772c3 100644
--- a/src/or/dirserv.c
+++ b/src/or/dirserv.c
@@ -357,14 +357,16 @@ dirserv_add_descriptor(const char **desc, const char **msg)
/* Is there too much clock skew? */
now = time(NULL);
if (ri->published_on > now+ROUTER_ALLOW_SKEW) {
- log_fn(LOG_NOTICE, "Publication time for nickname '%s' is too far in the future; possible clock skew. Not adding.", ri->nickname);
+ log_fn(LOG_NOTICE, "Publication time for nickname '%s' is too far (%d minutes) in the future; possible clock skew. Not adding.",
+ ri->nickname, (int)((ri->published_on-now)/60));
*msg = "Rejected: Your clock is set too far in the future, or your timezone is not correct.";
routerinfo_free(ri);
*desc = end;
return -1;
}
if (ri->published_on < now-ROUTER_MAX_AGE) {
- log_fn(LOG_NOTICE, "Publication time for router with nickname '%s' is too far in the past. Not adding.", ri->nickname);
+ log_fn(LOG_NOTICE, "Publication time for router with nickname '%s' is too far (%d minutes) in the past. Not adding.",
+ ri->nickname, (int)((now-ri->published_on)/60));
*msg = "Rejected: Server is expired, or your clock is too far in the past, or your timezone is not correct.";
routerinfo_free(ri);
*desc = end;
diff --git a/src/or/or.h b/src/or/or.h
index ac3ceb81c7..0eee10681b 100644
--- a/src/or/or.h
+++ b/src/or/or.h
@@ -1165,7 +1165,7 @@ void onion_append_to_cpath(crypt_path_t **head_ptr, crypt_path_t *new_hop);
/********************************* circuitlist.c ***********************/
-extern const char *circuit_state_to_string[];
+const char *circuit_state_to_string(int state);
enum which_conn_changed_t { P_CONN_CHANGED=1, N_CONN_CHANGED=0 };
void circuit_set_circid_orconn(circuit_t *circ, uint16_t id,
connection_t *conn,
diff --git a/src/or/rendservice.c b/src/or/rendservice.c
index ae435a2292..aa39f76764 100644
--- a/src/or/rendservice.c
+++ b/src/or/rendservice.c
@@ -988,7 +988,7 @@ rend_service_dump_stats(int severity)
continue;
}
log(severity, " Intro point at %s: circuit is %s",nickname,
- circuit_state_to_string[circ->state]);
+ circuit_state_to_string(circ->state));
}
}
}