From 63504e9e80acb35666f8689526c67dd99c4fb3ba Mon Sep 17 00:00:00 2001 From: Kai Blin Date: Mon, 24 Mar 2008 13:12:49 +0100 Subject: [PATCH] janitorial: Use poll() instead of select(). --- dlls/netapi32/nbt.c | 18 +++++++++++++----- dlls/wininet/internet.c | 17 ++++++++++------- dlls/wininet/netconnection.c | 17 ++++++++++------- 3 files changed, 33 insertions(+), 19 deletions(-) diff --git a/dlls/netapi32/nbt.c b/dlls/netapi32/nbt.c index 1186572dab7..96309e40376 100644 --- a/dlls/netapi32/nbt.c +++ b/dlls/netapi32/nbt.c @@ -67,6 +67,15 @@ #include "config.h" #include +#ifdef HAVE_POLL_H +#include +#endif +#ifdef HAVE_SYS_POLL_H +# include +#endif +#ifdef HAVE_SYS_TIME_H +# include +#endif #include "winsock2.h" #include "windef.h" @@ -302,13 +311,12 @@ static UCHAR NetBTWaitForNameResponse(const NetBTAdapter *adapter, SOCKET fd, while (!found && ret == NRC_GOODRET && (now = GetTickCount()) < waitUntil) { DWORD msToWait = waitUntil - now; - struct fd_set fds; - struct timeval timeout = { msToWait / 1000, msToWait % 1000 }; + struct pollfd pfd; int r; - FD_ZERO(&fds); - FD_SET(fd, &fds); - r = select(fd + 1, &fds, NULL, NULL, &timeout); + pfd.fd = fd; + pfd.events = POLLIN; + r = poll(&pfd, 1, msToWait); if (r < 0) ret = NRC_SYSTEM; else if (r == 1) diff --git a/dlls/wininet/internet.c b/dlls/wininet/internet.c index a8ae808cc3c..be2fa9ce93f 100644 --- a/dlls/wininet/internet.c +++ b/dlls/wininet/internet.c @@ -38,6 +38,12 @@ #ifdef HAVE_SYS_SOCKET_H # include #endif +#ifdef HAVE_POLL_H +#include +#endif +#ifdef HAVE_SYS_POLL_H +# include +#endif #ifdef HAVE_SYS_TIME_H # include #endif @@ -3049,22 +3055,19 @@ LPSTR INTERNET_GetResponseBuffer(void) LPSTR INTERNET_GetNextLine(INT nSocket, LPDWORD dwLen) { - struct timeval tv; - fd_set infd; + struct pollfd pfd; BOOL bSuccess = FALSE; INT nRecv = 0; LPSTR lpszBuffer = INTERNET_GetResponseBuffer(); TRACE("\n"); - FD_ZERO(&infd); - FD_SET(nSocket, &infd); - tv.tv_sec=RESPONSE_TIMEOUT; - tv.tv_usec=0; + pfd.fd = nSocket; + pfd.events = POLLIN; while (nRecv < MAX_REPLY_LEN) { - if (select(nSocket+1,&infd,NULL,NULL,&tv) > 0) + if (poll(&pfd,1, RESPONSE_TIMEOUT * 1000) > 0) { if (recv(nSocket, &lpszBuffer[nRecv], 1, 0) <= 0) { diff --git a/dlls/wininet/netconnection.c b/dlls/wininet/netconnection.c index 07fb3decc96..63f3f8e5bef 100644 --- a/dlls/wininet/netconnection.c +++ b/dlls/wininet/netconnection.c @@ -23,6 +23,12 @@ #include "config.h" #include "wine/port.h" +#ifdef HAVE_POLL_H +#include +#endif +#ifdef HAVE_SYS_POLL_H +# include +#endif #ifdef HAVE_SYS_TIME_H # include #endif @@ -610,19 +616,16 @@ BOOL NETCON_getNextLine(WININET_NETCONNECTION *connection, LPSTR lpszBuffer, LPD if (!connection->useSSL) { - struct timeval tv; - fd_set infd; + struct pollfd pfd; BOOL bSuccess = FALSE; DWORD nRecv = 0; - FD_ZERO(&infd); - FD_SET(connection->socketFD, &infd); - tv.tv_sec=RESPONSE_TIMEOUT; - tv.tv_usec=0; + pfd.fd = connection->socketFD; + pfd.events = POLLIN; while (nRecv < *dwBuffer) { - if (select(connection->socketFD+1,&infd,NULL,NULL,&tv) > 0) + if (poll(&pfd,1, RESPONSE_TIMEOUT * 1000) > 0) { if (recv(connection->socketFD, &lpszBuffer[nRecv], 1, 0) <= 0) {