Kai Blin : janitorial: Use poll() instead of select().
Alexandre Julliard
julliard at winehq.org
Mon Mar 24 07:55:15 CDT 2008
Module: wine
Branch: master
Commit: 63504e9e80acb35666f8689526c67dd99c4fb3ba
URL: http://source.winehq.org/git/wine.git/?a=commit;h=63504e9e80acb35666f8689526c67dd99c4fb3ba
Author: Kai Blin <kai.blin at gmail.com>
Date: Mon Mar 24 13:12:49 2008 +0100
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 1186572..96309e4 100644
--- a/dlls/netapi32/nbt.c
+++ b/dlls/netapi32/nbt.c
@@ -67,6 +67,15 @@
#include "config.h"
#include <stdarg.h>
+#ifdef HAVE_POLL_H
+#include <poll.h>
+#endif
+#ifdef HAVE_SYS_POLL_H
+# include <sys/poll.h>
+#endif
+#ifdef HAVE_SYS_TIME_H
+# include <sys/time.h>
+#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 a8ae808..be2fa9c 100644
--- a/dlls/wininet/internet.c
+++ b/dlls/wininet/internet.c
@@ -38,6 +38,12 @@
#ifdef HAVE_SYS_SOCKET_H
# include <sys/socket.h>
#endif
+#ifdef HAVE_POLL_H
+#include <poll.h>
+#endif
+#ifdef HAVE_SYS_POLL_H
+# include <sys/poll.h>
+#endif
#ifdef HAVE_SYS_TIME_H
# include <sys/time.h>
#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 07fb3de..63f3f8e 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 <poll.h>
+#endif
+#ifdef HAVE_SYS_POLL_H
+# include <sys/poll.h>
+#endif
#ifdef HAVE_SYS_TIME_H
# include <sys/time.h>
#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)
{
More information about the wine-cvs
mailing list