diff options
-rw-r--r-- | src/or/circuitbuild.c | 6 | ||||
-rw-r--r-- | src/or/circuituse.c | 3 | ||||
-rw-r--r-- | src/or/connection.c | 24 | ||||
-rw-r--r-- | src/or/connection_edge.c | 9 | ||||
-rw-r--r-- | src/or/connection_or.c | 5 | ||||
-rw-r--r-- | src/or/directory.c | 3 | ||||
-rw-r--r-- | src/or/dns.c | 12 | ||||
-rw-r--r-- | src/or/main.c | 6 | ||||
-rw-r--r-- | src/or/or.h | 4 |
9 files changed, 70 insertions, 2 deletions
diff --git a/src/or/circuitbuild.c b/src/or/circuitbuild.c index 29937028dc..b43fc62c5f 100644 --- a/src/or/circuitbuild.c +++ b/src/or/circuitbuild.c @@ -764,6 +764,9 @@ static int new_route_len(double cw, uint8_t purpose, smartlist_t *routers) { routelen = 4; else { log_fn(LOG_WARN,"Bug: unhandled purpose %d", purpose); +#ifdef TOR_FRAGILE + tor_assert(0); +#endif return -1; } #endif @@ -1078,6 +1081,9 @@ choose_good_exit_server(uint8_t purpose, routerlist_t *dir, return r; } log_fn(LOG_WARN,"Bug: unhandled purpose %d", purpose); +#ifdef TOR_FRAGILE + tor_assert(0); +#endif return NULL; } diff --git a/src/or/circuituse.c b/src/or/circuituse.c index 268f17b057..590a71bc4b 100644 --- a/src/or/circuituse.c +++ b/src/or/circuituse.c @@ -699,6 +699,9 @@ circuit_launch_by_identity(uint8_t purpose, const char *exit_digest, default: log_fn(LOG_WARN,"Bug: unexpected purpose %d when cannibalizing a general circ.", purpose); +#ifdef TOR_FRAGILE + tor_assert(0); +#endif return NULL; } return circ; diff --git a/src/or/connection.c b/src/or/connection.c index 854989c46d..fb71291ca1 100644 --- a/src/or/connection.c +++ b/src/or/connection.c @@ -220,8 +220,12 @@ void connection_about_to_close_connection(connection_t *conn) assert(conn->marked_for_close); if (conn->type == CONN_TYPE_AP || conn->type == CONN_TYPE_EXIT) { - if (!conn->has_sent_end) + if (!conn->has_sent_end) { log_fn(LOG_WARN,"Bug: Edge connection hasn't sent end yet?"); +#ifdef TOR_FRAGILE + tor_assert(0); +#endif + } } switch (conn->type) { @@ -295,6 +299,9 @@ void connection_close_immediate(connection_t *conn) assert_connection_ok(conn,0); if (conn->s < 0) { log_fn(LOG_WARN,"Bug: Attempt to close already-closed connection."); +#ifdef TOR_FRAGILE + tor_assert(0); +#endif return; } if (conn->outbuf_flushlen) { @@ -319,6 +326,9 @@ _connection_mark_for_close(connection_t *conn) if (conn->marked_for_close) { log(LOG_WARN, "Bug: Double mark-for-close on connection."); +#ifdef TOR_FRAGILE + tor_assert(0); +#endif return -1; } @@ -1371,6 +1381,9 @@ static int connection_process_inbuf(connection_t *conn, int package_partial) { return connection_control_process_inbuf(conn); default: log_fn(LOG_WARN,"Bug: got unexpected conn type %d.", conn->type); +#ifdef TOR_FRAGILE + tor_assert(0); +#endif return -1; } } @@ -1403,6 +1416,9 @@ static int connection_finished_flushing(connection_t *conn) { return connection_control_finished_flushing(conn); default: log_fn(LOG_WARN,"Bug: got unexpected conn type %d.", conn->type); +#ifdef TOR_FRAGILE + tor_assert(0); +#endif return -1; } } @@ -1426,6 +1442,9 @@ static int connection_finished_connecting(connection_t *conn) return connection_dir_finished_connecting(conn); default: log_fn(LOG_WARN,"Bug: got unexpected conn type %d.", conn->type); +#ifdef TOR_FRAGILE + tor_assert(0); +#endif return -1; } } @@ -1448,6 +1467,9 @@ static int connection_reached_eof(connection_t *conn) return connection_control_reached_eof(conn); default: log_fn(LOG_WARN,"Bug: got unexpected conn type %d.", conn->type); +#ifdef TOR_FRAGILE + tor_assert(0); +#endif return -1; } } diff --git a/src/or/connection_edge.c b/src/or/connection_edge.c index edc8379d15..f8e256c8fa 100644 --- a/src/or/connection_edge.c +++ b/src/or/connection_edge.c @@ -93,6 +93,9 @@ int connection_edge_process_inbuf(connection_t *conn, int package_partial) { return 0; } log_fn(LOG_WARN,"Bug: Got unexpected state %d. Closing.",conn->state); +#ifdef TOR_FRAGILE + tor_assert(0); +#endif connection_edge_end(conn, END_STREAM_REASON_MISC, conn->cpath_layer); connection_mark_for_close(conn); return -1; @@ -131,6 +134,9 @@ connection_edge_end(connection_t *conn, char reason, crypt_path_t *cpath_layer) if (conn->has_sent_end) { log_fn(LOG_WARN,"Bug: Calling connection_edge_end on an already ended stream?"); +#ifdef TOR_FRAGILE + tor_assert(0); +#endif return -1; } @@ -183,6 +189,9 @@ int connection_edge_finished_flushing(connection_t *conn) { return 0; default: log_fn(LOG_WARN,"BUG: called in unexpected state %d.", conn->state); +#ifdef TOR_FRAGILE + tor_assert(0); +#endif return -1; } return 0; diff --git a/src/or/connection_or.c b/src/or/connection_or.c index dd678c04bb..98c1f3bcb8 100644 --- a/src/or/connection_or.c +++ b/src/or/connection_or.c @@ -78,6 +78,9 @@ int connection_or_finished_flushing(connection_t *conn) { if (conn->state != OR_CONN_STATE_OPEN) { log_fn(LOG_WARN,"BUG: called in unexpected state %d",conn->state); +#ifdef TOR_FRAGILE + tor_assert(0); +#endif return -1; } @@ -210,7 +213,7 @@ connection_t *connection_or_connect(uint32_t addr, uint16_t port, if (server_mode(get_options()) && (me=router_get_my_routerinfo()) && !memcmp(me->identity_digest, id_digest,DIGEST_LEN)) { - log_fn(LOG_WARN,"Bug: Request to connect to myself! Failing."); + log_fn(LOG_WARN,"Bug: Client asked me to connect to myself! Refusing."); return NULL; } diff --git a/src/or/directory.c b/src/or/directory.c index 1742500251..1fd242a1be 100644 --- a/src/or/directory.c +++ b/src/or/directory.c @@ -1080,6 +1080,9 @@ int connection_dir_finished_flushing(connection_t *conn) { return 0; default: log_fn(LOG_WARN,"Bug: called in unexpected state %d.", conn->state); +#ifdef TOR_FRAGILE + tor_assert(0); +#endif return -1; } return 0; diff --git a/src/or/dns.c b/src/or/dns.c index 6d98c89d83..3e862ce692 100644 --- a/src/or/dns.c +++ b/src/or/dns.c @@ -118,9 +118,15 @@ static void purge_expired_resolves(uint32_t now) { log(LOG_DEBUG,"Forgetting old cached resolve (expires %lu)", (unsigned long)resolve->expire); if (resolve->state == CACHE_STATE_PENDING) { log_fn(LOG_WARN,"Bug: Expiring a dns resolve that's still pending. Forgot to cull it?"); +#ifdef TOR_FRAGILE + tor_assert(0); +#endif } if (resolve->pending_connections) { log_fn(LOG_WARN, "Closing pending connections on expiring DNS resolve!"); +#ifdef TOR_FRAGILE + tor_assert(0); +#endif while (resolve->pending_connections) { pend = resolve->pending_connections; resolve->pending_connections = pend->next; @@ -401,6 +407,9 @@ void dns_cancel_pending_resolve(char *address) { if (!resolve->pending_connections) { /* XXX this should never trigger, but sometimes it does */ log_fn(LOG_WARN,"Bug: Address '%s' is pending but has no pending connections!", address); +#ifdef TOR_FRAGILE + tor_assert(0); +#endif return; } tor_assert(resolve->pending_connections); @@ -596,6 +605,9 @@ int connection_dns_process_inbuf(connection_t *conn) { if (conn->state != DNSWORKER_STATE_BUSY && buf_datalen(conn->inbuf)) { log_fn(LOG_WARN,"Bug: read data from an idle dns worker. Please report."); +#ifdef TOR_FRAGILE + tor_assert(0); +#endif return 0; } if (buf_datalen(conn->inbuf) < 5) /* entire answer available? */ diff --git a/src/or/main.c b/src/or/main.c index cd3768c5ee..20c6e34035 100644 --- a/src/or/main.c +++ b/src/or/main.c @@ -339,6 +339,9 @@ conn_read_callback(int fd, short event, void *_conn) #ifndef MS_WINDOWS log_fn(LOG_WARN,"Bug: unhandled error on read for %s connection (fd %d); removing", CONN_TYPE_TO_STRING(conn->type), conn->s); +#ifdef TOR_FRAGILE + tor_assert(0); +#endif #endif connection_mark_for_close(conn); } @@ -366,6 +369,9 @@ static void conn_write_callback(int fd, short events, void *_conn) /* this connection is broken. remove it. */ log_fn(LOG_WARN,"Bug: unhandled error on write for %s connection (fd %d); removing", CONN_TYPE_TO_STRING(conn->type), conn->s); +#ifdef TOR_FRAGILE + tor_assert(0); +#endif conn->has_sent_end = 1; /* otherwise we cry wolf about duplicate close */ /* XXX do we need a close-immediate here, so we don't try to flush? */ connection_mark_for_close(conn); diff --git a/src/or/or.h b/src/or/or.h index 443b57b2bb..39cb83c112 100644 --- a/src/or/or.h +++ b/src/or/or.h @@ -128,6 +128,10 @@ #include "../common/util.h" #include "../common/torgzip.h" +/** Define this if you want Tor to crash when any problem comes up, + * so you can get a coredump and track things down. */ +#undef TOR_FRAGILE + /** Upper bound on maximum simultaneous connections; can be lowered by * config file. */ #define MAXCONNECTIONS 15000 |