]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
add in switch_core_signal_lock/unlock
authorAnthony Minessale <anthony.minessale@gmail.com>
Tue, 26 Feb 2008 16:55:40 +0000 (16:55 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Tue, 26 Feb 2008 16:55:40 +0000 (16:55 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@7737 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/include/private/switch_core_pvt.h
src/include/switch_core.h
src/mod/endpoints/mod_dingaling/mod_dingaling.c
src/mod/endpoints/mod_iax/mod_iax.c
src/mod/endpoints/mod_sofia/mod_sofia.c
src/mod/endpoints/mod_sofia/sofia.c
src/switch_core_memory.c
src/switch_core_rwlock.c
src/switch_core_session.c

index 6c0655525d42dc7c1821cf6255e14bf38462f5e6..4852afaa4d79dfd34aae3c3abd0504caaa04f73d 100644 (file)
@@ -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;
index 26d5220452709fed23f7a7753ae0030c777c4d08..afa939a6d45fde069a54b9d0f44e144661513b0c 100644 (file)
@@ -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
index a147e3dd2543bcf74fe0fcba2abc3d02dedffcd5..a502232bd2f2ce3fc8fdb5785d011483dbdf6f37 100644 (file)
@@ -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;
 }
 
index bebf9f822f1ec6bca8ac328a990605d9a70d7b34..8c6e2b61d310e4d9340572683ed6a5569b9cf517 100644 (file)
@@ -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);
+                       }
                }
        }
 
index 5f5b09b744f9aa47806b3ea94c4c6f8c827e48b6..54deab6855ef9cfaf5a0fa6ebe9505aad0046f0b 100644 (file)
@@ -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;
index 1c2b1210890cc9bc65e486fe68a495ab23a0963e..732f1ad5a65a10465a2607e92af3fb1ab5f72147 100644 (file)
@@ -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);
        }
 }
index 10510bacfd53a4df425aad6c18cbd265189f890b..1835d388b04a4e709f33de1a08f758af91d7c9fa 100644 (file)
@@ -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;
index 1e6e35cd750e76b535b1820e2d4f1a6a0102e75b..0bec5c935a056cc63c9064346a08bd4ff24653d2 100644 (file)
 #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
index 9a3e7a396adbf5914d796b07da738d4ef347dea0..d5c06b7ea24c201667f5510bef15591dff5581b8 100644 (file)
@@ -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);