r851 - trunk/code/unix

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Thu Aug 17 22:10:02 EDT 2006


Author: thilo
Date: 2006-08-17 22:10:02 -0400 (Thu, 17 Aug 2006)
New Revision: 851

Modified:
   trunk/code/unix/unix_net.c
Log:
Tweak the select() stuff a bit still.


Modified: trunk/code/unix/unix_net.c
===================================================================
--- trunk/code/unix/unix_net.c	2006-08-18 01:50:51 UTC (rev 850)
+++ trunk/code/unix/unix_net.c	2006-08-18 02:10:02 UTC (rev 851)
@@ -651,7 +651,7 @@
 	struct timeval timeout;
 	fd_set	fdset;
 	extern qboolean stdin_active;
-	qboolean not_empty = qfalse;
+	int highestfd = 0;
 
 	if (!com_dedicated->integer)
 		return; // we're not a server, just run full speed
@@ -660,27 +660,27 @@
 	if (stdin_active)
 	{
 		FD_SET(0, &fdset); // stdin is processed too
-		not_empty = qtrue;
+		highestfd = 1;
 	}
 	if(ip_socket && com_sv_running->integer)
 	{
 		FD_SET(ip_socket, &fdset); // network socket
-		not_empty = qtrue;
+		if(ip_socket >= highestfd)
+			highestfd = ip_socket + 1;
 	}
 	
-	// There's no reason to call select() with an empty set.
-	if(not_empty)
+	if(highestfd)
 	{
 		if(msec >= 0)
 		{
 			timeout.tv_sec = msec/1000;
 			timeout.tv_usec = (msec%1000)*1000;
-			select(ip_socket+1, &fdset, NULL, NULL, &timeout);
+			select(highestfd, &fdset, NULL, NULL, &timeout);
 		}
 		else
 		{
 			// Block indefinitely
-			select(ip_socket+1, &fdset, NULL, NULL, NULL);
+			select(highestfd, &fdset, NULL, NULL, NULL);
 		}
 	}
 }




More information about the quake3-commits mailing list