summaryrefslogtreecommitdiffstats
path: root/net/sdl_net/files/patch-SDLnetselect.c
blob: b29640787a8367ef7e94fb766a6a72b4346e3cf2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29

$FreeBSD$

--- SDLnetselect.c	2001/07/25 09:44:01	1.1
+++ SDLnetselect.c	2001/07/25 09:45:57
@@ -175,6 +175,7 @@
 	SOCKET maxfd;
 	int retval;
 	struct timeval tv;
+	struct timeval *tmp;
 	fd_set mask;
 
 	/* Find the largest file descriptor */
@@ -199,8 +200,14 @@
 		tv.tv_sec = timeout/1000;
 		tv.tv_usec = (timeout%1000)*1000;
 
+		/* XXX: Workaround for a bug in FreeBSD - w/o it in some cases select() chews 100% CPU */
+		if (timeout == ~0)
+			tmp = NULL;
+		else
+			tmp = &tv;
+
 		/* Look! */
-		retval = select(maxfd+1, &mask, NULL, NULL, &tv);
+		retval = select(maxfd+1, &mask, NULL, NULL, tmp);
 	} while ( errno == EINTR );
 
 	/* Mark all file descriptors ready that have data available */
OpenPOWER on IntegriCloud