[Freeswitch-svn] [commit] r4810 - freeswitch/trunk/src

Freeswitch SVN anthm at freeswitch.org
Fri Mar 30 13:25:48 EDT 2007


Author: anthm
Date: Fri Mar 30 13:25:48 2007
New Revision: 4810

Modified:
   freeswitch/trunk/src/switch_core.c
   freeswitch/trunk/src/switch_core_sqldb.c
   freeswitch/trunk/src/switch_event.c

Log:
fix race

Modified: freeswitch/trunk/src/switch_core.c
==============================================================================
--- freeswitch/trunk/src/switch_core.c	(original)
+++ freeswitch/trunk/src/switch_core.c	Fri Mar 30 13:25:48 2007
@@ -482,6 +482,7 @@
 	assert(runtime.memory_pool != NULL);
 	switch_log_init(runtime.memory_pool);
 	switch_event_init(runtime.memory_pool);
+
 	switch_core_sqldb_start(runtime.memory_pool);
 	switch_rtp_init(runtime.memory_pool);
 	runtime.running = 1;

Modified: freeswitch/trunk/src/switch_core_sqldb.c
==============================================================================
--- freeswitch/trunk/src/switch_core_sqldb.c	(original)
+++ freeswitch/trunk/src/switch_core_sqldb.c	Fri Mar 30 13:25:48 2007
@@ -39,6 +39,7 @@
 	switch_core_db_t *event_db;
 	switch_queue_t *sql_queue;
 	switch_memory_pool_t *memory_pool;
+	int thread_running;
 } runtime;
 
 static switch_status_t switch_core_db_persistant_execute_trans(switch_core_db_t *db, char *sql, uint32_t retries)
@@ -159,9 +160,8 @@
 	if (!runtime.event_db) {
 		runtime.event_db = switch_core_db_handle();
 	}
-	switch_queue_create(&runtime.sql_queue, SWITCH_SQL_QUEUE_LEN, runtime.memory_pool);
-
 
+	runtime.thread_running = 1;
 
 	for (;;) {
 		if (switch_queue_trypop(runtime.sql_queue, &pop) == SWITCH_STATUS_SUCCESS) {
@@ -398,11 +398,15 @@
 		}
 	}
 
+	switch_queue_create(&runtime.sql_queue, SWITCH_SQL_QUEUE_LEN, runtime.memory_pool);
+	
 	switch_threadattr_create(&thd_attr, runtime.memory_pool);
 	switch_threadattr_detach_set(thd_attr, 1);
 	switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
 	switch_thread_create(&thread, thd_attr, switch_core_sql_thread, NULL, runtime.memory_pool);
-
+	while (!runtime.thread_running) {
+		switch_yield(10000);
+	}
 }
 
 void switch_core_sqldb_stop(void)

Modified: freeswitch/trunk/src/switch_event.c
==============================================================================
--- freeswitch/trunk/src/switch_event.c	(original)
+++ freeswitch/trunk/src/switch_event.c	Fri Mar 30 13:25:48 2007
@@ -398,13 +398,14 @@
 	switch_threadattr_detach_set(thd_attr, 1);
 
 	assert(pool != NULL);
-	RUNTIME_POOL = pool;
-
+	THRUNTIME_POOL = RUNTIME_POOL = pool;
 
+	/*
 	if (switch_core_new_memory_pool(&THRUNTIME_POOL) != SWITCH_STATUS_SUCCESS) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Could not allocate memory pool\n");
 		return SWITCH_STATUS_MEMERR;
 	}
+	*/
 	/*
 	   if (switch_core_new_memory_pool(&BPOOL) != SWITCH_STATUS_SUCCESS) {
 	   switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Could not allocate memory pool\n");



More information about the Freeswitch-svn mailing list