summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/plugins/irc/irc-config.c17
-rw-r--r--src/plugins/irc/irc-config.h1
-rw-r--r--src/plugins/irc/irc-server.c19
3 files changed, 33 insertions, 4 deletions
diff --git a/src/plugins/irc/irc-config.c b/src/plugins/irc/irc-config.c
index 1aa48bf0d..032976524 100644
--- a/src/plugins/irc/irc-config.c
+++ b/src/plugins/irc/irc-config.c
@@ -127,6 +127,7 @@ struct t_config_option *irc_config_network_autoreconnect_delay_max;
struct t_config_option *irc_config_network_colors_receive;
struct t_config_option *irc_config_network_colors_send;
struct t_config_option *irc_config_network_lag_check;
+struct t_config_option *irc_config_network_lag_max;
struct t_config_option *irc_config_network_lag_min_show;
struct t_config_option *irc_config_network_lag_reconnect;
struct t_config_option *irc_config_network_lag_refresh_interval;
@@ -2739,6 +2740,14 @@ irc_config_init ()
"check)"),
NULL, 0, 3600 * 24 * 7, "60", NULL, 0, NULL, NULL,
&irc_config_change_network_lag_check, NULL, NULL, NULL);
+ irc_config_network_lag_max = weechat_config_new_option (
+ irc_config_file, ptr_section,
+ "lag_max", "integer",
+ N_("maximum lag (in seconds): if this lag is reached, WeeChat will "
+ "consider that the answer from server (pong) will never be received "
+ "and will give up counting the lag (0 = never give up)"),
+ NULL, 0, 3600 * 24 * 7, "1800", NULL, 0, NULL, NULL,
+ NULL, NULL, NULL, NULL);
irc_config_network_lag_min_show = weechat_config_new_option (
irc_config_file, ptr_section,
"lag_min_show", "integer",
@@ -2748,9 +2757,11 @@ irc_config_init ()
irc_config_network_lag_reconnect = weechat_config_new_option (
irc_config_file, ptr_section,
"lag_reconnect", "integer",
- N_("reconnect to server if lag is greater than this value (in seconds, "
- "0 = never reconnect)"),
- NULL, 0, 3600 * 24 * 7, "0", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ N_("reconnect to server if lag is greater than or equal to this value "
+ "(in seconds, 0 = never reconnect); this value must be less than or "
+ "equal to irc.network.lag_max"),
+ NULL, 0, 3600 * 24 * 7, "0", NULL, 0, NULL, NULL,
+ NULL, NULL, NULL, NULL);
irc_config_network_lag_refresh_interval = weechat_config_new_option (
irc_config_file, ptr_section,
"lag_refresh_interval", "integer",
diff --git a/src/plugins/irc/irc-config.h b/src/plugins/irc/irc-config.h
index 2cee3a8a4..89c29d06b 100644
--- a/src/plugins/irc/irc-config.h
+++ b/src/plugins/irc/irc-config.h
@@ -171,6 +171,7 @@ extern struct t_config_option *irc_config_network_autoreconnect_delay_max;
extern struct t_config_option *irc_config_network_colors_receive;
extern struct t_config_option *irc_config_network_colors_send;
extern struct t_config_option *irc_config_network_lag_check;
+extern struct t_config_option *irc_config_network_lag_max;
extern struct t_config_option *irc_config_network_lag_min_show;
extern struct t_config_option *irc_config_network_lag_reconnect;
extern struct t_config_option *irc_config_network_lag_refresh_interval;
diff --git a/src/plugins/irc/irc-server.c b/src/plugins/irc/irc-server.c
index 66663f910..0f5055c80 100644
--- a/src/plugins/irc/irc-server.c
+++ b/src/plugins/irc/irc-server.c
@@ -2842,7 +2842,7 @@ irc_server_timer_cb (void *data, int remaining_calls)
}
/* lag timeout? => disconnect */
if ((weechat_config_integer (irc_config_network_lag_reconnect) > 0)
- && (ptr_server->lag / 1000 > weechat_config_integer (irc_config_network_lag_reconnect)))
+ && (ptr_server->lag >= weechat_config_integer (irc_config_network_lag_reconnect) * 1000))
{
weechat_printf (ptr_server->buffer,
_("%s%s: lag is high, reconnecting to "
@@ -2854,6 +2854,23 @@ irc_server_timer_cb (void *data, int remaining_calls)
IRC_COLOR_RESET);
irc_server_disconnect (ptr_server, 0, 1);
}
+ else
+ {
+ /* stop lag counting if max lag is reached */
+ if ((weechat_config_integer (irc_config_network_lag_max) > 0)
+ && (ptr_server->lag >= (weechat_config_integer (irc_config_network_lag_max) * 1000)))
+ {
+ /* refresh lag item */
+ ptr_server->lag_last_refresh = current_time;
+ weechat_bar_item_update ("lag");
+
+ /* schedule next lag check in 5 seconds */
+ ptr_server->lag_check_time.tv_sec = 0;
+ ptr_server->lag_check_time.tv_usec = 0;
+ ptr_server->lag_next_check = time (NULL) +
+ weechat_config_integer (irc_config_network_lag_check);
+ }
+ }
}
/* remove redirects if timeout occurs */