From: Nick Mathewson Date: Mon, 25 Jan 2010 19:07:01 +0000 (-0500) Subject: Try to untangle the logic in server_port_flush(). X-Git-Tag: release-2.0.4-alpha~58 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=439aea0d072b98daf13ebe3d6eff8ab8ee5bd875;p=libevent 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. --- 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; } }