From 1019cc69b2909622f3c6d5a76addbcb70a94ef8f Mon Sep 17 00:00:00 2001
From: Přemysl Janouch 
Date: Sun, 3 May 2015 00:12:39 +0200
Subject: degesch: don't queue reconnects on bogus config
---
 degesch.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/degesch.c b/degesch.c
index 0f703cc..ebc24c0 100644
--- a/degesch.c
+++ b/degesch.c
@@ -4151,7 +4151,7 @@ start:
 	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
@@ -4168,12 +4168,15 @@ on_irc_reconnect_timeout (void *user_data)
 	struct server *s = user_data;
 
 	struct error *e = NULL;
-	if (irc_connect (s, &e))
+	bool should_retry = false;
+	if (irc_connect (s, &should_retry, &e))
 		return;
 
 	buffer_send_error (s->ctx, s->buffer, "%s", e->message);
 	error_free (e);
-	irc_queue_reconnect (s);
+
+	if (should_retry)
+		irc_queue_reconnect (s);
 }
 
 static void
@@ -4304,10 +4307,11 @@ end:
 }
 
 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
 	struct app_context *ctx = s->ctx;
+	*should_retry = true;
 
 	const char *irc_host = get_config_string (ctx, "server.irc_host");
 	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"))
 	{
 		error_set (e, "No hostname specified in configuration");
+		*should_retry = false;
 		return false;
 	}
 
-- 
cgit v1.2.3-70-g09d2