summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Angus <tim@ngus.net>2005-12-28 19:04:39 +0000
committerTim Angus <tim@ngus.net>2005-12-28 19:04:39 +0000
commit4e62f09c50f1f4a5cecf5bc979101903e0a8c67f (patch)
tree619b1fa9ba35caac507888fefc1129d52256bb6d
parent1dc7e94283f026b17c1e793cbf7542872812ffda (diff)
* Use select instead of poll for the master server -- apparently windows has no
poll implementation
-rw-r--r--src/master/master.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/master/master.c b/src/master/master.c
index 1158e59e..47ece021 100644
--- a/src/master/master.c
+++ b/src/master/master.c
@@ -23,7 +23,6 @@
#include <stdarg.h>
#include <signal.h>
-#include <sys/poll.h>
#ifndef WIN32
# include <pwd.h>
@@ -535,7 +534,9 @@ int main (int argc, const char* argv [])
int nb_bytes;
char packet [MAX_PACKET_SIZE + 1]; // "+ 1" because we append a '\0'
qboolean valid_options;
- struct pollfd socket_poll;
+ fd_set rfds;
+ struct timeval tv;
+
signal( SIGINT, cleanUp );
signal( SIGTERM, cleanUp );
@@ -558,16 +559,19 @@ int main (int argc, const char* argv [])
return EXIT_FAILURE;
MsgPrint (MSG_NORMAL, "\n");
- memset( &socket_poll, 0, sizeof( struct pollfd ) );
- socket_poll.fd = sock;
- socket_poll.events = POLLIN;
-
// Until the end of times...
while( !exitNow )
{
+ FD_ZERO( &rfds );
+ FD_SET( sock, &rfds );
+ tv.tv_sec = tv.tv_usec = 0;
+
// Check for new data every 100ms
- if( poll( &socket_poll, 1, 100 ) <= 0 )
+ if( select( sock + 1, &rfds, NULL, NULL, &tv ) <= 0 )
+ {
+ usleep( 100000 );
continue;
+ }
// Get the next valid message
addrlen = sizeof (address);