From f8d7df859148905195054ed1255f46970039a34f Mon Sep 17 00:00:00 2001 From: Azat Khuzhin Date: Sat, 11 May 2013 03:53:11 +0400 Subject: [PATCH 1/2] Fix SEGFAULT after evdns_base_resume if no nameservers installed. If there is no nameservers installed, using evdns_base_nameserver_ip_add(), than evdns_base_resume() will SEGFAULT, because of NULL dereference in evdns_requests_pump_waiting_queue() Conflicts: evdns.c --- evdns.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/evdns.c b/evdns.c index e229ab94..085f7146 100644 --- a/evdns.c +++ b/evdns.c @@ -727,21 +727,28 @@ request_reissue(struct request *req) { /* this function looks for space on the inflight queue and promotes */ /* requests from the waiting queue if it can. */ +/* */ +/* TODO: */ +/* add return code, see at nameserver_pick() and other functions. */ static void evdns_requests_pump_waiting_queue(struct evdns_base *base) { ASSERT_LOCKED(base); while (base->global_requests_inflight < base->global_max_requests_inflight && base->global_requests_waiting) { struct request *req; - /* move a request from the waiting queue to the inflight queue */ + EVUTIL_ASSERT(base->req_waiting_head); req = base->req_waiting_head; + + req->ns = nameserver_pick(base); + if (!req->ns) + return; + evdns_request_remove(req, &base->req_waiting_head); base->global_requests_waiting--; base->global_requests_inflight++; - req->ns = nameserver_pick(base); request_trans_id_set(req, transaction_id_pick(base)); evdns_request_insert(req, &REQ_HEAD(base, req->trans_id)); @@ -2441,6 +2448,7 @@ evdns_base_resume(struct evdns_base *base) EVDNS_LOCK(base); evdns_requests_pump_waiting_queue(base); EVDNS_UNLOCK(base); + return 0; } From 363388a0435391abd805d3bcbc6c5365b1c44df5 Mon Sep 17 00:00:00 2001 From: Greg Hazel Date: Wed, 29 May 2013 14:19:14 -0700 Subject: [PATCH 2/2] restore the comment --- evdns.c | 1 + 1 file changed, 1 insertion(+) diff --git a/evdns.c b/evdns.c index 085f7146..2285eb7d 100644 --- a/evdns.c +++ b/evdns.c @@ -744,6 +744,7 @@ evdns_requests_pump_waiting_queue(struct evdns_base *base) { if (!req->ns) return; + /* move a request from the waiting queue to the inflight queue */ evdns_request_remove(req, &base->req_waiting_head); base->global_requests_waiting--;