From 439aea0d072b98daf13ebe3d6eff8ab8ee5bd875 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Mon, 25 Jan 2010 14:07:01 -0500 Subject: [PATCH] Try to untangle the logic in server_port_flush(). The logic that prevented the first loop in this function from being infinite was rather confusing and hard to follow. It seems to confuse some automatic analysis tools as well as me. Let's try to replace it with something more comprehensible. --- evdns.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/evdns.c b/evdns.c index 29ea5432..6afe7557 100644 --- a/evdns.c +++ b/evdns.c @@ -1418,9 +1418,9 @@ server_port_read(struct evdns_server_port *s) { static void server_port_flush(struct evdns_server_port *port) { + struct server_request *req = port->pending_replies; ASSERT_LOCKED(port); - while (port->pending_replies) { - struct server_request *req = port->pending_replies; + while (req) { int r = sendto(port->socket, req->response, req->response_len, 0, (struct sockaddr*) &req->addr, req->addrlen); if (r < 0) { @@ -1432,6 +1432,9 @@ server_port_flush(struct evdns_server_port *port) if (server_request_free(req)) { /* we released the last reference to req->port. */ return; + } else { + EVUTIL_ASSERT(req != port->pending_replies); + req = port->pending_replies; } }