]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
fix shutdown issues
authorAnthony Minessale <anthony.minessale@gmail.com>
Tue, 8 Jan 2008 16:35:20 +0000 (16:35 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Tue, 8 Jan 2008 16:35:20 +0000 (16:35 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@7139 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/mod/endpoints/mod_sofia/mod_sofia.c
src/mod/endpoints/mod_sofia/sofia.c
src/mod/endpoints/mod_sofia/sofia_glue.c
src/mod/endpoints/mod_sofia/sofia_reg.c

index 27664ee6a19fe324871adfc413d70fb20c4ad3e4..44f251afcb55e0f6ed5ed76f40e405b1fc96d3ba 100644 (file)
@@ -546,6 +546,11 @@ static switch_status_t sofia_read_frame(switch_core_session_t *session, switch_f
        tech_pvt = (private_object_t *) switch_core_session_get_private(session);
        switch_assert(tech_pvt != NULL);
 
+       if (!(tech_pvt->profile->pflags & PFLAG_RUNNING)) {
+               switch_channel_hangup(tech_pvt->channel, SWITCH_CAUSE_NORMAL_CLEARING);
+               return SWITCH_STATUS_FALSE;
+       }
+
        if (switch_test_flag(tech_pvt, TFLAG_HUP)) {
                return SWITCH_STATUS_FALSE;
        }
index 461fbd252c70959a80ddfc0fb9dcbef4a59e1e98..382c933297a1d31b7c0876b768ee08a81c34dbf5 100644 (file)
@@ -535,13 +535,23 @@ void *SWITCH_THREAD_FUNC sofia_profile_thread_run(switch_thread_t *thread, void
        switch_thread_rwlock_wrlock(profile->rwlock);
        sofia_reg_unregister(profile);
        nua_shutdown(profile->nua);
-
        su_root_run(profile->s_root);
+
+       while(profile->inuse) {
+               switch_yield(100000);
+               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "waiting for %d session(s)\n", profile->inuse);
+       }
        nua_destroy(profile->nua);
 
        switch_mutex_lock(profile->ireg_mutex);
        switch_mutex_unlock(profile->ireg_mutex);
 
+       switch_mutex_lock(profile->flag_mutex);
+       switch_mutex_unlock(profile->flag_mutex);
+
+
+
+
        if (switch_event_create(&s_event, SWITCH_EVENT_UNPUBLISH) == SWITCH_STATUS_SUCCESS) {
                switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "service", "_sip._udp,_sip._tcp,_sip._sctp%s",
                                                        (sofia_test_pflag(profile, PFLAG_TLS)) ? ",_sips._tcp" : "");
@@ -2250,7 +2260,7 @@ void sofia_handle_sip_i_invite(nua_t *nua, sofia_profile_t *profile, nua_handle_
        int is_auth = 0, calling_myself = 0;
        su_addrinfo_t *my_addrinfo = msg_addrinfo(nua_current_request(nua));
        
-       if (sess_count >= sess_max) {
+       if (sess_count >= sess_max || !(profile->pflags & PFLAG_RUNNING)) {
                nua_respond(nh, 480, "Maximum Calls In Progress", SIPTAG_RETRY_AFTER_STR("300"), TAG_END());
                return;
        }
index 6b28c0a3c238edab8de6f632e3e61934660a71ff..21f98ea439c95b2603271b1661611db8bd5b4a7f 100644 (file)
@@ -1801,6 +1801,9 @@ sofia_profile_t *sofia_glue_find_profile__(const char *file, const char *func, i
 
        switch_mutex_lock(mod_sofia_globals.hash_mutex);
        if ((profile = (sofia_profile_t *) switch_core_hash_find(mod_sofia_globals.profile_hash, key))) {
+               if (!(profile->pflags & PFLAG_RUNNING)) {
+                       return NULL;
+               }
                if (switch_thread_rwlock_tryrdlock(profile->rwlock) != SWITCH_STATUS_SUCCESS) {
 #ifdef SOFIA_DEBUG_RWLOCKS
                        switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, SWITCH_LOG_ERROR, "Profile %s is locked\n", profile->name);
index f560bb14b34a47996cba5ce939838c6a2d6927fe..102e4aa5f49a2419a39631872c1f4c0d8714b7c4 100644 (file)
@@ -1052,6 +1052,9 @@ sofia_gateway_t *sofia_reg_find_gateway__(const char *file, const char *func, in
 
        switch_mutex_lock(mod_sofia_globals.hash_mutex);
        if ((gateway = (sofia_gateway_t *) switch_core_hash_find(mod_sofia_globals.gateway_hash, key))) {
+               if (!(gateway->profile->pflags & PFLAG_RUNNING)) {
+                       return NULL;
+               }
                if (switch_thread_rwlock_tryrdlock(gateway->profile->rwlock) != SWITCH_STATUS_SUCCESS) {
                        switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_ERROR, "Profile %s is locked\n", gateway->profile->name);
                        gateway = NULL;