Explorar o código

Allow multiple config plugins to be loaded at start time and set the config
object database objects.


git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@1490 fd59a12c-fef9-0310-b244-a6a79926bd2f

Steven Dake %!s(int64=18) %!d(string=hai) anos
pai
achega
93ce442597
Modificáronse 1 ficheiros con 28 adicións e 16 borrados
  1. 28 16
      exec/main.c

+ 28 - 16
exec/main.c

@@ -439,6 +439,7 @@ int main (int argc, char **argv)
 	struct config_iface_ver0 *config;
 	void *config_p;
 	char *config_iface;
+	char *iface;
 	int res, ch;
 	int background, setprio;
  	int totem_log_service;
@@ -512,25 +513,36 @@ int main (int argc, char **argv)
 		config_iface = "aisparser";
 	}
 
-	res = lcr_ifact_reference (
-		&config_handle,
-		config_iface,
-		config_version,
-		&config_p,
-		0);
+	/* Make a copy so we can deface it with strtok */
+	config_iface = strdup(config_iface);
 
-	config = (struct config_iface_ver0 *)config_p;
-	if (res == -1) {
-		log_printf (LOG_LEVEL_ERROR, "AIS Executive couldn't open configuration component.\n");
-		openais_exit_error (AIS_DONE_MAINCONFIGREAD);
-	}
+	iface = strtok(config_iface, ":");
+	while (iface)
+	{
+		res = lcr_ifact_reference (
+			&config_handle,
+			iface,
+			config_version,
+			&config_p,
+			0);
 
-	res = config->config_readconfig(objdb, &error_string);
-	if (res == -1) {
-		log_printf (LOG_LEVEL_ERROR, error_string);
-		openais_exit_error (AIS_DONE_MAINCONFIGREAD);
+		config = (struct config_iface_ver0 *)config_p;
+		if (res == -1) {
+			log_printf (LOG_LEVEL_ERROR, "AIS Executive couldn't open configuration component '%s'\n", iface);
+			openais_exit_error (AIS_DONE_MAINCONFIGREAD);
+		}
+
+		res = config->config_readconfig(objdb, &error_string);
+		if (res == -1) {
+			log_printf (LOG_LEVEL_ERROR, error_string);
+			openais_exit_error (AIS_DONE_MAINCONFIGREAD);
+		}
+		log_printf (LOG_LEVEL_NOTICE, error_string);
+
+		iface = strtok(NULL, ":");
 	}
-	log_printf (LOG_LEVEL_NOTICE, error_string);
+	if (config_iface)
+		free(config_iface);
 
 	openais_service_default_objdb_set (objdb);