[or-cvs] r6961: documentation and naming tweaks in dns.c (in tor/trunk: . src/or)
nickm at seul.org
nickm at seul.org
Mon Jul 31 18:01:49 UTC 2006
Author: nickm
Date: 2006-07-31 14:01:49 -0400 (Mon, 31 Jul 2006)
New Revision: 6961
Modified:
tor/trunk/
tor/trunk/src/or/dns.c
Log:
r6982 at Kushana: nickm | 2006-07-31 13:47:19 -0400
documentation and naming tweaks in dns.c
Property changes on: tor/trunk
___________________________________________________________________
Name: svk:merge
- c95137ef-5f19-0410-b913-86e773d04f59:/tor/branches/eventdns:6981
c95137ef-5f19-0410-b913-86e773d04f59:/tor/branches/oo-connections:6950
+ c95137ef-5f19-0410-b913-86e773d04f59:/tor/branches/eventdns:6982
c95137ef-5f19-0410-b913-86e773d04f59:/tor/branches/oo-connections:6950
Modified: tor/trunk/src/or/dns.c
===================================================================
--- tor/trunk/src/or/dns.c 2006-07-31 18:01:45 UTC (rev 6960)
+++ tor/trunk/src/or/dns.c 2006-07-31 18:01:49 UTC (rev 6961)
@@ -36,7 +36,8 @@
/** If more than this many processes are idle, shut down the extras. */
#define MAX_IDLE_DNSWORKERS 10
-/** DOCDCOC */
+/** How long will we wait for an answer from the resolver before we decide
+ * that the resolver is wedged? */
#define RESOLVE_MAX_TIMEOUT 300
/** Possible outcomes from hostname lookup: permanent failure,
@@ -62,10 +63,23 @@
#define CACHED_RESOLVE_MAGIC 0x1234F00D
-/* DOCDOC */
+/* Possible states for a cached resolve_t */
+/** We are waiting for the resolver system to tell us an answer here.
+ * When we get one, or when we time out, the state of this cached_resolve_t
+ * will become "DONE" and we'll possibly add a CACHED_VALID or a CACHED_FAILED
+ * entry. This cached_resolve_t will be in the hash table so that we will
+ * know not to launch more requests for this addr, but rather to add more
+ * connections to the pending list for the addr. */
#define CACHE_STATE_PENDING 0
+/** This used to be a pending cached_resolve_t, and we got an answer for it.
+ * Now we're waiting for this cached_resolve_t to expire. This should
+ * have no pending connections, and should not appear in the hash table. */
#define CACHE_STATE_DONE 1
+/** We are caching an answer for this address. This should have no pending
+ * connections, and should appear in the hash table. */
#define CACHE_STATE_CACHED_VALID 2
+/** We are caching a failure for this address. This should have no pending
+ * connections, and should appear in the hash table */
#define CACHE_STATE_CACHED_FAILED 3
/** A DNS request: possibly completed, possibly pending; cached_resolve
@@ -88,7 +102,7 @@
static void dns_found_answer(const char *address, uint32_t addr, char outcome,
uint32_t ttl);
static void send_resolved_cell(edge_connection_t *conn, uint8_t answer_type);
-static int assign_to_dnsworker(edge_connection_t *exitconn);
+static int launch_resolve(edge_connection_t *exitconn);
#ifndef USE_EVENTDNS
static int dnsworker_main(void *data);
static int spawn_dnsworker(void);
@@ -206,7 +220,9 @@
tor_free(r);
}
-/** DODDOC */
+/** Compare two cached_resolve_t pointers by expiry time, and return
+ * less-than-zero, zero, or greater-than-zero as appropriate. Used for
+ * the priority queue implementation. */
static int
_compare_cached_resolves_by_expiry(const void *_a, const void *_b)
{
@@ -219,9 +235,12 @@
return 1;
}
-/** Linked list of resolved addresses, oldest to newest. DOCDOC*/
+/** Priority queue of cached_resolve_t objects to let us know when they
+ * will expire. */
static smartlist_t *cached_resolve_pqueue = NULL;
+/** Set an expiry time for a cached_resolve_t, and add it to the expiry
+ * priority queue */
static void
set_expiry(cached_resolve_t *resolve, time_t expires)
{
@@ -318,6 +337,7 @@
resolve->magic = 0xF0BBF0BB;
tor_free(resolve);
} else {
+ /* This should be in state DONE. Make sure it's not in the cache. */
cached_resolve_t *tmp = HT_FIND(cache_map, &cache_root, resolve);
tor_assert(tmp != resolve);
}
@@ -467,10 +487,10 @@
HT_INSERT(cache_map, &cache_root, resolve);
set_expiry(resolve, now + RESOLVE_MAX_TIMEOUT);
- log_debug(LD_EXIT,"Assigning question %s to dnsworker.",
+ log_debug(LD_EXIT,"Launching %s.",
escaped_safe_str(exitconn->_base.address));
assert_cache_ok();
- return assign_to_dnsworker(exitconn);
+ return launch_resolve(exitconn);
}
/** Log an error and abort if conn is waiting for a DNS resolve.
@@ -762,7 +782,7 @@
* <b>exitconn</b>-\>address; tell that dns worker to begin resolving.
*/
static int
-assign_to_dnsworker(edge_connection_t *exitconn)
+lauch_resolve(edge_connection_t *exitconn)
{
connection_t *dnsconn;
unsigned char len;
@@ -1211,7 +1231,7 @@
}
static int
-assign_to_dnsworker(edge_connection_t *exitconn)
+launch_resolve(edge_connection_t *exitconn)
{
char *addr = tor_strdup(exitconn->_base.address);
int r;
More information about the tor-commits
mailing list