Rework the calculation of the select timeout in io() to be based on absolute wake time

An absolute wake time is now calculated and updated by set_server_bits(),
TimerTimeout() and tclTimerTimeout().  This is then used to calculate the actual
select() timeout, instead of having those functions calculate a relative timeout
value themselves.  This significantly simplifies those functions, since the
underlying values tend to be recorded as absolute times.

It also allows us to disentangle tclTimeTimeout from TimerTimeout(), and move the
responsibility for calculating the QUEUE_SENDS wake time from TimerTimeout() to
set_server_bits() where it belongs.

The QUEUE_SENDS and CONNECT_DELAY wake up times will also now be correctly
calculated, based on the last sent time and connect time respectively.
This commit is contained in:
Kevin Easton
2015-06-07 00:03:09 +10:00
parent 6f0f9dd8a8
commit c0c7cdbdcc
7 changed files with 67 additions and 99 deletions

View File

@@ -16,14 +16,9 @@ extern int kill_timer(char *);
extern void BX_delete_all_timers (void);
extern int timer_exists (char *ref);
extern time_t TimerTimeout (void);
void TimerTimeout(struct timeval *wake_time);
char *tcl_add_timer (TimerList **, long, char *, unsigned long);
int tcl_remove_timer (TimerList **, unsigned long);
int timer_callback_exists(void *);
time_t tclTimerTimeout(time_t);
#define MAGIC_TIMEOUT 100000000
#endif /* _TIMER_H_ */