[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] Clean up dns->connection_mark_for_close->dns_remove path
Update of /home/or/cvsroot/src/or
In directory moria.mit.edu:/tmp/cvs-serv1412/src/or
Modified Files:
dns.c
Log Message:
Clean up dns->connection_mark_for_close->dns_remove path
Index: dns.c
===================================================================
RCS file: /home/or/cvsroot/src/or/dns.c,v
retrieving revision 1.60
retrieving revision 1.61
diff -u -d -r1.60 -r1.61
--- dns.c 28 Feb 2004 22:34:47 -0000 1.60
+++ dns.c 4 Mar 2004 18:43:44 -0000 1.61
@@ -86,7 +86,7 @@
if(!oldest_cached_resolve) /* if there are no more, */
newest_cached_resolve = NULL; /* then make sure the list's tail knows that too */
SPLAY_REMOVE(cache_tree, &cache_root, resolve);
- free(resolve);
+ tor_free(resolve);
}
}
@@ -146,7 +146,7 @@
/* add us to the pending list */
pending_connection = tor_malloc(sizeof(struct pending_connection_t));
pending_connection->conn = exitconn;
- pending_connection->next = resolve->pending_connections;
+ pending_connection->next = NULL;
resolve->pending_connections = pending_connection;
/* add us to the linked list of resolves */
@@ -178,7 +178,7 @@
log_fn(LOG_DEBUG, "Connection (fd %d) needs to resolve '%s'; assigning to DNSWorker (fd %d)",
exitconn->s, exitconn->address, dnsconn->s);
- free(dnsconn->address);
+ tor_free(dnsconn->address);
dnsconn->address = tor_strdup(exitconn->address);
dnsconn->state = DNSWORKER_STATE_BUSY;
num_dnsworkers_busy++;
@@ -213,7 +213,7 @@
if(pend->conn == conn) {
resolve->pending_connections = pend->next;
- free(pend);
+ tor_free(pend);
log_fn(LOG_DEBUG, "Connection (fd %d) no longer waiting for resolve of '%s'",
conn->s, conn->address);
return;
@@ -222,7 +222,7 @@
if(pend->next->conn == conn) {
victim = pend->next;
pend->next = victim->next;
- free(victim);
+ tor_free(victim);
log_fn(LOG_DEBUG, "Connection (fd %d) no longer waiting for resolve of '%s'",
conn->s, conn->address);
return; /* more are pending */
@@ -256,11 +256,11 @@
address);
while(resolve->pending_connections) {
pend = resolve->pending_connections;
- /* This calls dns_cancel_pending_resolve, which removes pend
- * from the list, so we don't have to do it. Beware of
- * modify-while-iterating bugs hereabouts! */
+ /* So that mark_for_close doesn't double-remove the connection. */
+ pend->conn->state = EXIT_CONN_STATE_RESOLVEFAILED;
connection_mark_for_close(pend->conn, END_STREAM_REASON_MISC);
- assert(resolve->pending_connections != pend);
+ resolve->pending_connections = pend->next;
+ tor_free(pend);
}
/* remove resolve from the linked list */
@@ -281,7 +281,7 @@
/* remove resolve from the tree */
SPLAY_REMOVE(cache_tree, &cache_root, resolve);
- free(resolve);
+ tor_free(resolve);
}
static void dns_found_answer(char *address, uint32_t addr) {
@@ -322,16 +322,14 @@
assert_connection_ok(pend->conn,time(NULL));
pend->conn->addr = resolve->addr;
if(resolve->state == CACHE_STATE_FAILED) {
- /* This calls dns_cancel_pending_resolve, which removes pend
- * from the list, so we don't have to do it. Beware of
- * modify-while-iterating bugs hereabouts! */
+ /* prevent double-remove */
+ pend->conn->state = EXIT_CONN_STATE_RESOLVEFAILED;
connection_mark_for_close(pend->conn, END_STREAM_REASON_RESOLVEFAILED);
- assert(resolve->pending_connections != pend);
} else {
connection_exit_connect(pend->conn);
- resolve->pending_connections = pend->next;
- free(pend);
}
+ resolve->pending_connections = pend->next;
+ tor_free(pend);
}
}
@@ -371,7 +369,7 @@
dns_found_answer(conn->address, addr);
- free(conn->address);
+ tor_free(conn->address);
conn->address = tor_strdup("<idle>");
conn->state = DNSWORKER_STATE_IDLE;
num_dnsworkers_busy--;