degesch: don't cache reconnect configuration
Also make sure the delay isn't negative.
This commit is contained in:
parent
c2c82d20dd
commit
87352b33d0
20
degesch.c
20
degesch.c
@ -1015,18 +1015,13 @@ struct server
|
|||||||
|
|
||||||
char *name; ///< Server identifier
|
char *name; ///< Server identifier
|
||||||
struct buffer *buffer; ///< The buffer for this server
|
struct buffer *buffer; ///< The buffer for this server
|
||||||
|
|
||||||
// Configuration:
|
|
||||||
|
|
||||||
struct config_item_ *config; ///< Configuration root
|
struct config_item_ *config; ///< Configuration root
|
||||||
bool reconnect; ///< Whether to reconnect on conn. fail.
|
|
||||||
unsigned long reconnect_delay; ///< Reconnect delay in seconds
|
|
||||||
bool manual_disconnect; ///< Don't reconnect
|
|
||||||
|
|
||||||
// Connection:
|
// Connection:
|
||||||
|
|
||||||
enum server_state state; ///< Connection state
|
enum server_state state; ///< Connection state
|
||||||
struct connector *connector; ///< Connection establisher
|
struct connector *connector; ///< Connection establisher
|
||||||
|
bool manual_disconnect; ///< Don't reconnect after disconnect
|
||||||
|
|
||||||
int socket; ///< Socket FD of the server
|
int socket; ///< Socket FD of the server
|
||||||
struct str read_buffer; ///< Input yet to be processed
|
struct str read_buffer; ///< Input yet to be processed
|
||||||
@ -1354,6 +1349,7 @@ static struct config_schema g_config_server[] =
|
|||||||
{ .name = "reconnect_delay",
|
{ .name = "reconnect_delay",
|
||||||
.comment = "Time between reconnecting",
|
.comment = "Time between reconnecting",
|
||||||
.type = CONFIG_ITEM_INTEGER,
|
.type = CONFIG_ITEM_INTEGER,
|
||||||
|
.validate = config_validate_nonnegative,
|
||||||
.default_ = "5" },
|
.default_ = "5" },
|
||||||
|
|
||||||
{ .name = "socks_host",
|
{ .name = "socks_host",
|
||||||
@ -2802,14 +2798,15 @@ static void
|
|||||||
irc_queue_reconnect (struct server *s)
|
irc_queue_reconnect (struct server *s)
|
||||||
{
|
{
|
||||||
// As long as the user wants us to, that is
|
// As long as the user wants us to, that is
|
||||||
if (!s->reconnect)
|
if (!get_config_boolean (s->config, "reconnect"))
|
||||||
return;
|
return;
|
||||||
|
int64_t delay = get_config_integer (s->config, "reconnect_delay");
|
||||||
|
|
||||||
// TODO: exponentional backoff
|
// TODO: exponentional backoff
|
||||||
hard_assert (s->socket == -1);
|
hard_assert (s->state == IRC_DISCONNECTED);
|
||||||
buffer_send_status (s->ctx, s->buffer,
|
buffer_send_status (s->ctx, s->buffer,
|
||||||
"Trying to reconnect in %ld seconds...", s->reconnect_delay);
|
"Trying to reconnect in %ld seconds...", delay);
|
||||||
poller_timer_set (&s->reconnect_tmr, s->reconnect_delay * 1000);
|
poller_timer_set (&s->reconnect_tmr, delay * 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
@ -6661,9 +6658,6 @@ create_server (struct app_context *ctx)
|
|||||||
s->config = config_item_get (ctx->config.root, "server", NULL);
|
s->config = config_item_get (ctx->config.root, "server", NULL);
|
||||||
hard_assert (s->config != NULL);
|
hard_assert (s->config != NULL);
|
||||||
|
|
||||||
s->reconnect = get_config_boolean (s->config, "reconnect");
|
|
||||||
s->reconnect_delay = get_config_integer (s->config, "reconnect_delay");
|
|
||||||
|
|
||||||
struct error *e = NULL;
|
struct error *e = NULL;
|
||||||
if (!irc_autofill_user_info (s, &e))
|
if (!irc_autofill_user_info (s, &e))
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user