Base idle timeout on player->curup again, not current time
Idle timeout used to expire max_idle minutes after the last
player->curup update. When we got rid of the idle thread in commit
08b94556
(v4.3.20), this got changed to "wait no more than max_idle
minutes for input". Time spent computing and time spent blocked on
output no longer counts. In particular, a connection can block
indefinitely on output since then. Let's fix that.
Start with basing the input timeout on player->curup again. The
missing output timeout will be added shortly.
Aside: since status() updates player->curup, the idle timer gets reset
when the update aborts a command. Left for another day.
This commit is contained in:
parent
a96b400da3
commit
ed1cbc97e6
5 changed files with 22 additions and 6 deletions
|
@ -124,6 +124,24 @@ io_close(struct iop *iop, struct timeval *timeout)
|
|||
free(iop);
|
||||
}
|
||||
|
||||
void
|
||||
io_timeout(struct timeval *timeout, time_t deadline)
|
||||
{
|
||||
struct timeval now;
|
||||
|
||||
gettimeofday(&now, NULL);
|
||||
if (now.tv_sec >= deadline) {
|
||||
/* deadline reached already */
|
||||
timeout->tv_sec = 0;
|
||||
timeout->tv_usec = 0;
|
||||
} else {
|
||||
/* deadline in future */
|
||||
timeout->tv_sec = deadline - now.tv_sec - 1;
|
||||
timeout->tv_usec = 999999 - now.tv_usec;
|
||||
/* yes, this is 1usec early; sue me */
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Read input from IOP and enqueue it.
|
||||
* If TIMEOUT is non-null, wait at most that long for input to arrive.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue