From 4e62f09c50f1f4a5cecf5bc979101903e0a8c67f Mon Sep 17 00:00:00 2001 From: Tim Angus Date: Wed, 28 Dec 2005 19:04:39 +0000 Subject: * Use select instead of poll for the master server -- apparently windows has no poll implementation --- src/master/master.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'src/master') 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 #include -#include #ifndef WIN32 # include @@ -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); -- cgit