]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
add more profile shutdown code to compensate for bug in sofia lib on nua_destroy
authorAnthony Minessale <anthony.minessale@gmail.com>
Mon, 13 Oct 2008 19:26:28 +0000 (19:26 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Mon, 13 Oct 2008 19:26:28 +0000 (19:26 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@9997 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

index d633ea3e19b440cbfa35695ffbd713955bcc6659..415e8f8292cff79485db7d0b708fc6849e046dde 100644 (file)
@@ -1633,7 +1633,7 @@ static switch_status_t cmd_profile(char **argv, int argc, switch_stream_handle_t
        }
 
        if (!strcasecmp(argv[1], "stop") || !strcasecmp(argv[1], "restart")) {
-               int rsec = 3;
+               int rsec = 10;
                int diff = (int) (switch_timestamp(NULL) - profile->started);
                int remain = rsec - diff;
                if (diff < rsec) {
index f14e61bd4ae4b9cb7a5c7954d90ea71a968998df..4ee63ca1c8593ecbae08d4289761a089ea0ecc4d 100644 (file)
@@ -635,6 +635,14 @@ void *SWITCH_THREAD_FUNC sofia_profile_thread_run(switch_thread_t *thread, void
                su_root_step(profile->s_root, 1000);
        }
 
+       sofia_clear_pflag_locked(profile, PFLAG_RUNNING);
+
+       switch_core_session_hupall_matching_var("sofia_profile_name", profile->name, SWITCH_CAUSE_MANAGER_REQUEST);
+       while (profile->inuse) {
+               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Waiting for %d session(s)\n", profile->inuse);
+               su_root_step(profile->s_root, 1000);
+       }
+
        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Write lock %s\n", profile->name);
        switch_thread_rwlock_wrlock(profile->rwlock);
        sofia_reg_unregister(profile);
index 91bba930ec502068b15139b24513604394f8fbfb..a8ed8fdf31f84609ba531597bb71e8374ebb3957 100644 (file)
@@ -2708,6 +2708,19 @@ void sofia_glue_restart_all_profiles(void)
         for (hi = switch_hash_first(NULL, mod_sofia_globals.profile_hash); hi; hi = switch_hash_next(hi)) {
                        switch_hash_this(hi, &var, NULL, &val);
             if ((pptr = (sofia_profile_t *) val)) {
+                               int rsec = 10;
+                               int diff = (int) (switch_timestamp(NULL) - pptr->started);
+                               int remain = rsec - diff;
+                               if (sofia_test_pflag(pptr, PFLAG_RESPAWN) || !sofia_test_pflag(pptr, PFLAG_RUNNING)) {
+                                       continue;
+                               }
+
+                               if (diff < rsec) {
+                                       switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, 
+                                                                         "Profile %s must be up for at least %d seconds to stop/restart.\nPlease wait %d second%s\n",
+                                                                         pptr->name, rsec, remain, remain == 1 ? "" : "s");
+                                       continue;
+                               }
                                sofia_set_pflag_locked(pptr, PFLAG_RESPAWN);
                                sofia_clear_pflag_locked(pptr, PFLAG_RUNNING);
                        }