summaryrefslogtreecommitdiff
path: root/evdns.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2012-07-30 17:08:44 -0400
committerNick Mathewson <nickm@torproject.org>2012-07-30 17:08:44 -0400
commit9be8624b2f5633bfa0dc30ae4b6d22312373ef3f (patch)
tree8ffe53d39f6070b1345ac00603110199f140b113 /evdns.c
parent737f113a328cdf9fe5f718163882f0225052bed4 (diff)
parentdc3207767d4f06b3179a3238adc44e3043ccd65b (diff)
downloadlibevent-9be8624b2f5633bfa0dc30ae4b6d22312373ef3f.tar.gz
Merge remote-tracking branch 'origin/patches-2.0'
Diffstat (limited to 'evdns.c')
-rw-r--r--evdns.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/evdns.c b/evdns.c
index d32ea46c..f3a278dd 100644
--- a/evdns.c
+++ b/evdns.c
@@ -4218,6 +4218,8 @@ evdns_getaddrinfo_timeout_cb(evutil_socket_t fd, short what, void *ptr)
/* Cancel any pending requests, and note which one */
if (data->ipv4_request.r) {
+ /* XXXX This does nothing if the request's callback is already
+ * running (pending_cb is set). */
evdns_cancel_request(NULL, data->ipv4_request.r);
v4_timedout = 1;
EVDNS_LOCK(data->evdns_base);
@@ -4225,6 +4227,8 @@ evdns_getaddrinfo_timeout_cb(evutil_socket_t fd, short what, void *ptr)
EVDNS_UNLOCK(data->evdns_base);
}
if (data->ipv6_request.r) {
+ /* XXXX This does nothing if the request's callback is already
+ * running (pending_cb is set). */
evdns_cancel_request(NULL, data->ipv6_request.r);
v6_timedout = 1;
EVDNS_LOCK(data->evdns_base);
@@ -4248,6 +4252,10 @@ evdns_getaddrinfo_timeout_cb(evutil_socket_t fd, short what, void *ptr)
data->user_cb(e, NULL, data->user_data);
}
+ data->user_cb = NULL; /* prevent double-call if evdns callbacks are
+ * in-progress. XXXX It would be better if this
+ * weren't necessary. */
+
if (!v4_timedout && !v6_timedout) {
/* should be impossible? XXXX */
free_getaddrinfo_request(data);
@@ -4318,6 +4326,13 @@ evdns_getaddrinfo_gotresolve(int result, char type, int count,
return;
}
+ if (data->user_cb == NULL) {
+ /* We already answered. XXXX This shouldn't be needed; see
+ * comments in evdns_getaddrinfo_timeout_cb */
+ free_getaddrinfo_request(data);
+ return;
+ }
+
if (result == DNS_ERR_NONE) {
if (count == 0)
err = EVUTIL_EAI_NODATA;