[Freeswitch-svn] [commit] r10244 - in freeswitch/trunk/src: . include include/private mod/endpoints/mod_sofia

Freeswitch SVN anthm at freeswitch.org
Tue Nov 4 19:20:31 EST 2008


Author: anthm
Date: Tue Nov  4 19:20:30 2008
New Revision: 10244

Modified:
   freeswitch/trunk/src/include/private/switch_core_pvt.h
   freeswitch/trunk/src/include/switch_apr.h
   freeswitch/trunk/src/include/switch_core.h
   freeswitch/trunk/src/include/switch_types.h
   freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c
   freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h
   freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c
   freeswitch/trunk/src/switch_apr.c
   freeswitch/trunk/src/switch_core_hash.c
   freeswitch/trunk/src/switch_core_session.c
   freeswitch/trunk/src/switch_loadable_module.c

Log:
update

Modified: freeswitch/trunk/src/include/private/switch_core_pvt.h
==============================================================================
--- freeswitch/trunk/src/include/private/switch_core_pvt.h	(original)
+++ freeswitch/trunk/src/include/private/switch_core_pvt.h	Tue Nov  4 19:20:30 2008
@@ -52,9 +52,6 @@
 #include <apr_general.h>
 
 #include <apr_portable.h>
-typedef apr_os_thread_t switch_thread_id_t;
-#define switch_thread_self apr_os_thread_current
-
 
 #ifdef HAVE_MLOCKALL
 #include <sys/mman.h>

Modified: freeswitch/trunk/src/include/switch_apr.h
==============================================================================
--- freeswitch/trunk/src/include/switch_apr.h	(original)
+++ freeswitch/trunk/src/include/switch_apr.h	Tue Nov  4 19:20:30 2008
@@ -40,6 +40,16 @@
 #define SWITCH_APR_H
 
 SWITCH_BEGIN_EXTERN_C
+
+#ifdef WIN32
+typedef HANDLE                switch_thread_id_t;
+#else
+typedef pthread_t             switch_thread_id_t;
+#endif
+
+SWITCH_DECLARE(switch_thread_id_t) switch_thread_self(void);
+
+
 /*
    The pieces of apr we allow ppl to pass around between modules we typedef into our namespace and wrap all the functions
    any other apr code should be as hidden as possible.

Modified: freeswitch/trunk/src/include/switch_core.h
==============================================================================
--- freeswitch/trunk/src/include/switch_core.h	(original)
+++ freeswitch/trunk/src/include/switch_core.h	Tue Nov  4 19:20:30 2008
@@ -89,6 +89,9 @@
 	switch_size_t pointer_reply_size;
 	/*! message flags */
 	switch_core_session_message_flag_t flags;
+	const char *_file;
+	const char *_func;
+	int _line;
 };
 
 /*! \brief A generic object to pass as a thread's session object to allow mutiple arguements and a pool */
@@ -777,7 +780,11 @@
   \param message the message to recieve
   \return the status returned by the message handler
 */
-SWITCH_DECLARE(switch_status_t) switch_core_session_receive_message(_In_ switch_core_session_t *session, _In_ switch_core_session_message_t *message);
+SWITCH_DECLARE(switch_status_t) switch_core_session_perform_receive_message(_In_ switch_core_session_t *session, 
+																			_In_ switch_core_session_message_t *message,
+																			const char *file, const char *func, int line);
+#define switch_core_session_receive_message(_session, _message) switch_core_session_perform_receive_message(_session, _message, \
+																											__FILE__, __SWITCH_FUNC__, __LINE__)
 
 /*! 
   \brief Queue an event on a given session
@@ -927,7 +934,11 @@
   \param pool the pool to use for the new hash
   \return SWITCH_STATUS_SUCCESS if the hash is created
 */
-SWITCH_DECLARE(switch_status_t) switch_core_hash_init(_Out_ switch_hash_t **hash, _In_ switch_memory_pool_t *pool);
+SWITCH_DECLARE(switch_status_t) switch_core_hash_init_case(_Out_ switch_hash_t **hash, _In_ switch_memory_pool_t *pool, switch_bool_t case_sensitive);
+#define switch_core_hash_init(_hash, _pool) switch_core_hash_init_case(_hash, _pool, SWITCH_TRUE);
+#define switch_core_hash_init_nocase(_hash, _pool) switch_core_hash_init_case(_hash, _pool, SWITCH_FALSE);
+
+
 
 /*! 
   \brief Destroy an existing hash table

Modified: freeswitch/trunk/src/include/switch_types.h
==============================================================================
--- freeswitch/trunk/src/include/switch_types.h	(original)
+++ freeswitch/trunk/src/include/switch_types.h	Tue Nov  4 19:20:30 2008
@@ -565,7 +565,8 @@
 	SWITCH_MESSAGE_INDICATE_DEFLECT,
 	SWITCH_MESSAGE_INDICATE_VIDEO_REFRESH_REQ,
 	SWITCH_MESSAGE_INDICATE_DISPLAY,
-	SWITCH_MESSAGE_INDICATE_TRANSCODING_NECESSARY
+	SWITCH_MESSAGE_INDICATE_TRANSCODING_NECESSARY,
+	SWITCH_MESSAGE_INVALID
 } switch_core_session_message_types_t;
 
 

Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c	(original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c	Tue Nov  4 19:20:30 2008
@@ -868,9 +868,15 @@
 	default:
 		break;
 	}
-
+	
 	/* ones that do need to lock sofia mutex */
 	switch_mutex_lock(tech_pvt->sofia_mutex);
