Module: sems Branch: master Commit: f1b8362ef0ad7a1f9d59bc614326acfc1112908d URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sems/?a=commit;h=f1b8362ef0ad7a1f9d59bc614326acfc1112908d
Author: Stefan Sayer <[email protected]> Committer: Stefan Sayer <[email protected]> Date: Wed Sep 22 15:49:04 2010 +0200 handle SIGHUP: stop sessions (send BYE), dont quit --- core/AmSessionContainer.cpp | 12 ++++++++---- core/AmSessionContainer.h | 5 +++++ core/sems.cpp | 5 +++++ doc/doxygen_proj | 2 +- doc/src/doc_signals.h | 16 ++++++++++++++++ doc/src/doxyref.h | 1 + 6 files changed, 36 insertions(+), 5 deletions(-) diff --git a/core/AmSessionContainer.cpp b/core/AmSessionContainer.cpp index 8777fbc..65b7c18 100644 --- a/core/AmSessionContainer.cpp +++ b/core/AmSessionContainer.cpp @@ -138,14 +138,18 @@ void AmSessionContainer::run() DBG("Session cleaner terminating\n"); } -void AmSessionContainer::on_stop() -{ - _container_closed.set(true); - +void AmSessionContainer::broadcastShutdown() { DBG("brodcasting ServerShutdown system event to %u sessions...\n", AmSession::getSessionNum()); AmEventDispatcher::instance()-> broadcast(new AmSystemEvent(AmSystemEvent::ServerShutdown)); +} + +void AmSessionContainer::on_stop() +{ + _container_closed.set(true); + + broadcastShutdown(); DBG("waiting for active event queues to stop...\n"); diff --git a/core/AmSessionContainer.h b/core/AmSessionContainer.h index ec99afa..e3644bd 100644 --- a/core/AmSessionContainer.h +++ b/core/AmSessionContainer.h @@ -143,6 +143,11 @@ class AmSessionContainer : public AmThread */ bool postEvent(const string& local_tag, AmEvent* event); + /** + * broadcasts a server shutdown system event to all sessions + */ + void broadcastShutdown(); + _MONITORING_DEFINE_INTERFACE; }; diff --git a/core/sems.cpp b/core/sems.cpp index f1dfb6b..6d6ed18 100644 --- a/core/sems.cpp +++ b/core/sems.cpp @@ -203,6 +203,11 @@ static void signal_handler(int sig) { WARN("Signal %s (%d) received.\n", strsignal(sig), sig); + if ( sig == SIGHUP) { + AmSessionContainer::instance()->broadcastShutdown(); + return; + } + if (sig == SIGCHLD && AmConfig::IgnoreSIGCHLD) { return; } diff --git a/doc/doxygen_proj b/doc/doxygen_proj index e97384d..e674212 100644 --- a/doc/doxygen_proj +++ b/doc/doxygen_proj @@ -605,7 +605,7 @@ RECURSIVE = YES # excluded from the INPUT source files. This way you can easily exclude a # subdirectory from a directory tree whose root is specified with the INPUT tag. -EXCLUDE = .svn \ +EXCLUDE = .svn .git \ ../apps/xmlrpc2di/xmlrpc++ \ ../core/plug-in/ilbc/iLBC_rfc3951 \ ../core/plug-in/gsm/gsm-1.0-pl10 \ diff --git a/doc/src/doc_signals.h b/doc/src/doc_signals.h new file mode 100644 index 0000000..d00729d --- /dev/null +++ b/doc/src/doc_signals.h @@ -0,0 +1,16 @@ +/*! \page signalsdoc SEMS signal handling + +\section sigtitle How signals are handled by SEMS + +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. + +\section see_also See also + + \li max_shutdown_time in sems.conf: \ref sems.conf.sample + + + */ diff --git a/doc/src/doxyref.h b/doc/src/doxyref.h index 80d95c5..1e52bbc 100644 --- a/doc/src/doxyref.h +++ b/doc/src/doxyref.h @@ -20,6 +20,7 @@ * \arg \ref AppDoc * \arg \ref ModuleDoc_dsm * \arg \ref ZRTP + * \arg \ref signalsdoc * \arg \ref Tuning * * \section developerdoc Developer's documentation _______________________________________________ Semsdev mailing list [email protected] http://lists.iptel.org/mailman/listinfo/semsdev
