From c7df7e63fba4eb49cc12b92f85ef25850fbb5b63 Mon Sep 17 00:00:00 2001 From: Ondrej Martine Date: Fri, 30 Apr 2010 14:02:35 +0000 Subject: [PATCH] * add possibility to stop the new SIP controller git-svn-id: http://svn.berlios.de/svnroot/repos/sems/trunk@1869 8eb893ce-cfd4-0310-b710-fb5ebe64c474 --- core/SipCtrlInterface.cpp | 18 +++++++++++++++--- core/SipCtrlInterface.h | 5 ++++- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/core/SipCtrlInterface.cpp b/core/SipCtrlInterface.cpp index 0cc13a61..095b0128 100644 --- a/core/SipCtrlInterface.cpp +++ b/core/SipCtrlInterface.cpp @@ -113,6 +113,7 @@ int SipCtrlInterface::load() } SipCtrlInterface::SipCtrlInterface() + : stopped(false) { trans_layer::instance()->register_ua(this); } @@ -222,13 +223,12 @@ int SipCtrlInterface::send(AmSipRequest &req) void SipCtrlInterface::run(const string& bind_addr, unsigned short bind_port) { - INFO("Starting SIP control interface\n"); + DBG("Starting SIP control interface\n"); 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]; wheeltimer::instance()->start(); @@ -237,8 +237,15 @@ void SipCtrlInterface::run(const string& bind_addr, unsigned short bind_port) udp_servers[i] = new udp_trsp(udp_socket); udp_servers[i]->start(); } - + + while (!stopped.get()) { + stopped.wait_for(); + } + + DBG("Stopping SIP control interface threads\n"); + for(int i=0; istop(); udp_servers[i]->join(); delete udp_servers[i]; } @@ -247,6 +254,11 @@ void SipCtrlInterface::run(const string& bind_addr, unsigned short bind_port) 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 a0a2885d..45fc95bd 100644 --- a/core/SipCtrlInterface.h +++ b/core/SipCtrlInterface.h @@ -51,6 +51,8 @@ class SipCtrlInterface: friend class udp_trsp; + AmCondition stopped; + public: static string outbound_host; @@ -66,7 +68,8 @@ public: int load(); void run(const string& bind_addr, unsigned short bind_port); - + void stop(); + /** * Sends a SIP request. *