summaryrefslogtreecommitdiff
path: root/src/or/dns.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2004-02-27 22:00:26 +0000
committerNick Mathewson <nickm@torproject.org>2004-02-27 22:00:26 +0000
commitc5bbb571d2a27d0b81bfe7a1d374ba965497f267 (patch)
tree81bf23633d8fe4a1da845f097bd52a6ae83340ae /src/or/dns.c
parent58a7bfab81eeb707b1251df8e525e5b7b7365272 (diff)
downloadtor-c5bbb571d2a27d0b81bfe7a1d374ba965497f267.tar.gz
tor-c5bbb571d2a27d0b81bfe7a1d374ba965497f267.zip
Refactor mark_for_close, connection_edge_end and friends. Now, everybody
who wants to shut down a connection calls connection_mark_for_close instead of setting marked_for_close to 1. This automatically removes the connection from the DNS cache if needed, sends a RELAY END cell if appropriate, and can be changed to do whatever else is needed. Still to do: - The same for circuits, maybe. - Add some kind of hold_connection_open_until_flushed flag, maybe. - Change stuff that closes connections with return -1 to use mark_for_close, maybe. svn:r1145
Diffstat (limited to 'src/or/dns.c')
-rw-r--r--src/or/dns.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/src/or/dns.c b/src/or/dns.c
index f8aa7e0f07..ce3e212c65 100644
--- a/src/or/dns.c
+++ b/src/or/dns.c
@@ -236,8 +236,7 @@ void dns_cancel_pending_resolve(char *address, connection_t *onlyconn) {
address);
while(resolve->pending_connections) {
pend = resolve->pending_connections;
- if(connection_edge_end(pend->conn, END_STREAM_REASON_MISC, NULL) < 0)
- log_fn(LOG_WARN,"1: I called connection_edge_end redundantly.");
+ connection_mark_for_close(pend->conn, END_STREAM_REASON_MISC);
resolve->pending_connections = pend->next;
free(pend);
}
@@ -302,8 +301,7 @@ static void dns_found_answer(char *address, uint32_t addr) {
assert_connection_ok(pend->conn,0);
pend->conn->addr = resolve->addr;
if(resolve->state == CACHE_STATE_FAILED) {
- if(connection_edge_end(pend->conn, END_STREAM_REASON_RESOLVEFAILED, NULL) < 0)
- log_fn(LOG_WARN,"1: I called connection_edge_end redundantly.");
+ connection_mark_for_close(pend->conn, END_STREAM_REASON_RESOLVEFAILED);
} else {
assert_connection_ok(pend->conn, time(NULL));
connection_exit_connect(pend->conn);
@@ -457,10 +455,8 @@ static void spawn_enough_dnsworkers(void) {
log_fn(LOG_WARN, "%d DNS workers are spawned; all are busy. Killing one.",
MAX_DNSWORKERS);
- /* tell the exit connection that it's failed */
- dns_cancel_pending_resolve(dnsconn->address, NULL);
- dnsconn->marked_for_close = 1;
+ connection_mark_for_close(dnsconn,0);
num_dnsworkers_busy--;
num_dnsworkers--;
}
@@ -484,7 +480,7 @@ static void spawn_enough_dnsworkers(void) {
num_dnsworkers-num_dnsworkers_needed, num_dnsworkers);
dnsconn = connection_get_by_type_state(CONN_TYPE_DNSWORKER, DNSWORKER_STATE_IDLE);
assert(dnsconn);
- dnsconn->marked_for_close = 1;
+ connection_mark_for_close(dnsconn,0);
num_dnsworkers--;
}
}