+
+	if (switch_channel_get_state(channel) >= CS_HANGUP || !tech_pvt) {
+		status = SWITCH_STATUS_FALSE;
+		goto end_lock;
+	}
+
 	switch (msg->message_id) {
 	case SWITCH_MESSAGE_INDICATE_VIDEO_REFRESH_REQ:
 		{
@@ -958,7 +964,7 @@
 					if (sofia_glue_tech_media(tech_pvt, r_sdp) != SWITCH_STATUS_SUCCESS) {
 						switch_channel_set_variable(channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "CODEC NEGOTIATION ERROR");
 						status = SWITCH_STATUS_FALSE;
-						goto end;
+						goto end_lock;
 					}
 					send_invite = 0;
 				}
@@ -968,7 +974,7 @@
 				sofia_glue_tech_prepare_codecs(tech_pvt);
 				if ((status = sofia_glue_tech_choose_port(tech_pvt, 0)) != SWITCH_STATUS_SUCCESS) {
 					switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
-					goto end;
+					goto end_lock;
 				}
 			}
 			sofia_glue_set_local_sdp(tech_pvt, NULL, 0, NULL, 1);
@@ -1098,7 +1104,7 @@
 				msg->message_id = SWITCH_MESSAGE_INDICATE_REDIRECT;
 				msg->string_arg = p;
 				switch_core_session_receive_message(session, msg);
-				goto end;
+				goto end_lock;
 			} else {
 				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Responding with %d [%s]\n", code, reason);
 
@@ -1152,7 +1158,7 @@
 						sofia_glue_tech_patch_sdp(tech_pvt);
 						if (sofia_glue_activate_rtp(tech_pvt, 0) != SWITCH_STATUS_SUCCESS) {
 							status = SWITCH_STATUS_FALSE;
-							goto end;
+							goto end_lock;
 						}
 					}
 				} else {
@@ -1165,18 +1171,16 @@
 							sofia_glue_tech_prepare_codecs(tech_pvt);
 							if (sofia_glue_tech_media(tech_pvt, r_sdp) != SWITCH_STATUS_SUCCESS) {
 								switch_channel_set_variable(channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "CODEC NEGOTIATION ERROR");
-								//switch_mutex_lock(tech_pvt->sofia_mutex);
 								//nua_respond(tech_pvt->nh, SIP_488_NOT_ACCEPTABLE, TAG_END());
-								//switch_mutex_unlock(tech_pvt->sofia_mutex);
 								status = SWITCH_STATUS_FALSE;
-								goto end;
+								goto end_lock;
 							}
 						}
 					}
 
 					if ((status = sofia_glue_tech_choose_port(tech_pvt, 0)) != SWITCH_STATUS_SUCCESS) {
 						switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
-						goto end;
+						goto end_lock;
 					}
 					sofia_glue_set_local_sdp(tech_pvt, NULL, 0, NULL, 0);
 					if (sofia_glue_activate_rtp(tech_pvt, 0) != SWITCH_STATUS_SUCCESS) {
@@ -1212,6 +1216,9 @@
 	default:
 		break;
 	}
