SIGTERM stops server without sending BYE

SIGHUP - broadcast shutdown, usually sends BYE and stops all calls. The server does not terminate.
SIGINT - broadcast shutdown (usually sends BYE and stops all calls), and stop.
SIGTERM - stop the server, without broadcasting shutdown (no BYEs sent).
sayer/1.4-spce2.6
Stefan Sayer 16 years ago
parent e03bbc94cd
commit 434cba1cc7

@ -44,7 +44,7 @@ AmSessionContainer* AmSessionContainer::_instance=NULL;
_MONITORING_DECLARE_INTERFACE(AmSessionContainer);
AmSessionContainer::AmSessionContainer()
: _run_cond(false), _container_closed(false)
: _run_cond(false), _container_closed(false), enable_unclean_shutdown(false)
{
}
@ -149,23 +149,27 @@ void AmSessionContainer::on_stop()
{
_container_closed.set(true);
broadcastShutdown();
if (enable_unclean_shutdown) {
INFO("unclean shutdown requested - not broadcasting shutdown\n");
} else {
broadcastShutdown();
DBG("waiting for active event queues to stop...\n");
DBG("waiting for active event queues to stop...\n");
for (unsigned int i=0;
(!AmEventDispatcher::instance()->empty() &&
(!AmConfig::MaxShutdownTime ||
i < AmConfig::MaxShutdownTime * 1000 / 10));i++)
usleep(10000);
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");
}
if (!AmEventDispatcher::instance()->empty()) {
WARN("Not all calls cleanly ended!\n");
}
DBG("cleaning sessions...\n");
while (clean_sessions())
usleep(10000);
DBG("cleaning sessions...\n");
while (clean_sessions())
usleep(10000);
}
_run_cond.set(true); // so that thread stops
}
@ -434,3 +438,7 @@ bool AmSessionContainer::addSession(const string& local_tag,
return AmEventDispatcher::instance()->
addEventQueue(local_tag,(AmEventQueue*)session);
}
void AmSessionContainer::enableUncleanShutdown() {
enable_unclean_shutdown = true;
}

@ -67,6 +67,9 @@ class AmSessionContainer : public AmThread
/** We are a Singleton ! Avoid people to have their own instance. */
AmSessionContainer();
bool enable_unclean_shutdown;
/**
* Tries to stop the session and queue it destruction.
*/
@ -148,6 +151,9 @@ class AmSessionContainer : public AmThread
*/
void broadcastShutdown();
/** enable unclean shutdown (will not broadcastShutdown event) */
void enableUncleanShutdown();
_MONITORING_DEFINE_INTERFACE;
};

@ -226,6 +226,10 @@ static void signal_handler(int sig)
return;
}
if (sig == SIGTERM) {
AmSessionContainer::instance()->enableUncleanShutdown();
}
if (main_pid == getpid()) {
if(!is_shutting_down.get()) {
is_shutting_down.set(true);

@ -6,7 +6,8 @@ The execution of the server can be controlled by sending signals
to the process.
\li SIGHUP - broadcast shutdown, usually sends BYE and stops all calls. The server does not terminate.
\li SIGTERM, SIGINT - broadcast shutdown (usually sends BYE and stops all calls), and stop.
\li SIGINT - broadcast shutdown (usually sends BYE and stops all calls), and stop. This also happens when sems is run in foreground and Ctrl-C is pressed.
\li SIGTERM - stop the server, without broadcasting shutdown (no BYEs sent).
\li SIGUSR1, SIGUSR2 - broadcast a system event with id User1 or User2, can for example be used in DSM with system(#type=="User2") condition
\section see_also See also

Loading…
Cancel
Save