diff options
author | Paul Janzen <pjanzen@cvs.openbsd.org> | 2000-06-30 18:28:08 +0000 |
---|---|---|
committer | Paul Janzen <pjanzen@cvs.openbsd.org> | 2000-06-30 18:28:08 +0000 |
commit | 430746985c6ef5778be7e1877f0ab438fb53a066 (patch) | |
tree | a68765c6376738ba5f54717d23b884e812c93b6b /games/hunt | |
parent | 803711ce6616923c9e73b0c3375058d4b486cc08 (diff) |
re-initialize timeout before each invocation of select()
Diffstat (limited to 'games/hunt')
-rw-r--r-- | games/hunt/hunt/list.c | 6 | ||||
-rw-r--r-- | games/hunt/huntd/driver.c | 22 |
2 files changed, 15 insertions, 13 deletions
diff --git a/games/hunt/hunt/list.c b/games/hunt/hunt/list.c index 1e9a22014c5..fd5a2a9497d 100644 --- a/games/hunt/hunt/list.c +++ b/games/hunt/hunt/list.c @@ -1,4 +1,4 @@ -/* $OpenBSD: list.c,v 1.1 1999/12/12 14:53:02 d Exp $ */ +/* $OpenBSD: list.c,v 1.2 2000/06/30 18:28:03 pjanzen Exp $ */ /* * Copyright 1999, David Leonard. All rights reserved. * Redistribution and use in source and binary forms are permitted @@ -71,6 +71,8 @@ next_driver_fd(fd) maxfd = probe_sock[i]; } + probe_timeout.tv_sec = LIST_DELAY; + probe_timeout.tv_usec = 0; ret = select(maxfd + 1, &r, NULL, NULL, &probe_timeout); if (ret == -1) { @@ -221,8 +223,6 @@ probe_drivers(req, preferred) int fd, inlen = 8192; int i, len; - probe_timeout.tv_sec = LIST_DELAY; - probe_timeout.tv_usec = 0; numdrivers = 0; probe_cleanup(); diff --git a/games/hunt/huntd/driver.c b/games/hunt/huntd/driver.c index 8957e0cedad..b23d3c77fe7 100644 --- a/games/hunt/huntd/driver.c +++ b/games/hunt/huntd/driver.c @@ -1,4 +1,4 @@ -/* $OpenBSD: driver.c,v 1.7 1999/12/12 15:13:50 d Exp $ */ +/* $OpenBSD: driver.c,v 1.8 2000/06/30 18:28:07 pjanzen Exp $ */ /* $NetBSD: driver.c,v 1.5 1997/10/20 00:37:16 lukem Exp $ */ /* * Hunt @@ -115,10 +115,10 @@ erred: again: do { /* First, poll to see if we can get input */ - timerclear(&timeout); do { read_fds = Fds_mask; errno = 0; + timerclear(&timeout); nready = select(Num_fds, &read_fds, NULL, NULL, &timeout); if (nready < 0 && errno != EINTR) { @@ -134,22 +134,22 @@ again: * to do, and decide if we need to to block * indefinitely or just timeout. */ - if (conf_simstep && can_moveshots()) { + do { + if (conf_simstep && can_moveshots()) { /* * block for a short time before continuing * with explosions, bullets and whatnot */ - to = &timeout; - to->tv_sec = conf_simstep / 1000000; - to->tv_usec = conf_simstep % 1000000; - } else + to = &timeout; + to->tv_sec = conf_simstep / 1000000; + to->tv_usec = conf_simstep % 1000000; + } else /* * since there's nothing going on, * just block waiting for external activity */ - to = NULL; - - do { + to = NULL; + read_fds = Fds_mask; errno = 0; nready = select(Num_fds, &read_fds, NULL, NULL, @@ -263,6 +263,8 @@ again: log(LOG_WARNING, "select"); break; } + linger.tv_sec = conf_linger; + linger.tv_usec = 0; } if (ret > 0) /* Someone returned! Resume the game: */ |