+
+ end_lock:
+
 	switch_mutex_unlock(tech_pvt->sofia_mutex);
 
   end:

Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h	(original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h	Tue Nov  4 19:20:30 2008
@@ -504,6 +504,7 @@
 	int remote_port;
 	int got_bye;
 	int hold_laps;
+	switch_thread_id_t locker;
 };
 
 struct callback_t {

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 Nov  4 19:20:30 2008
@@ -170,6 +170,7 @@
 	switch_core_session_t *session = NULL;
 	switch_channel_t *channel = NULL;
 	sofia_gateway_t *gateway = NULL;
+	int locked = 0;
 
 	if (sofia_private && sofia_private != &mod_sofia_globals.destroy_private && sofia_private != &mod_sofia_globals.keep_private) {
 		if ((gateway = sofia_private->gateway)) {
@@ -203,12 +204,15 @@
 	}
 
 	if (session) {
-		switch_mutex_lock(tech_pvt->sofia_mutex);
-
 		if (channel && switch_channel_get_state(channel) >= CS_HANGUP) {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Channel is already hungup.\n");
 			goto done;
 		}
+
+		if (tech_pvt) {
+			switch_mutex_lock(tech_pvt->sofia_mutex);
+			locked = 1;
+		}
 	} else if (sofia_private && sofia_private->is_call) {
 		sofia_private->destroy_me = 22;
 	}
@@ -360,9 +364,12 @@
 	}
 
 	if (session) {
-		switch_mutex_unlock(tech_pvt->sofia_mutex);
 		switch_core_session_rwunlock(session);
 	}
+
+	if (tech_pvt && locked) {
+		switch_mutex_unlock(tech_pvt->sofia_mutex);
+	}
 }
 
 void event_handler(switch_event_t *event)

Modified: freeswitch/trunk/src/switch_apr.c
==============================================================================
--- freeswitch/trunk/src/switch_apr.c	(original)
+++ freeswitch/trunk/src/switch_apr.c	Tue Nov  4 19:20:30 2008
@@ -69,6 +69,11 @@
 
 /* Memory Pools */
 
+SWITCH_DECLARE(switch_thread_id_t) switch_thread_self(void)
+{
+	return apr_os_thread_current();
+}
+
 SWITCH_DECLARE(void) switch_pool_clear(switch_memory_pool_t *p)
 {
 	apr_pool_clear(p);

Modified: freeswitch/trunk/src/switch_core_hash.c
==============================================================================
--- freeswitch/trunk/src/switch_core_hash.c	(original)
+++ freeswitch/trunk/src/switch_core_hash.c	Tue Nov  4 19:20:30 2008
@@ -41,14 +41,14 @@
 	Hash table;
 };
 
-SWITCH_DECLARE(switch_status_t) switch_core_hash_init(switch_hash_t **hash, switch_memory_pool_t *pool)
+SWITCH_DECLARE(switch_status_t) switch_core_hash_init_case(switch_hash_t **hash, switch_memory_pool_t *pool, switch_bool_t case_sensitive)
 {
 	switch_hash_t *newhash;
 
 	newhash = switch_core_alloc(pool, sizeof(*newhash));
 	switch_assert(newhash);
 
-	sqlite3HashInit(&newhash->table, SQLITE_HASH_BINARY, 1);
+	sqlite3HashInit(&newhash->table, case_sensitive ? SQLITE_HASH_BINARY : SQLITE_HASH_STRING, 1);
 	*hash = newhash;
 
 	return SWITCH_STATUS_SUCCESS;

Modified: freeswitch/trunk/src/switch_core_session.c
==============================================================================
--- freeswitch/trunk/src/switch_core_session.c	(original)
+++ freeswitch/trunk/src/switch_core_session.c	Tue Nov  4 19:20:30 2008
@@ -413,7 +413,33 @@
 	return cause;
 }
 
-SWITCH_DECLARE(switch_status_t) switch_core_session_receive_message(switch_core_session_t *session, switch_core_session_message_t *message)
+static const char *message_names[] = {
+	"SWITCH_MESSAGE_REDIRECT_AUDIO",
+	"SWITCH_MESSAGE_TRANSMIT_TEXT",
+	"SWITCH_MESSAGE_INDICATE_ANSWER",
+	"SWITCH_MESSAGE_INDICATE_PROGRESS",
+	"SWITCH_MESSAGE_INDICATE_BRIDGE",
+	"SWITCH_MESSAGE_INDICATE_UNBRIDGE",
+	"SWITCH_MESSAGE_INDICATE_TRANSFER",
+	"SWITCH_MESSAGE_INDICATE_RINGING",
+	"SWITCH_MESSAGE_INDICATE_MEDIA",
+	"SWITCH_MESSAGE_INDICATE_NOMEDIA",
+	"SWITCH_MESSAGE_INDICATE_HOLD",
+	"SWITCH_MESSAGE_INDICATE_UNHOLD",
+	"SWITCH_MESSAGE_INDICATE_REDIRECT",
+	"SWITCH_MESSAGE_INDICATE_RESPOND",
+	"SWITCH_MESSAGE_INDICATE_BROADCAST",
+	"SWITCH_MESSAGE_INDICATE_MEDIA_REDIRECT",
+	"SWITCH_MESSAGE_INDICATE_DEFLECT",
+	"SWITCH_MESSAGE_INDICATE_VIDEO_REFRESH_REQ",
+	"SWITCH_MESSAGE_INDICATE_DISPLAY",
+	"SWITCH_MESSAGE_INDICATE_TRANSCODING_NECESSARY",
+	"SWITCH_MESSAGE_INVALID"
+};
+
+SWITCH_DECLARE(switch_status_t) switch_core_session_perform_receive_message(switch_core_session_t *session, 
+																			switch_core_session_message_t *message,
+																			const char *file, const char *func, int line)
 {
 	switch_io_event_hook_receive_message_t *ptr;
 	switch_status_t status = SWITCH_STATUS_SUCCESS;
@@ -428,6 +454,17 @@
 		return status;
 	}
 
