add sofia global standby on that makes sofia not do anything but refuse to work until sofia global standby off or sofia recover is issued
This commit is contained in:
parent
10dfc37770
commit
6dd5e59b05
|
@ -4139,6 +4139,7 @@ SWITCH_STANDARD_API(sofia_function)
|
|||
int ston = -1;
|
||||
int cton = -1;
|
||||
int wdon = -1;
|
||||
int stbyon = -1;
|
||||
|
||||
if (argc > 1) {
|
||||
if (!strcasecmp(argv[1], "debug")) {
|
||||
|
@ -4174,6 +4175,12 @@ SWITCH_STANDARD_API(sofia_function)
|
|||
}
|
||||
}
|
||||
|
||||
if (!strcasecmp(argv[1], "standby")) {
|
||||
if (argc > 2) {
|
||||
stbyon = switch_true(argv[2]);
|
||||
}
|
||||
}
|
||||
|
||||
if (!strcasecmp(argv[1], "capture")) {
|
||||
if (argc > 2) {
|
||||
cton = switch_true(argv[2]);
|
||||
|
@ -4191,11 +4198,14 @@ SWITCH_STANDARD_API(sofia_function)
|
|||
sofia_glue_global_siptrace(ston);
|
||||
stream->write_function(stream, "+OK Global siptrace %s", ston ? "on" : "off");
|
||||
} else if (cton != -1) {
|
||||
sofia_glue_global_capture(cton);
|
||||
stream->write_function(stream, "+OK Global capture %s", cton ? "on" : "off");
|
||||
sofia_glue_global_capture(cton);
|
||||
stream->write_function(stream, "+OK Global capture %s", cton ? "on" : "off");
|
||||
} else if (wdon != -1) {
|
||||
sofia_glue_global_watchdog(wdon);
|
||||
stream->write_function(stream, "+OK Global watchdog %s", wdon ? "on" : "off");
|
||||
} else if (stbyon != -1) {
|
||||
sofia_glue_global_standby(stbyon);
|
||||
stream->write_function(stream, "+OK Global standby %s", stbyon ? "on" : "off");
|
||||
} else {
|
||||
stream->write_function(stream, "-ERR Usage: siptrace <on|off>|capture <on|off>|watchdog <on|off>|debug <sla|presence|none");
|
||||
}
|
||||
|
@ -4296,6 +4306,11 @@ static switch_call_cause_t sofia_outgoing_channel(switch_core_session_t *session
|
|||
|
||||
*new_session = NULL;
|
||||
|
||||
if (sofia_test_pflag(profile, PFLAG_STANDBY)) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "System Paused\n");
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (!outbound_profile || zstr(outbound_profile->destination_number)) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Invalid Empty Destination\n");
|
||||
goto error;
|
||||
|
@ -5406,6 +5421,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_sofia_load)
|
|||
switch_console_set_complete("add sofia tracelevel ::[console:alert:crit:err:warning:notice:info:debug");
|
||||
|
||||
switch_console_set_complete("add sofia global siptrace ::[on:off");
|
||||
switch_console_set_complete("add sofia global standby ::[on:off");
|
||||
switch_console_set_complete("add sofia global capture ::[on:off");
|
||||
switch_console_set_complete("add sofia global watchdog ::[on:off");
|
||||
|
||||
|
|
|
@ -219,7 +219,7 @@ typedef enum {
|
|||
PFLAG_UUID_AS_CALLID,
|
||||
PFLAG_SCROOGE,
|
||||
PFLAG_MANAGE_SHARED_APPEARANCE,
|
||||
PFLAG_MANAGE_SHARED_APPEARANCE_SYLANTRO_DELETED_USE_ME,
|
||||
PFLAG_STANDBY,
|
||||
PFLAG_DISABLE_SRV,
|
||||
PFLAG_DISABLE_SRV503,
|
||||
PFLAG_DISABLE_NAPTR,
|
||||
|
@ -843,6 +843,8 @@ switch_mutex_unlock(obj->flag_mutex);
|
|||
/* Function Prototypes */
|
||||
/*************************************************************************************************************************************************************/
|
||||
|
||||
void sofia_glue_global_standby(switch_bool_t on);
|
||||
|
||||
switch_status_t sofia_glue_activate_rtp(private_object_t *tech_pvt, switch_rtp_flag_t myflags);
|
||||
|
||||
void sofia_glue_deactivate_rtp(private_object_t *tech_pvt);
|
||||
|
|
|
@ -857,7 +857,6 @@ static void our_sofia_event_callback(nua_event_t event,
|
|||
int locked = 0;
|
||||
int check_destroy = 1;
|
||||
|
||||
|
||||
if (sofia_private && sofia_private->is_call && sofia_private->de) {
|
||||
sofia_dispatch_event_t *qde = sofia_private->de;
|
||||
sofia_private->de = NULL;
|
||||
|
@ -1302,6 +1301,14 @@ void sofia_event_callback(nua_event_t event,
|
|||
sofia_dispatch_event_t *de;
|
||||
|
||||
|
||||
if (sofia_test_pflag(profile, PFLAG_STANDBY)) {
|
||||
if (event < nua_r_set_params || event > nua_r_authenticate) {
|
||||
nua_respond(nh, 503, "System Paused", TAG_END());
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
switch_mutex_lock(profile->flag_mutex);
|
||||
profile->queued_events++;
|
||||
switch_mutex_unlock(profile->flag_mutex);
|
||||
|
@ -1586,6 +1593,12 @@ void *SWITCH_THREAD_FUNC sofia_profile_worker_thread_run(switch_thread_t *thread
|
|||
|
||||
/* While we're running, or there is a pending sql statment that we haven't appended to sqlbuf yet, because of a lack of buffer space */
|
||||
while ((mod_sofia_globals.running == 1 && sofia_test_pflag(profile, PFLAG_RUNNING)) || sql) {
|
||||
|
||||
if (sofia_test_pflag(profile, PFLAG_STANDBY)) {
|
||||
switch_yield(1000000);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (sofia_test_pflag(profile, PFLAG_SQL_IN_TRANS)) {
|
||||
/* Do we have enough statements or is the timeout expired */
|
||||
while (sql || (sofia_test_pflag(profile, PFLAG_RUNNING) && mod_sofia_globals.running == 1 &&
|
||||
|
@ -2965,6 +2978,12 @@ switch_status_t reconfig_sofia(sofia_profile_t *profile)
|
|||
} else {
|
||||
sofia_clear_pflag(profile, PFLAG_PRESENCE_MAP);
|
||||
}
|
||||
} else if (!strcasecmp(var, "profile-standby")) {
|
||||
if (switch_true(val)) {
|
||||
sofia_set_pflag(profile, PFLAG_STANDBY);
|
||||
} else {
|
||||
sofia_clear_pflag(profile, PFLAG_STANDBY);
|
||||
}
|
||||
} else if (!strcasecmp(var, "liberal-dtmf")) {
|
||||
if (switch_true(val)) {
|
||||
sofia_set_pflag(profile, PFLAG_LIBERAL_DTMF);
|
||||
|
@ -3695,6 +3714,12 @@ switch_status_t config_sofia(int reload, char *profile_name)
|
|||
} else {
|
||||
sofia_clear_pflag(profile, PFLAG_PRESENCE_MAP);
|
||||
}
|
||||
} else if (!strcasecmp(var, "profile-standby")) {
|
||||
if (switch_true(val)) {
|
||||
sofia_set_pflag(profile, PFLAG_STANDBY);
|
||||
} else {
|
||||
sofia_clear_pflag(profile, PFLAG_STANDBY);
|
||||
}
|
||||
} else if (!strcasecmp(var, "liberal-dtmf")) {
|
||||
if (switch_true(val)) {
|
||||
sofia_set_pflag(profile, PFLAG_LIBERAL_DTMF);
|
||||
|
|
|
@ -5312,6 +5312,30 @@ void sofia_glue_global_siptrace(switch_bool_t on)
|
|||
|
||||
}
|
||||
|
||||
void sofia_glue_global_standby(switch_bool_t on)
|
||||
{
|
||||
switch_hash_index_t *hi;
|
||||
const void *var;
|
||||
void *val;
|
||||
sofia_profile_t *pptr;
|
||||
|
||||
switch_mutex_lock(mod_sofia_globals.hash_mutex);
|
||||
if (mod_sofia_globals.profile_hash) {
|
||||
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)) {
|
||||
if (on) {
|
||||
sofia_set_pflag_locked(pptr, PFLAG_STANDBY);
|
||||
} else {
|
||||
sofia_clear_pflag_locked(pptr, PFLAG_STANDBY);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
switch_mutex_unlock(mod_sofia_globals.hash_mutex);
|
||||
|
||||
}
|
||||
|
||||
void sofia_glue_global_capture(switch_bool_t on)
|
||||
{
|
||||
switch_hash_index_t *hi;
|
||||
|
@ -5674,6 +5698,8 @@ int sofia_glue_recover(switch_bool_t flush)
|
|||
h.profile = profile;
|
||||
h.total = 0;
|
||||
|
||||
sofia_clear_pflag_locked(profile, PFLAG_STANDBY);
|
||||
|
||||
if (flush) {
|
||||
sql = switch_mprintf("delete from sip_recovery where profile_name='%q'", profile->name);
|
||||
sofia_glue_execute_sql_now(profile, &sql, SWITCH_TRUE);
|
||||
|
|
Loading…
Reference in New Issue