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.
This commit is contained in:
Nick Mathewson 2010-01-25 14:07:01 -05:00
parent 361da8f202
commit 439aea0d07

View File

@ -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;
}
}