degesch: don't queue reconnects on bogus config

This commit is contained in:
Přemysl Eric Janouch 2015-05-03 00:12:39 +02:00
parent b31104784c
commit 1019cc69b2
1 changed files with 9 additions and 4 deletions

View File

@ -4151,7 +4151,7 @@ start:
return IRC_READ_ERROR; return IRC_READ_ERROR;
} }
static bool irc_connect (struct server *s, struct error **); static bool irc_connect (struct server *s, bool *should_retry, struct error **);
static void irc_queue_reconnect (struct server *s); static void irc_queue_reconnect (struct server *s);
static void static void
@ -4168,12 +4168,15 @@ on_irc_reconnect_timeout (void *user_data)
struct server *s = user_data; struct server *s = user_data;
struct error *e = NULL; struct error *e = NULL;
if (irc_connect (s, &e)) bool should_retry = false;
if (irc_connect (s, &should_retry, &e))
return; return;
buffer_send_error (s->ctx, s->buffer, "%s", e->message); buffer_send_error (s->ctx, s->buffer, "%s", e->message);
error_free (e); error_free (e);
irc_queue_reconnect (s);
if (should_retry)
irc_queue_reconnect (s);
} }
static void static void
@ -4304,10 +4307,11 @@ end:
} }
static bool static bool
irc_connect (struct server *s, struct error **e) irc_connect (struct server *s, bool *should_retry, struct error **e)
{ {
// TODO: connect asynchronously so that we don't freeze // TODO: connect asynchronously so that we don't freeze
struct app_context *ctx = s->ctx; struct app_context *ctx = s->ctx;
*should_retry = true;
const char *irc_host = get_config_string (ctx, "server.irc_host"); const char *irc_host = get_config_string (ctx, "server.irc_host");
int64_t irc_port_int = get_config_integer (ctx, "server.irc_port"); int64_t irc_port_int = get_config_integer (ctx, "server.irc_port");
@ -4315,6 +4319,7 @@ irc_connect (struct server *s, struct error **e)
if (!get_config_string (ctx, "server.irc_host")) if (!get_config_string (ctx, "server.irc_host"))
{ {
error_set (e, "No hostname specified in configuration"); error_set (e, "No hostname specified in configuration");
*should_retry = false;
return false; return false;
} }