Revision
15106
Author
mrene
Date
2009-10-06 23:56:32 -0500 (Tue, 06 Oct 2009)

Log Message

mod_fifo: gracefully fail on missing config file

Modified Paths

Diff

Modified: freeswitch/trunk/src/mod/applications/mod_fifo/mod_fifo.c (15105 => 15106)


--- freeswitch/trunk/src/mod/applications/mod_fifo/mod_fifo.c	2009-10-07 04:30:19 UTC (rev 15105)
+++ freeswitch/trunk/src/mod/applications/mod_fifo/mod_fifo.c	2009-10-07 04:56:32 UTC (rev 15106)
@@ -2254,6 +2254,7 @@
 {
 	switch_application_interface_t *app_interface;
 	switch_api_interface_t *commands_api_interface;
+	switch_status_t status;
 
 	/* create/register custom event message type */
 	if (switch_event_reserve_subclass(FIFO_EVENT) != SWITCH_STATUS_SUCCESS) {
@@ -2272,6 +2273,16 @@
 	switch_core_hash_init(&globals.fifo_hash, globals.pool);
 	switch_mutex_init(&globals.mutex, SWITCH_MUTEX_NESTED, globals.pool);
 	switch_mutex_init(&globals.sql_mutex, SWITCH_MUTEX_NESTED, globals.pool);
+	
+	globals.running = 1;
+	
+	if ((status = load_config(0,1)) != SWITCH_STATUS_SUCCESS) {
+		switch_event_unbind(&globals.node);
+		switch_event_free_subclass(FIFO_EVENT);
+		switch_core_hash_destroy(&globals.fifo_hash);
+		switch_core_destroy_memory_pool(&globals.pool);
+		return status;
+	}
 
 	/* connect my internal structure to the blank pointer passed to me */
 	*module_interface = switch_loadable_module_create_module_interface(pool, modname);
@@ -2284,9 +2295,6 @@
 	switch_console_set_complete("add fifo count");
 	switch_console_set_complete("add fifo importance");
 
-	globals.running = 1;
-
-	load_config(0,1);
 	start_node_thread(globals.pool);
 
 	return SWITCH_STATUS_SUCCESS;