1
0
forked from bip/bip

lag shouldn't be allowed to go negative

This commit is contained in:
Loïc Gomez 2022-01-09 21:12:24 +01:00 committed by Pierre-Louis Bonicoli
parent 62fd77dc17
commit af590f83b7
Signed by untrusted user: pilou
GPG Key ID: 06914C4A5EDAA6DD
2 changed files with 8 additions and 3 deletions

View File

@ -188,8 +188,13 @@ void irc_start_lagtest(struct link_server *l)
*/
void irc_compute_lag(struct link_server *is)
{
time_t lag;
assert(is->laginit_ts != -1);
is->lag = time(NULL) - is->laginit_ts;
lag = time(NULL) - is->laginit_ts;
if (lag > LAGOUT_TIME*2)
is->lag = LAGOUT_TIME*2;
else
is->lag = (unsigned)lag;
}
int irc_lags_out(struct link_server *is)

View File

@ -239,8 +239,8 @@ struct link_server {
size_t user_mode_len;
/* init stuff */
int lag;
int laginit_ts;
unsigned lag;
time_t laginit_ts;
int lagtest_timeout;
/* chanmodes */