degesch: fix reconnect delays

This commit is contained in:
Přemysl Eric Janouch 2015-10-28 03:46:41 +01:00
parent e41f503202
commit a8a852d4b3
1 changed files with 5 additions and 2 deletions

View File

@ -3669,15 +3669,18 @@ static int64_t
irc_get_reconnect_delay (struct server *s) irc_get_reconnect_delay (struct server *s)
{ {
int64_t delay = get_config_integer (s->config, "reconnect_delay"); int64_t delay = get_config_integer (s->config, "reconnect_delay");
int64_t delay_factor = get_config_integer (s->ctx->config.root, int64_t delay_factor = get_config_integer (s->ctx->config.root,
"behaviour.reconnect_delay_growing"); "behaviour.reconnect_delay_growing");
for (unsigned i = 0; i < s->reconnect_attempt; i++) for (unsigned i = 0; i < s->reconnect_attempt; i++)
{
if (delay_factor && delay > INT64_MAX / delay_factor)
break;
delay *= delay_factor; delay *= delay_factor;
}
int64_t delay_max = get_config_integer (s->ctx->config.root, int64_t delay_max = get_config_integer (s->ctx->config.root,
"behaviour.reconnect_delay_max"); "behaviour.reconnect_delay_max");
return (delay > delay_max || delay < 0) ? delay_max : delay; return MIN (delay, delay_max);
} }
static void static void