helps if one groks select semantics :/

This commit is contained in:
Bill Currie 2000-12-29 06:19:44 +00:00
parent 73980fe852
commit 2695ec4990

View file

@ -168,15 +168,11 @@ main
int int
main (int argc, char *argv[]) main (int argc, char *argv[])
{ {
static struct timeval _timeout;
double time, oldtime, newtime; double time, oldtime, newtime;
fd_set fdset; fd_set fdset;
extern int net_socket; extern int net_socket;
int j; int j;
_timeout.tv_sec = 1;
_timeout.tv_usec = 0;
memset (&host_parms, 0, sizeof (host_parms)); memset (&host_parms, 0, sizeof (host_parms));
COM_InitArgv (argc, argv); COM_InitArgv (argc, argv);
@ -201,6 +197,7 @@ main (int argc, char *argv[])
// //
oldtime = Sys_DoubleTime () - 0.1; oldtime = Sys_DoubleTime () - 0.1;
while (1) { while (1) {
struct timeval _timeout;
struct timeval *timeout = 0; struct timeval *timeout = 0;
// select on the net socket and stdin // select on the net socket and stdin
// the only reason we have a timeout at all is so that if the last // the only reason we have a timeout at all is so that if the last
@ -210,8 +207,12 @@ main (int argc, char *argv[])
if (do_stdin) if (do_stdin)
FD_SET (0, &fdset); FD_SET (0, &fdset);
FD_SET (net_socket, &fdset); FD_SET (net_socket, &fdset);
_timeout.tv_sec = 1;
_timeout.tv_usec = 0;
if (svs.num_clients) if (svs.num_clients)
timeout = &_timeout; timeout = &_timeout;
if (select (net_socket + 1, &fdset, NULL, NULL, timeout) == -1) if (select (net_socket + 1, &fdset, NULL, NULL, timeout) == -1)
continue; continue;
stdin_ready = FD_ISSET (0, &fdset); stdin_ready = FD_ISSET (0, &fdset);