[or-cvs] get more serious about hunting The Bug
Roger Dingledine
arma at seul.org
Fri Apr 9 09:39:45 UTC 2004
Update of /home/or/cvsroot/src/or
In directory moria.mit.edu:/home2/arma/work/onion/cvs/src/or
Modified Files:
dns.c main.c or.h
Log Message:
get more serious about hunting The Bug
(it has been haunting us since the days of 0.0.2preX)
Index: dns.c
===================================================================
RCS file: /home/or/cvsroot/src/or/dns.c,v
retrieving revision 1.73
retrieving revision 1.74
diff -u -d -r1.73 -r1.74
--- dns.c 7 Apr 2004 19:57:39 -0000 1.73
+++ dns.c 9 Apr 2004 09:39:41 -0000 1.74
@@ -263,6 +263,19 @@
}
}
+void assert_all_pending_dns_resolves_ok(void) {
+ struct pending_connection_t *pend;
+ struct cached_resolve *resolve;
+
+ SPLAY_FOREACH(resolve, cache_tree, &cache_root) {
+ for(pend = resolve->pending_connections;
+ pend;
+ pend = pend->next) {
+ assert_connection_ok(pend->conn, 0);
+ }
+ }
+}
+
/* Cancel all pending connections. Then cancel the resolve itself,
* and remove the 'struct cached_resolve' from the cache.
*/
@@ -344,6 +357,7 @@
if (resolve->state != CACHE_STATE_PENDING) {
log_fn(LOG_WARN, "Resolved '%s' which was already resolved; ignoring",
address);
+ assert(resolve->pending_connections == NULL);
return;
}
/* Removed this assertion: in fact, we'll sometimes get a double answer
Index: main.c
===================================================================
RCS file: /home/or/cvsroot/src/or/main.c,v
retrieving revision 1.228
retrieving revision 1.229
diff -u -d -r1.228 -r1.229
--- main.c 7 Apr 2004 22:48:06 -0000 1.228
+++ main.c 9 Apr 2004 09:39:42 -0000 1.229
@@ -181,13 +181,14 @@
log_fn(LOG_DEBUG,"socket %d wants to read.",conn->s);
assert_connection_ok(conn, time(NULL));
+ assert_all_pending_dns_resolves_ok();
if(
- /* XXX does POLLHUP also mean it's definitely broken? */
+ /* XXX does POLLHUP also mean it's definitely broken? */
#ifdef MS_WINDOWS
- (poll_array[i].revents & POLLERR) ||
+ (poll_array[i].revents & POLLERR) ||
#endif
- connection_handle_read(conn) < 0) {
+ connection_handle_read(conn) < 0) {
if (!conn->marked_for_close) {
/* this connection is broken. remove it */
/* XXX This shouldn't ever happen anymore. */
@@ -196,8 +197,9 @@
CONN_TYPE_TO_STRING(conn->type), conn->s);
connection_mark_for_close(conn,0);
}
- }
- assert_connection_ok(conn, time(NULL));
+ }
+ assert_connection_ok(conn, time(NULL));
+ assert_all_pending_dns_resolves_ok();
}
static void conn_write(int i) {
@@ -212,6 +214,7 @@
return;
assert_connection_ok(conn, time(NULL));
+ assert_all_pending_dns_resolves_ok();
if (connection_handle_write(conn) < 0) {
if (!conn->marked_for_close) {
@@ -223,6 +226,7 @@
}
}
assert_connection_ok(conn, time(NULL));
+ assert_all_pending_dns_resolves_ok();
}
static void conn_close_if_marked(int i) {
@@ -231,6 +235,7 @@
conn = connection_array[i];
assert_connection_ok(conn, time(NULL));
+ assert_all_pending_dns_resolves_ok();
if(!conn->marked_for_close)
return; /* nothing to see here, move along */
@@ -446,7 +451,9 @@
if(now.tv_sec > current_second) { /* the second has rolled over. check more stuff. */
++stats_n_seconds_reading;
+ assert_all_pending_dns_resolves_ok();
run_scheduled_events(now.tv_sec);
+ assert_all_pending_dns_resolves_ok();
current_second = now.tv_sec; /* remember which second it is, for next time */
}
Index: or.h
===================================================================
RCS file: /home/or/cvsroot/src/or/or.h,v
retrieving revision 1.309
retrieving revision 1.310
diff -u -d -r1.309 -r1.310
--- or.h 8 Apr 2004 09:41:28 -0000 1.309
+++ or.h 9 Apr 2004 09:39:42 -0000 1.310
@@ -914,6 +914,7 @@
int connection_dns_process_inbuf(connection_t *conn);
void connection_dns_remove(connection_t *conn);
void assert_connection_edge_not_dns_pending(connection_t *conn);
+void assert_all_pending_dns_resolves_ok(void);
void dns_cancel_pending_resolve(char *question);
int dns_resolve(connection_t *exitconn);
More information about the tor-commits
mailing list