From fab091b9e1a38822ba12e428b7f6eb62c9a20f59 Mon Sep 17 00:00:00 2001 From: Bert Hubert Date: Tue, 10 Jul 2007 18:53:34 +0000 Subject: [PATCH] move tcp waits to poll instead of select git-svn-id: svn://svn.powerdns.com/pdns/trunk/pdns@1072 d19b8d6e-7fed-0310-83ef-9ca221ded41b --- pdns/misc.cc | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/pdns/misc.cc b/pdns/misc.cc index f7eea9e5f..f391b8e25 100644 --- a/pdns/misc.cc +++ b/pdns/misc.cc @@ -34,7 +34,7 @@ #include #include #include - +#include #include #include #include @@ -277,21 +277,18 @@ int waitForData(int fd, int seconds, int useconds) int waitForRWData(int fd, bool waitForRead, int seconds, int useconds) { - struct timeval tv; int ret; - tv.tv_sec = seconds; - tv.tv_usec = useconds; - - fd_set readfds, writefds; - FD_ZERO( &readfds ); - FD_ZERO( &writefds ); + struct pollfd pfd; + memset(&pfd, 0, sizeof(pfd)); + pfd.fd = fd; + if(waitForRead) - FD_SET( fd, &readfds ); + pfd.events=POLLIN; else - FD_SET( fd, &writefds ); + pfd.events=POLLOUT; - ret = select( fd + 1, &readfds, &writefds, NULL, &tv ); + ret = poll(&pfd, 1, seconds); if ( ret == -1 ) errno = ETIMEDOUT; -- 2.40.0