Read and process as many packets as possible in read_udp_packets, to avoid having to run the entire event loop once per packet. (Patch from the Google tree.)

This commit is contained in:
Steinar H. Gunderson
2007-09-29 14:21:47 +00:00
parent c1a475e708
commit c788efffd4

View File

@@ -399,13 +399,17 @@ static void read_udp_packets(ares_channel channel, fd_set *read_fds,
* extra system calls and confusion. */ * extra system calls and confusion. */
FD_CLR(server->udp_socket, read_fds); FD_CLR(server->udp_socket, read_fds);
count = sread(server->udp_socket, buf, sizeof(buf)); /* To reduce event loop overhead, read and process as many
if (count == -1 && try_again(SOCKERRNO)) * packets as we can. */
continue; do {
else if (count <= 0) count = sread(server->udp_socket, buf, sizeof(buf));
handle_error(channel, i, now); if (count == -1 && try_again(SOCKERRNO))
continue;
process_answer(channel, buf, (int)count, i, 0, now); else if (count <= 0)
handle_error(channel, i, now);
else
process_answer(channel, buf, (int)count, i, 0, now);
} while (count > 0);
} }
} }