From d825b5e2cb960fdc348d068a7af3ffbd54cc1c3f Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Thu, 10 Feb 2011 11:01:54 +0100 Subject: s3: Eliminate select from libaddns --- lib/addns/dnssock.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) (limited to 'lib/addns') diff --git a/lib/addns/dnssock.c b/lib/addns/dnssock.c index 7c8bd418e5..42b4e2d40f 100644 --- a/lib/addns/dnssock.c +++ b/lib/addns/dnssock.c @@ -22,9 +22,11 @@ License along with this library; if not, see . */ +#include "replace.h" #include "dns.h" #include #include +#include "system/select.h" static int destroy_dns_connection(struct dns_connection *conn) { @@ -103,7 +105,7 @@ static DNS_ERROR dns_udp_open( const char *nameserver, } memcpy( &ulAddress, pHost->h_addr, pHost->h_length ); } - + /* Create a socket for sending data */ conn->s = socket( AF_INET, SOCK_DGRAM, IPPROTO_UDP ); @@ -143,7 +145,7 @@ DNS_ERROR dns_open_connection( const char *nameserver, int32 dwType, case DNS_UDP: return dns_udp_open( nameserver, mem_ctx, conn ); } - + return ERROR_DNS_INVALID_PARAMETER; } @@ -212,21 +214,17 @@ DNS_ERROR dns_send(struct dns_connection *conn, const struct dns_buffer *buf) static DNS_ERROR read_all(int fd, uint8 *data, size_t len) { size_t total = 0; - fd_set rfds; - struct timeval tv; while (total < len) { + struct pollfd pfd; ssize_t ret; int fd_ready; - - FD_ZERO( &rfds ); - FD_SET( fd, &rfds ); - - /* 10 second timeout */ - tv.tv_sec = 10; - tv.tv_usec = 0; - - fd_ready = select( fd+1, &rfds, NULL, NULL, &tv ); + + ZERO_STRUCT(pfd); + pfd.fd = fd; + pfd.events = POLLIN|POLLHUP; + + fd_ready = poll(&pfd, 1, 10000); if ( fd_ready == 0 ) { /* read timeout */ return ERROR_DNS_SOCKET_ERROR; -- cgit