+	message->_file = file;
+	message->_func = func;
+	message->_line = line;
+
+	if (message->message_id > SWITCH_MESSAGE_INVALID) {
+		message->message_id = SWITCH_MESSAGE_INVALID;
+	}
+
+	switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_DEBUG, "%s receive message [%s]\n",
+					  switch_channel_get_name(session->channel), message_names[message->message_id]);
+	
 	if (session->endpoint_interface->io_routines->receive_message) {
 		status = session->endpoint_interface->io_routines->receive_message(session, message);
 	}
@@ -440,6 +477,11 @@
 		}
 	}
 
+	message->_file = NULL;
+	message->_func = NULL;
+	message->_line = 0;
+	
+
 	switch_core_session_kill_channel(session, SWITCH_SIG_BREAK);
 	switch_core_session_rwunlock(session);
 

Modified: freeswitch/trunk/src/switch_loadable_module.c
==============================================================================
--- freeswitch/trunk/src/switch_loadable_module.c	(original)
+++ freeswitch/trunk/src/switch_loadable_module.c	Tue Nov  4 19:20:30 2008
@@ -1020,19 +1020,19 @@
 #endif
 
 	switch_core_hash_init(&loadable_modules.module_hash, loadable_modules.pool);
-	switch_core_hash_init(&loadable_modules.endpoint_hash, loadable_modules.pool);
-	switch_core_hash_init(&loadable_modules.codec_hash, loadable_modules.pool);
-	switch_core_hash_init(&loadable_modules.timer_hash, loadable_modules.pool);
-	switch_core_hash_init(&loadable_modules.application_hash, loadable_modules.pool);
-	switch_core_hash_init(&loadable_modules.api_hash, loadable_modules.pool);
+	switch_core_hash_init_nocase(&loadable_modules.endpoint_hash, loadable_modules.pool);
+	switch_core_hash_init_nocase(&loadable_modules.codec_hash, loadable_modules.pool);
+	switch_core_hash_init_nocase(&loadable_modules.timer_hash, loadable_modules.pool);
+	switch_core_hash_init_nocase(&loadable_modules.application_hash, loadable_modules.pool);
+	switch_core_hash_init_nocase(&loadable_modules.api_hash, loadable_modules.pool);
 	switch_core_hash_init(&loadable_modules.file_hash, loadable_modules.pool);
-	switch_core_hash_init(&loadable_modules.speech_hash, loadable_modules.pool);
-	switch_core_hash_init(&loadable_modules.asr_hash, loadable_modules.pool);
-	switch_core_hash_init(&loadable_modules.directory_hash, loadable_modules.pool);
-	switch_core_hash_init(&loadable_modules.chat_hash, loadable_modules.pool);
-	switch_core_hash_init(&loadable_modules.say_hash, loadable_modules.pool);
-	switch_core_hash_init(&loadable_modules.management_hash, loadable_modules.pool);
-	switch_core_hash_init(&loadable_modules.dialplan_hash, loadable_modules.pool);
+	switch_core_hash_init_nocase(&loadable_modules.speech_hash, loadable_modules.pool);
+	switch_core_hash_init_nocase(&loadable_modules.asr_hash, loadable_modules.pool);
+	switch_core_hash_init_nocase(&loadable_modules.directory_hash, loadable_modules.pool);
+	switch_core_hash_init_nocase(&loadable_modules.chat_hash, loadable_modules.pool);
+	switch_core_hash_init_nocase(&loadable_modules.say_hash, loadable_modules.pool);
+	switch_core_hash_init_nocase(&loadable_modules.management_hash, loadable_modules.pool);
+	switch_core_hash_init_nocase(&loadable_modules.dialplan_hash, loadable_modules.pool);
 	switch_mutex_init(&loadable_modules.mutex, SWITCH_MUTEX_NESTED, loadable_modules.pool);
 
 	switch_loadable_module_load_module("", "CORE_SOFTTIMER_MODULE", SWITCH_FALSE, &err);



More information about the Freeswitch-svn mailing list