Rework and improve the scheduling of the server lag check

Previously the server lag check was run by update_clock() if the number of
seconds since client startup was a multiple of 20 (unless it had already been
done this second).  This meant that if update_clock() was not being called
frequently (eg. if your IRC connection was very quiet), it might go a long
time between lag checks.

This commit adds a /set LAG_CHECK_INTERVAL (defaulting to 30).  For each
server, a lag check ping is scheduled for every LAG_CHECK_INTERVAL seconds
after the connection is finalised/registered.  Setting this value to 0
disables the lag check pings entirely.

The old code set the lag to 'unknown' immediately after sending out a ping,
which meant that it was quite unpredictable how long the lag value would
stay around for.  The new code only sets this once the current lag value
has become stale (ie. a ping reply is overdue based on the current lag
value).  If your lag is staying the same or reducing, you shouldn't see
the [Lag ??] at all.
This commit is contained in:
Kevin Easton
2015-06-12 15:54:43 +10:00
parent 7eae2aba86
commit 6dbc712046
8 changed files with 87 additions and 88 deletions

View File

@@ -94,7 +94,8 @@ typedef struct
int sent; /* set if something has been sent,
* used for redirect */
int lag; /* indication of lag from server CDE*/
time_t lag_time; /* time ping sent to server CDE */
struct timeval lag_sent; /* time lag ping sent to server CDE */
struct timeval lag_recv; /* time last lag ping reply was recieved */
unsigned long lag_cookie; /* cookie to identify our lag check pings */
time_t last_msg; /* last mesg recieved from the server CDE */
@@ -237,9 +238,7 @@ extern SGroup *server_group_list;
int BX_get_server_lag (int);
void BX_set_server_lag (int, int);
time_t get_server_lagtime (int);
void set_server_lagtime (int, time_t);
unsigned long get_server_lag_cookie(int gso_index);
void server_lag_reply(int s, unsigned long cookie, struct timeval lag_recv, struct timeval lag_sent);
char *BX_set_server_password (int, char *);
void BX_set_server_nickname (int, char *);
@@ -365,7 +364,6 @@ ChannelList *BX_get_server_channels (int);
void reconnect_server(int *, int *, time_t *);
int finalize_server_connect(int, int, int);
int next_server(int);
int check_serverlag (void);
void do_idle_server (void);
/* XXXXX ick, gross, bad. XXXXX */