introduced max_shutdown_time, limits server stop

to prevent SEMS from stopping if there are hanging sessions,
a limit on the maximum shutdown time (actually time to wait
for sessions to stop) can be configured

default: 10 seconds
turn off by setting to 0
sayer/1.4-spce2.6
Stefan Sayer 16 years ago
parent 8f289e98b9
commit cbf59af49d

@ -58,6 +58,8 @@ string AmConfig::DaemonUid = DEFAULT_DAEMON_UID;
string AmConfig::DaemonGid = DEFAULT_DAEMON_GID;
#endif
unsigned int AmConfig::MaxShutdownTime = DEFAULT_MAX_SHUTDOWN_TIME;
string AmConfig::LocalIP = "";
string AmConfig::PublicIP = "";
string AmConfig::PrefixSep = PREFIX_SEPARATOR;
@ -416,6 +418,9 @@ int AmConfig::readConfiguration()
}
}
MaxShutdownTime = cfg.getParameterInt("max_shutdown_time",
DEFAULT_MAX_SHUTDOWN_TIME);
// user_prefix_separator
PrefixSep = cfg.getParameter("user_prefix_separator",PrefixSep);
@ -468,7 +473,6 @@ int AmConfig::readConfiguration()
}
}
// single codec in 200 OK
if(cfg.hasParameter("single_codec_in_ok")){
SingleCodecInOK = (cfg.getParameter("single_codec_in_ok") == "yes");

@ -75,6 +75,8 @@ struct AmConfig
static string DaemonGid;
#endif
static unsigned int MaxShutdownTime;
/** local IP for SDP media advertising */
static string LocalIP;

@ -63,7 +63,7 @@ void AmSessionContainer::dispose()
if(!_instance->is_stopped()) {
_instance->stop();
while(!_instance->is_stopped())
while (!_instance->is_stopped())
usleep(10000);
}
// todo: add locking here
@ -149,12 +149,19 @@ void AmSessionContainer::on_stop()
DBG("waiting for active event queues to stop...\n");
while (!AmEventDispatcher::instance()->empty())
sleep(1);
for (unsigned int i=0;
(!AmEventDispatcher::instance()->empty() &&
(!AmConfig::MaxShutdownTime ||
i < AmConfig::MaxShutdownTime * 1000 / 10));i++)
usleep(10000);
if (!AmEventDispatcher::instance()->empty()) {
WARN("Not all calls cleanly ended!\n");
}
DBG("cleaning sessions...\n");
while (clean_sessions())
sleep(1);
usleep(10000);
_run_cond.set(true); // so that thread stops
}

@ -206,6 +206,15 @@ stderr=no
# (same as -D)
loglevel=2
# optional parameter: max_shutdown_time=<time in seconds>
#
# Limit on server shutdown time (time to send/resend BYE
# to active calls). 0 to disable (infinite).
#
# Default: 10
#
#max_shutdown_time = 10
# optional parameter: syslog_facility={DAEMON|USER|LOCAL[0-7]}
#
# - sets the log facility that is used for syslog. Using this,

@ -40,6 +40,8 @@
#define RTP_HIGHPORT 0xffff
#define MAX_FORWARDS 70
#define DEFAULT_MAX_SHUTDOWN_TIME 10 // 10 seconds max for shutting down
#ifndef DISABLE_DAEMON_MODE
# define DEFAULT_DAEMON_MODE true
# define DEFAULT_DAEMON_PID_FILE "/var/local/run/sems.pid"

Loading…
Cancel
Save