make qf-server REALY sleep when there are no clients currently connected

This commit is contained in:
Bill Currie 2000-12-29 05:32:24 +00:00
parent c71fc78360
commit 73980fe852
3 changed files with 12 additions and 4 deletions

View file

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