Loading ares/ares_getsock.c +11 −5 Original line number Diff line number Diff line Loading @@ -34,16 +34,18 @@ int ares_getsock(ares_channel channel, ares_socket_t *socks = (ares_socket_t *)s; /* No queries, no file descriptors. */ if (ares__is_list_empty(&(channel->all_queries))) return 0; /* Are there any active queries? */ int active_queries = !ares__is_list_empty(&(channel->all_queries)); for (i = 0; (i < channel->nservers) && (sockindex < ARES_GETSOCK_MAXNUM); i++) { server = &channel->servers[i]; if (server->udp_socket != ARES_SOCKET_BAD) /* We only need to register interest in UDP sockets if we have * outstanding queries. */ if (active_queries && server->udp_socket != ARES_SOCKET_BAD) { if(sockindex >= numsocks) break; Loading @@ -51,6 +53,10 @@ int ares_getsock(ares_channel channel, bitmap |= ARES_GETSOCK_READABLE(setbits, sockindex); sockindex++; } /* We always register for TCP events, because we want to know * when the other side closes the connection, so we don't waste * time trying to use a broken connection. */ if (server->tcp_socket != ARES_SOCKET_BAD) { if(sockindex >= numsocks) Loading @@ -58,7 +64,7 @@ int ares_getsock(ares_channel channel, socks[sockindex] = server->tcp_socket; bitmap |= ARES_GETSOCK_READABLE(setbits, sockindex); if (server->qhead) if (server->qhead && active_queries) /* then the tcp socket is also writable! */ bitmap |= ARES_GETSOCK_WRITABLE(setbits, sockindex); Loading Loading
ares/ares_getsock.c +11 −5 Original line number Diff line number Diff line Loading @@ -34,16 +34,18 @@ int ares_getsock(ares_channel channel, ares_socket_t *socks = (ares_socket_t *)s; /* No queries, no file descriptors. */ if (ares__is_list_empty(&(channel->all_queries))) return 0; /* Are there any active queries? */ int active_queries = !ares__is_list_empty(&(channel->all_queries)); for (i = 0; (i < channel->nservers) && (sockindex < ARES_GETSOCK_MAXNUM); i++) { server = &channel->servers[i]; if (server->udp_socket != ARES_SOCKET_BAD) /* We only need to register interest in UDP sockets if we have * outstanding queries. */ if (active_queries && server->udp_socket != ARES_SOCKET_BAD) { if(sockindex >= numsocks) break; Loading @@ -51,6 +53,10 @@ int ares_getsock(ares_channel channel, bitmap |= ARES_GETSOCK_READABLE(setbits, sockindex); sockindex++; } /* We always register for TCP events, because we want to know * when the other side closes the connection, so we don't waste * time trying to use a broken connection. */ if (server->tcp_socket != ARES_SOCKET_BAD) { if(sockindex >= numsocks) Loading @@ -58,7 +64,7 @@ int ares_getsock(ares_channel channel, socks[sockindex] = server->tcp_socket; bitmap |= ARES_GETSOCK_READABLE(setbits, sockindex); if (server->qhead) if (server->qhead && active_queries) /* then the tcp socket is also writable! */ bitmap |= ARES_GETSOCK_WRITABLE(setbits, sockindex); Loading