From a2317af5826502bf9b85c779a79d42a9aba463a6 Mon Sep 17 00:00:00 2001 From: Tristan Matthews <tristan.matthews@savoirfairelinux.com> Date: Mon, 6 Aug 2012 16:30:29 -0400 Subject: [PATCH] * #11499: daemon: merge terminate and finish methods --- daemon/src/managerimpl.cpp | 34 +++++++++++++++++----------------- daemon/src/managerimpl.h | 5 ----- daemon/test/main.cpp | 4 ++-- 3 files changed, 19 insertions(+), 24 deletions(-) diff --git a/daemon/src/managerimpl.cpp b/daemon/src/managerimpl.cpp index 2a2e1db187..4138cf3630 100644 --- a/daemon/src/managerimpl.cpp +++ b/daemon/src/managerimpl.cpp @@ -131,24 +131,20 @@ void ManagerImpl::run() void ManagerImpl::finish() { - if (!finished_) { - finished_ = true; - // Unset signal handlers - signal(SIGHUP, SIG_DFL); - signal(SIGINT, SIG_DFL); - signal(SIGTERM, SIG_DFL); - terminate(); - dbus_.exit(); - } -} + if (finished_) + return; + + finished_ = true; + // Unset signal handlers + signal(SIGHUP, SIG_DFL); + signal(SIGINT, SIG_DFL); + signal(SIGTERM, SIG_DFL); -void ManagerImpl::terminate() -{ std::vector<std::string> callList(getCallList()); - DEBUG("Hangup %zu remaining call", callList.size()); + DEBUG("Hangup %zu remaining call(s)", callList.size()); for (std::vector<std::string>::iterator iter = callList.begin(); - iter != callList.end(); ++iter) + iter != callList.end(); ++iter) hangupCall(*iter); saveConfig(); @@ -160,10 +156,14 @@ void ManagerImpl::terminate() // the SIPVoIPLink, the link still needs the accounts for pjsip cleanup unloadAccountMap(); - ost::MutexLock lock(audioLayerMutex_); + { + ost::MutexLock lock(audioLayerMutex_); - delete audiodriver_; - audiodriver_ = NULL; + delete audiodriver_; + audiodriver_ = NULL; + } + + dbus_.exit(); } bool ManagerImpl::isCurrentCall(const std::string& callId) const diff --git a/daemon/src/managerimpl.h b/daemon/src/managerimpl.h index ef47fd2755..580a9c78bb 100644 --- a/daemon/src/managerimpl.h +++ b/daemon/src/managerimpl.h @@ -140,11 +140,6 @@ class ManagerImpl { */ void run(); - /** - * Terminate all thread (sound, link) and unload AccountMap - */ - void terminate(); - /* * Terminate all threads and exit DBus loop */ diff --git a/daemon/test/main.cpp b/daemon/test/main.cpp index f67d1b85ff..7688d6b42a 100644 --- a/daemon/test/main.cpp +++ b/daemon/test/main.cpp @@ -143,8 +143,8 @@ int main(int argc, char* argv[]) // Run the tests. bool wasSuccessful = runner.run(); - printf("=== Test suite terminate ===\n"); - Manager::instance().terminate(); + printf("=== Test suite ending ===\n"); + Manager::instance().finish(); restore(); -- GitLab