Merge remote-tracking branch 'public/pr/79' into patches-2.0

This commit is contained in:
Nick Mathewson 2013-06-10 15:16:13 -04:00
commit 387e6b90c3

13
evdns.c
View File

@ -727,21 +727,29 @@ 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;
/* move a request from the waiting queue to the inflight queue */
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 +2449,7 @@ evdns_base_resume(struct evdns_base *base)
EVDNS_LOCK(base);
evdns_requests_pump_waiting_queue(base);
EVDNS_UNLOCK(base);
return 0;
}