[Freeswitch-trunk] [commit] r12861 - freeswitch/trunk/src/mod/endpoints/mod_sofia

FreeSWITCH SVN anthm at freeswitch.org
Tue Mar 31 16:57:07 PDT 2009


Author: anthm
Date: Tue Mar 31 18:57:07 2009
New Revision: 12861

Log:
speed up loop

Modified:
   freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c

Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c	(original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c	Tue Mar 31 18:57:07 2009
@@ -640,7 +640,8 @@
 	uint32_t gateway_loops = 0;
 	int loops = 0;
 	uint32_t qsize;
-
+	void *pop;
+	
 	ireg_loops = IREG_SECONDS;
 	gateway_loops = GATEWAY_SECONDS;
 
@@ -652,7 +653,6 @@
 
 	while ((mod_sofia_globals.running == 1 && sofia_test_pflag(profile, PFLAG_RUNNING)) || qsize) {
 		if (qsize) {
-			void *pop;
 			switch_mutex_lock(profile->ireg_mutex);
 			while (switch_queue_trypop(profile->sql_queue, &pop) == SWITCH_STATUS_SUCCESS && pop) {
 				sofia_glue_actually_execute_sql(profile, SWITCH_TRUE, (char *) pop, NULL);
@@ -675,10 +675,17 @@
 			loops = 0;
 		}
 
-		switch_yield(10000);
+		switch_cond_next();
 		qsize = switch_queue_size(profile->sql_queue);
 	}
 
+	switch_mutex_lock(profile->ireg_mutex);
+	while (switch_queue_trypop(profile->sql_queue, &pop) == SWITCH_STATUS_SUCCESS && pop) {
+		sofia_glue_actually_execute_sql(profile, SWITCH_TRUE, (char *) pop, NULL);
+		free(pop);
+	}
+	switch_mutex_unlock(profile->ireg_mutex);
+
 	sofia_clear_pflag_locked(profile, PFLAG_WORKER_RUNNING);
 
 	return NULL;



More information about the Freeswitch-trunk mailing list