diff options
-rw-r--r-- | ChangeLog.asciidoc | 3 | ||||
-rw-r--r-- | src/plugins/irc/irc-bar-item.c | 1 | ||||
-rw-r--r-- | src/plugins/irc/irc-protocol.c | 7 | ||||
-rw-r--r-- | src/plugins/irc/irc-server.c | 24 | ||||
-rw-r--r-- | src/plugins/irc/irc-server.h | 1 | ||||
-rw-r--r-- | src/plugins/irc/irc-upgrade.c | 1 |
6 files changed, 26 insertions, 11 deletions
diff --git a/ChangeLog.asciidoc b/ChangeLog.asciidoc index d92506198..4a2217eab 100644 --- a/ChangeLog.asciidoc +++ b/ChangeLog.asciidoc @@ -61,8 +61,7 @@ https://weechat.org/files/releasenotes/ReleaseNotes-devel.html[release notes] * api: fix type of value returned by function strcasestr * fifo: fix send error on Cygwin when something is received in the pipe (issue #436) -* irc: remove lag item when a lag is displayed and new lag computed is exactly - 0 milliseconds +* irc: fix update of lag item when the server lag changes * irc: do not allow command /query with a channel name (issue #459) * irc: decode/encode only text in IRC messages and not the headers (bug #29886, issue #218, issue #451) diff --git a/src/plugins/irc/irc-bar-item.c b/src/plugins/irc/irc-bar-item.c index f168235ac..740a6f6a9 100644 --- a/src/plugins/irc/irc-bar-item.c +++ b/src/plugins/irc/irc-bar-item.c @@ -447,7 +447,6 @@ irc_bar_item_lag (void *data, struct t_gui_bar_item *item, irc_buffer_get_server_and_channel (buffer, &server, NULL); if (server - && (server->lag >= 0) && (server->lag >= weechat_config_integer (irc_config_network_lag_min_show))) { snprintf (buf, sizeof (buf), diff --git a/src/plugins/irc/irc-protocol.c b/src/plugins/irc/irc-protocol.c index 65feed475..b83b7fc03 100644 --- a/src/plugins/irc/irc-protocol.c +++ b/src/plugins/irc/irc-protocol.c @@ -1709,19 +1709,20 @@ IRC_PROTOCOL_CALLBACK(ping) IRC_PROTOCOL_CALLBACK(pong) { struct timeval tv; - int old_lag; IRC_PROTOCOL_MIN_ARGS(0); if (server->lag_check_time.tv_sec != 0) { /* calculate lag (time diff with lag check) */ - old_lag = server->lag; gettimeofday (&tv, NULL); server->lag = (int)(weechat_util_timeval_diff (&(server->lag_check_time), &tv) / 1000); - if (old_lag != server->lag) + if (server->lag != server->lag_displayed) + { + server->lag_displayed = server->lag; weechat_bar_item_update ("lag"); + } /* schedule next lag check */ server->lag_check_time.tv_sec = 0; diff --git a/src/plugins/irc/irc-server.c b/src/plugins/irc/irc-server.c index d14c07c03..16fa9e104 100644 --- a/src/plugins/irc/irc-server.c +++ b/src/plugins/irc/irc-server.c @@ -1028,7 +1028,8 @@ irc_server_alloc (const char *name) new_server->is_away = 0; new_server->away_message = NULL; new_server->away_time = 0; - new_server->lag = -1; + new_server->lag = 0; + new_server->lag_displayed = -1; new_server->lag_check_time.tv_sec = 0; new_server->lag_check_time.tv_usec = 0; new_server->lag_next_check = time (NULL) + @@ -3012,7 +3013,7 @@ irc_server_timer_cb (void *data, int remaining_calls) (ptr_server->current_address) ? ptr_server->current_address : "weechat"); gettimeofday (&(ptr_server->lag_check_time), NULL); - ptr_server->lag = -1; + ptr_server->lag = 0; ptr_server->lag_last_refresh = 0; } else @@ -3059,7 +3060,11 @@ irc_server_timer_cb (void *data, int remaining_calls) && (ptr_server->lag >= weechat_config_integer (irc_config_network_lag_min_show))) { ptr_server->lag_last_refresh = current_time; - weechat_bar_item_update ("lag"); + if (ptr_server->lag != ptr_server->lag_displayed) + { + ptr_server->lag_displayed = ptr_server->lag; + weechat_bar_item_update ("lag"); + } } /* lag timeout? => disconnect */ if ((weechat_config_integer (irc_config_network_lag_reconnect) > 0) @@ -3083,7 +3088,11 @@ irc_server_timer_cb (void *data, int remaining_calls) { /* refresh lag item */ ptr_server->lag_last_refresh = current_time; - weechat_bar_item_update ("lag"); + if (ptr_server->lag != ptr_server->lag_displayed) + { + ptr_server->lag_displayed = ptr_server->lag; + weechat_bar_item_update ("lag"); + } /* schedule next lag check in 5 seconds */ ptr_server->lag_check_time.tv_sec = 0; @@ -4658,7 +4667,8 @@ irc_server_disconnect (struct t_irc_server *server, int switch_address, server->cap_account_notify = 0; server->is_away = 0; server->away_time = 0; - server->lag = -1; + server->lag = 0; + server->lag_displayed = -1; server->lag_check_time.tv_sec = 0; server->lag_check_time.tv_usec = 0; server->lag_next_check = time (NULL) + @@ -5256,6 +5266,7 @@ irc_server_hdata_server_cb (void *data, const char *hdata_name) WEECHAT_HDATA_VAR(struct t_irc_server, away_message, STRING, 0, NULL, NULL); WEECHAT_HDATA_VAR(struct t_irc_server, away_time, TIME, 0, NULL, NULL); WEECHAT_HDATA_VAR(struct t_irc_server, lag, INTEGER, 0, NULL, NULL); + WEECHAT_HDATA_VAR(struct t_irc_server, lag_displayed, INTEGER, 0, NULL, NULL); WEECHAT_HDATA_VAR(struct t_irc_server, lag_check_time, OTHER, 0, NULL, NULL); WEECHAT_HDATA_VAR(struct t_irc_server, lag_next_check, TIME, 0, NULL, NULL); WEECHAT_HDATA_VAR(struct t_irc_server, lag_last_refresh, TIME, 0, NULL, NULL); @@ -5494,6 +5505,8 @@ irc_server_add_to_infolist (struct t_infolist *infolist, return 0; if (!weechat_infolist_new_var_integer (ptr_item, "lag", server->lag)) return 0; + if (!weechat_infolist_new_var_integer (ptr_item, "lag_displayed", server->lag_displayed)) + return 0; if (!weechat_infolist_new_var_buffer (ptr_item, "lag_check_time", &(server->lag_check_time), sizeof (struct timeval))) return 0; if (!weechat_infolist_new_var_time (ptr_item, "lag_next_check", server->lag_next_check)) @@ -5837,6 +5850,7 @@ irc_server_print_log () weechat_log_printf (" away_message . . . . : '%s'", ptr_server->away_message); weechat_log_printf (" away_time. . . . . . : %ld", ptr_server->away_time); weechat_log_printf (" lag. . . . . . . . . : %d", ptr_server->lag); + weechat_log_printf (" lag_displayed. . . . : %d", ptr_server->lag_displayed); weechat_log_printf (" lag_check_time . . . : tv_sec:%d, tv_usec:%d", ptr_server->lag_check_time.tv_sec, ptr_server->lag_check_time.tv_usec); diff --git a/src/plugins/irc/irc-server.h b/src/plugins/irc/irc-server.h index 7897bd883..dd650c325 100644 --- a/src/plugins/irc/irc-server.h +++ b/src/plugins/irc/irc-server.h @@ -206,6 +206,7 @@ struct t_irc_server char *away_message; /* away message, NULL if not away */ time_t away_time; /* time() when user marking as away */ int lag; /* lag (in milliseconds) */ + int lag_displayed; /* last value displayed for lag */ struct timeval lag_check_time; /* last time lag was checked (ping sent) */ time_t lag_next_check; /* time for next check */ time_t lag_last_refresh; /* last refresh of lag item */ diff --git a/src/plugins/irc/irc-upgrade.c b/src/plugins/irc/irc-upgrade.c index d62147520..2169df3bd 100644 --- a/src/plugins/irc/irc-upgrade.c +++ b/src/plugins/irc/irc-upgrade.c @@ -444,6 +444,7 @@ irc_upgrade_read_cb (void *data, irc_upgrade_current_server->away_message = strdup (str); irc_upgrade_current_server->away_time = weechat_infolist_time (infolist, "away_time"); irc_upgrade_current_server->lag = weechat_infolist_integer (infolist, "lag"); + irc_upgrade_current_server->lag_displayed = weechat_infolist_integer (infolist, "lag_displayed"); buf = weechat_infolist_buffer (infolist, "lag_check_time", &size); if (buf) memcpy (&(irc_upgrade_current_server->lag_check_time), buf, size); |