changeset 10535:e4e31fa845a5 HEAD

master: Give error message with unknown names in protocols setting.
author Timo Sirainen <tss@iki.fi>
date Wed, 23 Dec 2009 17:20:02 -0500
parents 8f2c4d0f7247
children 7a0a89d81699
files src/master/master-settings.c
diffstat 1 files changed, 23 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/master/master-settings.c	Wed Dec 23 17:13:42 2009 -0500
+++ b/src/master/master-settings.c	Wed Dec 23 17:20:02 2009 -0500
@@ -299,6 +299,21 @@
 }
 
 static bool
+services_have_protocol(struct master_settings *set, const char *name)
+{
+	struct service_settings *const *services;
+
+	array_foreach(&set->services, services) {
+		struct service_settings *service = *services;
+
+		if (service->protocol != NULL &&
+		    strcmp(service->protocol, name) == 0)
+			return TRUE;
+	}
+	return FALSE;
+}
+
+static bool
 master_settings_verify(void *_set, pool_t pool, const char **error_r)
 {
 	struct master_settings *set = _set;
@@ -396,6 +411,14 @@
 	}
 
 	set->protocols_split = p_strsplit(pool, set->protocols, " ");
+	for (i = 0; set->protocols_split[i] != NULL; i++) {
+		if (!services_have_protocol(set, set->protocols_split[i])) {
+			*error_r = t_strdup_printf("protocols: "
+						   "Unknown protocol: %s",
+						   set->protocols_split[i]);
+			return FALSE;
+		}
+	}
 	return TRUE;
 }
 /* </settings checks> */