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
sayer/1.4-spce2.6
Stefan Sayer 16 years ago
parent 13f949c054
commit 75be85ab79

@ -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; i<AmConfig::SIPServerThreads;i++){
@ -251,15 +261,12 @@ void SipCtrlInterface::run(const string& bind_addr, unsigned short bind_port)
delete udp_servers[i];
}
trans_layer::instance()->register_transport(NULL);
delete [] udp_servers;
delete udp_socket;
}
void SipCtrlInterface::stop()
{
stopped.set(true);
}
int SipCtrlInterface::send(const AmSipReply &rep)
{
sip_msg msg;

@ -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<bool> 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.
*

@ -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);
}

Loading…
Cancel
Save