changeset 4974:4654603f24f6 HEAD

If ssl_disable=yes, don't bother resolving ssl_listen. Also if listen or ssl_listen resolving fails, log if it was listen or ssl_listen setting that caused the error.
author Timo Sirainen <tss@iki.fi>
date Thu, 28 Dec 2006 21:59:37 +0200
parents ec41129cd0ef
children 1bc48cee6420
files src/master/main.c
diffstat 1 files changed, 22 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/src/master/main.c	Thu Dec 28 20:40:29 2006 +0200
+++ b/src/master/main.c	Thu Dec 28 21:59:37 2006 +0200
@@ -248,7 +248,8 @@
 		i_warning("waitpid() failed: %m");
 }
 
-static void resolve_ip(const char *name, struct ip_addr *ip, unsigned int *port)
+static void resolve_ip(const char *set_name, const char *name,
+		       struct ip_addr *ip, unsigned int *port)
 {
 	struct ip_addr *ip_list;
 	const char *p;
@@ -264,16 +265,19 @@
 	if (name[0] == '[') {
 		/* IPv6 address */
 		p = strchr(name, ']');
-		if (p == NULL)
-			i_fatal("Missing ']' in address %s", name);
-
+		if (p == NULL) {
+			i_fatal("%s: Missing ']' in address %s",
+				set_name, name);
+		}
 		name = t_strdup_until(name+1, p);
 
 		p++;
 		if (*p == '\0')
 			p = NULL;
-		else if (*p != ':')
-			i_fatal("Invalid data after ']' in address %s", name);
+		else if (*p != ':') {
+			i_fatal("%s: Invalid data after ']' in address %s",
+				set_name, name);
+		}
 	} else {
 		p = strrchr(name, ':');
 		if (p != NULL)
@@ -281,8 +285,10 @@
 	}
 
 	if (p != NULL) {
-		if (!is_numeric(p+1, '\0'))
-			i_fatal("Invalid port in address %s", name);
+		if (!is_numeric(p+1, '\0')) {
+			i_fatal("%s: Invalid port in address %s",
+				set_name, name);
+		}
 		*port = atoi(p+1);
 	}
 
@@ -301,12 +307,12 @@
 	/* Return the first IP if there happens to be multiple. */
 	ret = net_gethostbyname(name, &ip_list, &ips_count);
 	if (ret != 0) {
-		i_fatal("Can't resolve address %s: %s",
-			name, net_gethosterror(ret));
+		i_fatal("%s: Can't resolve address %s: %s",
+			set_name, name, net_gethosterror(ret));
 	}
 
 	if (ips_count < 1)
-		i_fatal("No IPs for address: %s", name);
+		i_fatal("%s: No IPs for address: %s", set_name, name);
 
 	*ip = ip_list[0];
 }
@@ -359,8 +365,11 @@
 #endif
 
 	/* resolve */
-	resolve_ip(set->listen, &set->listen_ip, &set->listen_port);
-	resolve_ip(set->ssl_listen, &set->ssl_listen_ip, &set->ssl_listen_port);
+	resolve_ip("listen", set->listen, &set->listen_ip, &set->listen_port);
+	if (!set->ssl_disable) {
+		resolve_ip("ssl_listen", set->ssl_listen, &set->ssl_listen_ip,
+			   &set->ssl_listen_port);
+	}
 
 	/* if ssl_listen wasn't explicitly set in the config file,
 	   use the non-ssl IP settings for the ssl listener, too. */