add in switch_core_signal_lock/unlock
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@7737 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
bd21deb1b1
commit
be1abfe573
|
@ -109,6 +109,7 @@ struct switch_core_session {
|
|||
|
||||
switch_mutex_t *mutex;
|
||||
switch_mutex_t *resample_mutex;
|
||||
switch_mutex_t *signal_mutex;
|
||||
switch_thread_cond_t *cond;
|
||||
|
||||
switch_thread_rwlock_t *rwlock;
|
||||
|
|
|
@ -286,6 +286,9 @@ SWITCH_DECLARE(switch_status_t) switch_core_destroy(void);
|
|||
///\ingroup core1
|
||||
///\{
|
||||
|
||||
SWITCH_DECLARE(switch_status_t) switch_core_session_signal_lock(switch_core_session_t *session);
|
||||
SWITCH_DECLARE(switch_status_t) switch_core_session_signal_unlock(switch_core_session_t *session);
|
||||
|
||||
#ifdef SWITCH_DEBUG_RWLOCKS
|
||||
SWITCH_DECLARE(switch_status_t) switch_core_session_perform_read_lock(_In_ switch_core_session_t *session, const char *file, const char *func, int line);
|
||||
#endif
|
||||
|
|
|
@ -2538,6 +2538,8 @@ static ldl_status handle_signalling(ldl_handle_t * handle, ldl_session_t * dlses
|
|||
|
||||
|
||||
if ((session = ldl_session_get_private(dlsession))) {
|
||||
|
||||
switch_core_session_signal_lock(session);
|
||||
tech_pvt = switch_core_session_get_private(session);
|
||||
switch_assert(tech_pvt != NULL);
|
||||
|
||||
|
@ -2559,7 +2561,7 @@ static ldl_status handle_signalling(ldl_handle_t * handle, ldl_session_t * dlses
|
|||
}
|
||||
if ((session = switch_core_session_request(dingaling_endpoint_interface, NULL)) != 0) {
|
||||
switch_core_session_add_stream(session, NULL);
|
||||
|
||||
switch_core_session_signal_lock(session);
|
||||
|
||||
if ((tech_pvt = (struct private_object *) switch_core_session_alloc(session, sizeof(struct private_object))) != 0) {
|
||||
char *exten;
|
||||
|
@ -2946,6 +2948,10 @@ static ldl_status handle_signalling(ldl_handle_t * handle, ldl_session_t * dlses
|
|||
|
||||
done:
|
||||
|
||||
if (session) {
|
||||
switch_core_session_signal_unlock(session);
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
|
|
@ -938,6 +938,7 @@ SWITCH_MODULE_RUNTIME_FUNCTION(mod_iax_runtime)
|
|||
|
||||
if ((tech_pvt = iax_get_private(iaxevent->session))) {
|
||||
channel = switch_core_session_get_channel(tech_pvt->session);
|
||||
switch_core_session_signal_lock(tech_pvt->session);
|
||||
}
|
||||
|
||||
if (globals.debug && iaxevent->etype != IAX_EVENT_VOICE) {
|
||||
|
@ -1115,6 +1116,10 @@ SWITCH_MODULE_RUNTIME_FUNCTION(mod_iax_runtime)
|
|||
break;
|
||||
}
|
||||
iax_event_free(iaxevent);
|
||||
|
||||
if (tech_pvt && tech_pvt->session) {
|
||||
switch_core_session_signal_unlock(tech_pvt->session);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -708,7 +708,7 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
|
|||
switch_status_t status = SWITCH_STATUS_SUCCESS;
|
||||
|
||||
switch_mutex_lock(tech_pvt->flag_mutex);
|
||||
|
||||
|
||||
if (switch_channel_get_state(channel) >= CS_HANGUP || !tech_pvt) {
|
||||
status = SWITCH_STATUS_FALSE;
|
||||
goto end;
|
||||
|
|
|
@ -222,8 +222,8 @@ void sofia_event_callback(nua_event_t event,
|
|||
nua_event_name(event), status, phrase, session ? switch_channel_get_name(channel) : "n/a");
|
||||
}
|
||||
|
||||
if (tech_pvt) {
|
||||
switch_mutex_lock(tech_pvt->flag_mutex);
|
||||
if (session) {
|
||||
switch_core_session_signal_lock(session);
|
||||
}
|
||||
|
||||
if ((profile->pflags & PFLAG_AUTH_ALL) && tech_pvt && tech_pvt->key && sip) {
|
||||
|
@ -352,11 +352,8 @@ void sofia_event_callback(nua_event_t event,
|
|||
sofia_reg_release_gateway(gateway);
|
||||
}
|
||||
|
||||
if (tech_pvt) {
|
||||
switch_mutex_unlock(tech_pvt->flag_mutex);
|
||||
}
|
||||
|
||||
if (session) {
|
||||
switch_core_session_signal_unlock(session);
|
||||
switch_core_session_rwunlock(session);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
#include <switch.h>
|
||||
#include "private/switch_core_pvt.h"
|
||||
/*#define LOCK_MORE*/
|
||||
#define PER_POOL_LOCK 1
|
||||
/*#define PER_POOL_LOCK 1*/
|
||||
|
||||
static struct {
|
||||
switch_mutex_t *mem_lock;
|
||||
|
|
|
@ -35,6 +35,17 @@
|
|||
#include <switch.h>
|
||||
#include "private/switch_core_pvt.h"
|
||||
|
||||
|
||||
SWITCH_DECLARE(switch_status_t) switch_core_session_signal_lock(switch_core_session_t *session)
|
||||
{
|
||||
return switch_mutex_lock(session->signal_mutex);
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(switch_status_t) switch_core_session_signal_unlock(switch_core_session_t *session)
|
||||
{
|
||||
return switch_mutex_unlock(session->signal_mutex);
|
||||
}
|
||||
|
||||
#ifdef SWITCH_DEBUG_RWLOCKS
|
||||
SWITCH_DECLARE(switch_status_t) switch_core_session_perform_read_lock(switch_core_session_t *session, const char *file, const char *func, int line)
|
||||
#else
|
||||
|
|
|
@ -347,6 +347,9 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_receive_message(switch_core_
|
|||
return status;
|
||||
}
|
||||
|
||||
|
||||
switch_core_session_signal_lock(session);
|
||||
|
||||
if (session->endpoint_interface->io_routines->receive_message) {
|
||||
status = session->endpoint_interface->io_routines->receive_message(session, message);
|
||||
}
|
||||
|
@ -360,6 +363,9 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_receive_message(switch_core_
|
|||
}
|
||||
|
||||
switch_core_session_kill_channel(session, SWITCH_SIG_BREAK);
|
||||
|
||||
switch_core_session_signal_unlock(session);
|
||||
|
||||
switch_core_session_rwunlock(session);
|
||||
|
||||
return status;
|
||||
|
@ -831,6 +837,7 @@ SWITCH_DECLARE(switch_core_session_t *) switch_core_session_request(const switch
|
|||
|
||||
switch_mutex_init(&session->mutex, SWITCH_MUTEX_NESTED, session->pool);
|
||||
switch_mutex_init(&session->resample_mutex, SWITCH_MUTEX_NESTED, session->pool);
|
||||
switch_mutex_init(&session->signal_mutex, SWITCH_MUTEX_NESTED, session->pool);
|
||||
switch_thread_rwlock_create(&session->bug_rwlock, session->pool);
|
||||
switch_thread_cond_create(&session->cond, session->pool);
|
||||
switch_thread_rwlock_create(&session->rwlock, session->pool);
|
||||
|
|
Loading…
Reference in New Issue