diff options
-rw-r--r-- | degesch.c | 20 |
1 files changed, 7 insertions, 13 deletions
@@ -1015,18 +1015,13 @@ struct server char *name; ///< Server identifier struct buffer *buffer; ///< The buffer for this server - - // Configuration: - 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: enum server_state state; ///< Connection state struct connector *connector; ///< Connection establisher + bool manual_disconnect; ///< Don't reconnect after disconnect int socket; ///< Socket FD of the server struct str read_buffer; ///< Input yet to be processed @@ -1354,6 +1349,7 @@ static struct config_schema g_config_server[] = { .name = "reconnect_delay", .comment = "Time between reconnecting", .type = CONFIG_ITEM_INTEGER, + .validate = config_validate_nonnegative, .default_ = "5" }, { .name = "socks_host", @@ -2802,14 +2798,15 @@ static void irc_queue_reconnect (struct server *s) { // As long as the user wants us to, that is - if (!s->reconnect) + if (!get_config_boolean (s->config, "reconnect")) return; + int64_t delay = get_config_integer (s->config, "reconnect_delay"); // TODO: exponentional backoff - hard_assert (s->socket == -1); + hard_assert (s->state == IRC_DISCONNECTED); buffer_send_status (s->ctx, s->buffer, - "Trying to reconnect in %ld seconds...", s->reconnect_delay); - poller_timer_set (&s->reconnect_tmr, s->reconnect_delay * 1000); + "Trying to reconnect in %ld seconds...", delay); + 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); 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; if (!irc_autofill_user_info (s, &e)) { |