mirror of
https://github.com/libevent/libevent.git
synced 2025-01-31 09:12:55 +08:00
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
This commit is contained in:
parent
e826f19e05
commit
f8d7df8591
12
evdns.c
12
evdns.c
@ -727,21 +727,28 @@ request_reissue(struct request *req) {
|
|||||||
|
|
||||||
/* this function looks for space on the inflight queue and promotes */
|
/* this function looks for space on the inflight queue and promotes */
|
||||||
/* requests from the waiting queue if it can. */
|
/* requests from the waiting queue if it can. */
|
||||||
|
/* */
|
||||||
|
/* TODO: */
|
||||||
|
/* add return code, see at nameserver_pick() and other functions. */
|
||||||
static void
|
static void
|
||||||
evdns_requests_pump_waiting_queue(struct evdns_base *base) {
|
evdns_requests_pump_waiting_queue(struct evdns_base *base) {
|
||||||
ASSERT_LOCKED(base);
|
ASSERT_LOCKED(base);
|
||||||
while (base->global_requests_inflight < base->global_max_requests_inflight &&
|
while (base->global_requests_inflight < base->global_max_requests_inflight &&
|
||||||
base->global_requests_waiting) {
|
base->global_requests_waiting) {
|
||||||
struct request *req;
|
struct request *req;
|
||||||
/* move a request from the waiting queue to the inflight queue */
|
|
||||||
EVUTIL_ASSERT(base->req_waiting_head);
|
EVUTIL_ASSERT(base->req_waiting_head);
|
||||||
req = 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);
|
evdns_request_remove(req, &base->req_waiting_head);
|
||||||
|
|
||||||
base->global_requests_waiting--;
|
base->global_requests_waiting--;
|
||||||
base->global_requests_inflight++;
|
base->global_requests_inflight++;
|
||||||
|
|
||||||
req->ns = nameserver_pick(base);
|
|
||||||
request_trans_id_set(req, transaction_id_pick(base));
|
request_trans_id_set(req, transaction_id_pick(base));
|
||||||
|
|
||||||
evdns_request_insert(req, &REQ_HEAD(base, req->trans_id));
|
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_LOCK(base);
|
||||||
evdns_requests_pump_waiting_queue(base);
|
evdns_requests_pump_waiting_queue(base);
|
||||||
EVDNS_UNLOCK(base);
|
EVDNS_UNLOCK(base);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user