From 1d6d737927d4e99333a8e6ae26b44ca959fc1cd9 Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Mon, 27 Jan 2014 19:57:41 +0000 Subject: Fixed lag meter getting stuck. Also lag_sent in struct server should have always been an unsigned long. Fixes #749. --- src/common/hexchat.c | 10 +++++++--- src/common/hexchat.h | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/common/hexchat.c b/src/common/hexchat.c index d44fa2f4..07f91cfb 100644 --- a/src/common/hexchat.c +++ b/src/common/hexchat.c @@ -286,12 +286,16 @@ lag_check (void) NULL, NULL, 0); if (prefs.hex_net_auto_reconnect) serv->auto_reconnect (serv, FALSE, -1); - } else if (!serv->lag_sent) + } else { snprintf (tbuf, sizeof (tbuf), "LAG%lu", tim); serv->p_ping (serv, "", tbuf); - serv->lag_sent = tim; - fe_set_lag (serv, -1); + + if (!serv->lag_sent) + { + serv->lag_sent = tim; + fe_set_lag (serv, -1); + } } } list = list->next; diff --git a/src/common/hexchat.h b/src/common/hexchat.h index 63d0fbed..39a44191 100644 --- a/src/common/hexchat.h +++ b/src/common/hexchat.h @@ -570,7 +570,7 @@ typedef struct server time_t msg_last_time; /*time_t connect_time;*/ /* when did it connect? */ - time_t lag_sent; + unsigned long lag_sent; /* we are still waiting for this ping response*/ time_t ping_recv; /* when we last got a ping reply */ time_t away_time; /* when we were marked away */ -- cgit 1.4.1 From 9969282c72f838004fe3d75f06db48072b0fbfeb Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Mon, 27 Jan 2014 20:24:56 +0000 Subject: Now make_ping_time() in common/util.c returns the time in milliseconds instead of microseconds. In fe_set_lag(serv, lag) the lag argument is now in milliseconds as well. Fixes #758. --- src/common/fe.h | 2 +- src/common/inbound.c | 6 +++--- src/common/util.c | 2 +- src/fe-gtk/fe-gtk.c | 18 +++++++++--------- src/fe-text/fe-text.c | 2 +- 5 files changed, 15 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/common/fe.h b/src/common/fe.h index a7287c4d..cd8ecef9 100644 --- a/src/common/fe.h +++ b/src/common/fe.h @@ -118,7 +118,7 @@ void fe_set_nick (struct server *serv, char *newnick); void fe_ignore_update (int level); void fe_beep (session *sess); void fe_lastlog (session *sess, session *lastlog_sess, char *sstr, gtk_xtext_search_flags flags); -void fe_set_lag (server *serv, int lag); +void fe_set_lag (server *serv, long lag); void fe_set_throttle (server *serv); void fe_set_away (server *serv); void fe_serverlist_open (session *sess); diff --git a/src/common/inbound.c b/src/common/inbound.c index d1c5b51a..47fe2e00 100644 --- a/src/common/inbound.c +++ b/src/common/inbound.c @@ -892,8 +892,8 @@ inbound_ping_reply (session *sess, char *timestring, char *from, if (lag) { sess->server->lag_sent = 0; - sess->server->lag = dif / 1000; - fe_set_lag (sess->server, dif / 100000); + sess->server->lag = dif; + fe_set_lag (sess->server, dif); return; } @@ -906,7 +906,7 @@ inbound_ping_reply (session *sess, char *timestring, char *from, tags_data->timestamp); } else { - snprintf (outbuf, sizeof (outbuf), "%ld.%ld%ld", dif / 1000000, (dif / 100000) % 10, dif % 10); + snprintf (outbuf, sizeof (outbuf), "%ld.%03ld", dif / 1000, dif % 1000); EMIT_SIGNAL_TIMESTAMP (XP_TE_PINGREP, sess, from, outbuf, NULL, NULL, 0, tags_data->timestamp); } diff --git a/src/common/util.c b/src/common/util.c index 6e912169..f999e61f 100644 --- a/src/common/util.c +++ b/src/common/util.c @@ -1459,7 +1459,7 @@ make_ping_time (void) GTimeVal timev; g_get_current_time (&timev); #endif - return (timev.tv_sec - 50000) * 1000000 + timev.tv_usec; + return (timev.tv_sec - 50000) * 1000 + timev.tv_usec/1000; } diff --git a/src/fe-gtk/fe-gtk.c b/src/fe-gtk/fe-gtk.c index 389ef899..ae68bb79 100644 --- a/src/fe-gtk/fe-gtk.c +++ b/src/fe-gtk/fe-gtk.c @@ -713,7 +713,7 @@ fe_lastlog (session *sess, session *lastlog_sess, char *sstr, gtk_xtext_search_f } void -fe_set_lag (server *serv, int lag) +fe_set_lag (server *serv, long lag) { GSList *list = sess_list; session *sess; @@ -727,21 +727,21 @@ fe_set_lag (server *serv, int lag) if (!serv->lag_sent) return; nowtim = make_ping_time (); - lag = (nowtim - serv->lag_sent) / 100000; + lag = nowtim - serv->lag_sent; } /* if there is no pong for >30s report the lag as +30s */ - if (lag > 300 && serv->lag_sent) - lag=300; + if (lag > 30000 && serv->lag_sent) + lag=30000; - per = (double)((double)lag / (double)10); + per = ((double)lag) / 1000.0; if (per > 1.0) per = 1.0; - snprintf (lagtext, sizeof (lagtext) - 1, "%s%d.%ds", - serv->lag_sent ? "+" : "", lag / 10, lag % 10); - snprintf (lagtip, sizeof (lagtip) - 1, "Lag: %s%d.%d seconds", - serv->lag_sent ? "+" : "", lag / 10, lag % 10); + snprintf (lagtext, sizeof (lagtext) - 1, "%s%ld.%lds", + serv->lag_sent ? "+" : "", lag / 1000, (lag/100) % 10); + snprintf (lagtip, sizeof (lagtip) - 1, "Lag: %s%ld.%ld seconds", + serv->lag_sent ? "+" : "", lag / 1000, (lag/100) % 10); while (list) { diff --git a/src/fe-text/fe-text.c b/src/fe-text/fe-text.c index 76f93d8d..06b58e05 100644 --- a/src/fe-text/fe-text.c +++ b/src/fe-text/fe-text.c @@ -802,7 +802,7 @@ fe_lastlog (session *sess, session *lastlog_sess, char *sstr, gtk_xtext_search_f { } void -fe_set_lag (server * serv, int lag) +fe_set_lag (server * serv, long lag) { } void -- cgit 1.4.1