aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2008-02-05 21:39:40 +0000
committerNick Mathewson <nickm@torproject.org>2008-02-05 21:39:40 +0000
commitc11c48fc783305fbb3a1b446b35dc3d9602d4bbe (patch)
tree82a480985d9d4b29f7033c777031d77b44f108cb /src
parentbd5bcbdc091dc40fe1337aeb45852c60343a92bf (diff)
downloadtor-c11c48fc783305fbb3a1b446b35dc3d9602d4bbe.tar.gz
tor-c11c48fc783305fbb3a1b446b35dc3d9602d4bbe.zip
r17913@catbus: nickm | 2008-02-05 16:11:33 -0500
Correctly register failures in connection_add() in dnsserv_launch_request() svn:r13387
Diffstat (limited to 'src')
-rw-r--r--src/or/control.c15
-rw-r--r--src/or/dnsserv.c10
-rw-r--r--src/or/or.h2
3 files changed, 18 insertions, 9 deletions
diff --git a/src/or/control.c b/src/or/control.c
index 31c88580df..afb88d2a9b 100644
--- a/src/or/control.c
+++ b/src/or/control.c
@@ -2439,7 +2439,7 @@ static int
handle_control_resolve(control_connection_t *conn, uint32_t len,
const char *body)
{
- smartlist_t *args;
+ smartlist_t *args, *failed;
int is_reverse = 0;
(void) len; /* body is nul-terminated; it's safe to ignore the length */
@@ -2458,14 +2458,21 @@ handle_control_resolve(control_connection_t *conn, uint32_t len,
tor_free(cp);
is_reverse = 1;
}
+ failed = smartlist_create();
SMARTLIST_FOREACH(args, const char *, arg, {
- dnsserv_launch_request(arg, is_reverse);
+ if (dnsserv_launch_request(arg, is_reverse)<0)
+ smartlist_add(failed, (char*)arg);
+ });
+
+ send_control_done(conn);
+ SMARTLIST_FOREACH(failed, const char *, arg, {
+ control_event_address_mapped(arg, arg, time(NULL),
+ "Unable to launch resolve request");
});
SMARTLIST_FOREACH(args, char *, cp, tor_free(cp));
smartlist_free(args);
-
- send_control_done(conn);
+ smartlist_free(failed);
return 0;
}
diff --git a/src/or/dnsserv.c b/src/or/dnsserv.c
index d1e6219a94..d2b5bacc79 100644
--- a/src/or/dnsserv.c
+++ b/src/or/dnsserv.c
@@ -47,7 +47,7 @@ evdns_server_callback(struct evdns_server_request *req, void *_data)
(void) addrlen;
sa = (struct sockaddr*) &addr;
if (sa->sa_family != AF_INET) {
- /* XXXX020 Handle IPV6 */
+ /* XXXX_IP6 Handle IPV6 */
log_warn(LD_APP, "Requesting address wasn't ipv4.");
evdns_server_request_respond(req, DNS_ERR_SERVERFAILED);
return;
@@ -155,8 +155,10 @@ evdns_server_callback(struct evdns_server_request *req, void *_data)
/* Helper function: called whenever the client sends a resolve request to our
* controller. We need to eventually answer the request <b>req</b>.
+ * Returns 0 if the controller will be getting (or has gotten) an event in
+ * response; -1 if we couldn't launch the request.
*/
-void
+int
dnsserv_launch_request(const char *name, int reverse)
{
edge_connection_t *conn;
@@ -178,9 +180,8 @@ dnsserv_launch_request(const char *name, int reverse)
if (connection_add(TO_CONN(conn))<0) {
log_warn(LD_APP, "Couldn't register dummy connection for RESOLVE request");
- /* XXXX020 Answer the controller. */
connection_free(TO_CONN(conn));
- return;
+ return -1;
}
/* Now, throw the connection over to get rewritten (which will answer it
@@ -195,6 +196,7 @@ dnsserv_launch_request(const char *name, int reverse)
log_info(LD_APP, "Passed request for %s to rewrite_and_attach.",
escaped_safe_str(q_name));
tor_free(q_name);
+ return 0;
}
/** If there is a pending request on <b>conn</b> that's waiting for an answer,
diff --git a/src/or/or.h b/src/or/or.h
index a1aea43901..eca2c8da64 100644
--- a/src/or/or.h
+++ b/src/or/or.h
@@ -3221,7 +3221,7 @@ void dnsserv_resolved(edge_connection_t *conn,
const char *answer,
int ttl);
void dnsserv_reject_request(edge_connection_t *conn);
-void dnsserv_launch_request(const char *name, int is_reverse);
+int dnsserv_launch_request(const char *name, int is_reverse);
/********************************* geoip.c **************************/