Author: anthm Date: Mon Oct 13 15:26:28 2008 New Revision: 9997 Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c Log: add more profile shutdown code to compensate for bug in sofia lib on nua_destroy 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 Mon Oct 13 15:26:28 2008 @@ -1633,7 +1633,7 @@ } 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) { 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 Mon Oct 13 15:26:28 2008 @@ -635,6 +635,14 @@ 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); Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c (original) +++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c Mon Oct 13 15:26:28 2008 @@ -2708,6 +2708,19 @@ 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); }