From 75be85ab79753f69fe6d62462012e0f57f43baa3 Mon Sep 17 00:00:00 2001 From: Stefan Sayer Date: Tue, 18 May 2010 22:05:09 +0000 Subject: [PATCH] fixed shutdown procedure: - session container needs to be stopped first, with everything else still in place, so sessions can stop/send BYE - UDP SIP transport is needed in shutdown procedure - event dispatcher is needed until the end (may be needed to post events while destructing things) git-svn-id: http://svn.berlios.de/svnroot/repos/sems/trunk@1916 8eb893ce-cfd4-0310-b710-fb5ebe64c474 --- core/SipCtrlInterface.cpp | 23 +++++++++++++++-------- core/SipCtrlInterface.h | 9 ++++++++- core/sems.cpp | 9 ++++++--- 3 files changed, 29 insertions(+), 12 deletions(-) diff --git a/core/SipCtrlInterface.cpp b/core/SipCtrlInterface.cpp index 9136f1d5..1520273e 100644 --- a/core/SipCtrlInterface.cpp +++ b/core/SipCtrlInterface.cpp @@ -226,11 +226,11 @@ void SipCtrlInterface::run(const string& bind_addr, unsigned short bind_port) { DBG("Starting SIP control interface\n"); - udp_trsp_socket* udp_socket = new udp_trsp_socket; + udp_socket = new udp_trsp_socket; udp_socket->bind(bind_addr,bind_port); trans_layer::instance()->register_transport(udp_socket); - udp_trsp** udp_servers = new udp_trsp*[AmConfig::SIPServerThreads]; + udp_servers = new udp_trsp*[AmConfig::SIPServerThreads]; wheeltimer::instance()->start(); @@ -242,7 +242,17 @@ void SipCtrlInterface::run(const string& bind_addr, unsigned short bind_port) while (!stopped.get()) { stopped.wait_for(); } - + + DBG("SIP control interface ending\n"); +} + +void SipCtrlInterface::stop() +{ + stopped.set(true); +} + +void SipCtrlInterface::cleanup() +{ DBG("Stopping SIP control interface threads\n"); for(int i=0; iregister_transport(NULL); + delete [] udp_servers; delete udp_socket; } -void SipCtrlInterface::stop() -{ - stopped.set(true); -} - int SipCtrlInterface::send(const AmSipReply &rep) { sip_msg msg; diff --git a/core/SipCtrlInterface.h b/core/SipCtrlInterface.h index 5d27e819..105c80da 100644 --- a/core/SipCtrlInterface.h +++ b/core/SipCtrlInterface.h @@ -43,6 +43,9 @@ struct sip_header; class trans_ticket; +class udp_trsp_socket; +class udp_trsp; + class SipCtrlInterface: public sip_ua { @@ -53,6 +56,9 @@ class SipCtrlInterface: AmCondition stopped; + udp_trsp_socket* udp_socket; + udp_trsp** udp_servers; + public: static string outbound_host; @@ -68,7 +74,8 @@ public: void run(const string& bind_addr, unsigned short bind_port); void stop(); - + void cleanup(); + /** * Sends a SIP request. * diff --git a/core/sems.cpp b/core/sems.cpp index 7fff629b..e07b1b8b 100644 --- a/core/sems.cpp +++ b/core/sems.cpp @@ -606,15 +606,16 @@ int main(int argc, char* argv[]) success = true; + // session container stops active sessions + INFO("Disposing session container\n"); + AmSessionContainer::dispose(); + INFO("Disposing RTP receiver\n"); AmRtpReceiver::dispose(); INFO("Disposing media processor\n"); AmMediaProcessor::dispose(); - INFO("Disposing session container\n"); - AmSessionContainer::dispose(); - INFO("Disposing event dispatcher\n"); AmEventDispatcher::dispose(); @@ -628,6 +629,8 @@ int main(int argc, char* argv[]) } #endif + sip_ctrl.cleanup(); + INFO("Exiting (%s)\n", success ? "success" : "failure"); return (success ? EXIT_SUCCESS : EXIT_FAILURE); }