[Sofaswitch-svn] [commit] r438 - in sofaswitch/trunk: am mcu voip
Author: derek Date: Sun Jul 27 22:22:05 2008 New Revision: 438 Modified: sofaswitch/trunk/am/main.cxx sofaswitch/trunk/am/manager.cxx sofaswitch/trunk/am/manager.h sofaswitch/trunk/am/supervisor.cxx sofaswitch/trunk/mcu/main.cxx sofaswitch/trunk/mcu/manager.cxx sofaswitch/trunk/mcu/manager.h sofaswitch/trunk/voip/main.cxx sofaswitch/trunk/voip/mymanager.cxx sofaswitch/trunk/voip/mymanager.h Log: Correctly cope with the times when the supervisor could not connect to the server. Should be more robust now on startup.. Modified: sofaswitch/trunk/am/main.cxx ============================================================================== --- sofaswitch/trunk/am/main.cxx (original) +++ sofaswitch/trunk/am/main.cxx Sun Jul 27 22:22:05 2008 @@ -29,6 +29,7 @@ #include "manager.h" #include "main.h" #include <sofa/messages.h> +#include "supervisor.h" #include "version.h" @@ -128,20 +129,24 @@ } LaunchNewId lid(ourId, ourPassword); - opal = new Manager(lid, ourId, ourPassword); - opal->StartSupervisor(); - if (opal->WaitUntilSupervisorOk()) - opal->Main(); - else - cerr << "The supervisor did not connect to the remote server. Sigh" << endl; - - PTRACE(3, "Now end the opal thing"); - - opal->WaitForSupervisorEnd(); + Supervisor *s = NULL;; + do { + if (s != NULL) { + s->Terminate(); + s->WaitForTermination(); + delete s; + } + s = new Supervisor(lid); + s->Resume(); + s->WaitUntilInitialised(); + } + while (s->IsTerminating()); + opal = new Manager(lid, s, ourId, ourPassword); + opal->Main(); delete opal; - + delete s; PThread::Sleep(1000); } Modified: sofaswitch/trunk/am/manager.cxx ============================================================================== --- sofaswitch/trunk/am/manager.cxx (original) +++ sofaswitch/trunk/am/manager.cxx Sun Jul 27 22:22:05 2008 @@ -45,9 +45,11 @@ //////////////////////////////////////////////////////////////////////////////// Manager::Manager(LaunchNewId & _lid, - PString & _ourId, PString & _ourPassword) + Supervisor *s, + PString & _ourId, + PString & _ourPassword) : lid(_lid), - supervisor(*(new Supervisor(lid))), + supervisor(*s), ourPassword(_ourPassword), ourId(_ourId), runningComms(NULL) @@ -68,17 +70,11 @@ /* eradicate all current calls */ supervisor.Terminate(); supervisor.WaitForTermination(); - delete & supervisor; delete runningComms; runningComms = NULL; } -void Manager::StartSupervisor() -{ - supervisor.Resume(); -} - Comms * Manager::ClearCommsId(const PString &memberId) { PTRACE(3, "Clear comms Id on " << memberId); @@ -111,16 +107,6 @@ return NULL; } -bool Manager::WaitUntilSupervisorOk() -{ - return supervisor.WaitUntilInitialised(); -} - -void Manager::WaitForSupervisorEnd() -{ - supervisor.WaitForTermination(); -} - void Manager::RequestNewId(const PStringArray & cmds, const PString & requester) { Modified: sofaswitch/trunk/am/manager.h ============================================================================== --- sofaswitch/trunk/am/manager.h (original) +++ sofaswitch/trunk/am/manager.h Sun Jul 27 22:22:05 2008 @@ -66,7 +66,10 @@ public: /**Constructor */ - Manager(LaunchNewId & lid, PString & ourId, PString & ourPassword); + Manager(LaunchNewId & lid, + Supervisor *_supervisor, + PString & ourId, + PString & ourPassword); /**destructor */ ~Manager(); @@ -120,16 +123,6 @@ RequestNewId commands */ Comms *RemoveFromPreCallQueue(const PString & preferredId); - /**Get the supervisor to start processing messages */ - void StartSupervisor(); - - /**Wait (up to 1 second) to see if the supervisor is installed and - connected OK. */ - bool WaitUntilSupervisorOk(); - - /**Wait until the supervisor has finished */ - void WaitForSupervisorEnd(); - /**Cause the comms instance in activeCalls to be moved to the dead comms list. Give no error if the specified comms instance could not be found */ Modified: sofaswitch/trunk/am/supervisor.cxx ============================================================================== --- sofaswitch/trunk/am/supervisor.cxx (original) +++ sofaswitch/trunk/am/supervisor.cxx Sun Jul 27 22:22:05 2008 @@ -67,10 +67,7 @@ void Supervisor::OnTermination() { - Manager *mgr = AmProcess::Current().GetManager(); - mgr->RemoveAllCalls(); - - PTRACE(3, "Destructor Supervisor thread has ended"); + PTRACE(3, "Supervisor thread has ended"); } void Supervisor::ProcessCallNode(const PStringArray & cmds, const PString & sender) Modified: sofaswitch/trunk/mcu/main.cxx ============================================================================== --- sofaswitch/trunk/mcu/main.cxx (original) +++ sofaswitch/trunk/mcu/main.cxx Sun Jul 27 22:22:05 2008 @@ -32,6 +32,7 @@ #include "manager.h" #include "main.h" #include "sofa/messages.h" +#include "supervisor.h" #include "version.h" @@ -134,19 +135,28 @@ PTRACE(3, "Select a default password of " << ourPassword); } - LaunchNewId lid(ourId, ourPassword); - opal = new Manager(lid, ourId, ourPassword); - opal->StartSupervisor(); - - if (opal->WaitUntilSupervisorOk()) - opal->Main(); - else - cerr << "The supervisor did not connect to the remote server. Sigh" << endl; + LaunchNewId lid(ourId, ourPassword); + Supervisor *s = NULL; + do { + if (s != NULL) { + s->Terminate(); + s->WaitForTermination(); + delete s; + } + s = new Supervisor(lid); + s->Resume(); + s->WaitUntilInitialised(); + } + while (s->IsTerminating()); + + opal = new Manager(lid, s, ourId, ourPassword); - PTRACE(3, "Now end the opal thing"); - opal->WaitForSupervisorEnd(); + opal->Main(); delete opal; + + delete s; + PThread::Sleep(1000); } Modified: sofaswitch/trunk/mcu/manager.cxx ============================================================================== --- sofaswitch/trunk/mcu/manager.cxx (original) +++ sofaswitch/trunk/mcu/manager.cxx Sun Jul 27 22:22:05 2008 @@ -56,9 +56,10 @@ ///////////////////////////////////////////////////////////////////////////// Manager::Manager(LaunchNewId & _lid, - PString & _ourId, PString & _ourPassword) + Supervisor * _supervisor, + PString & _ourId, PString & _ourPassword) : lid(_lid), - supervisor(*(new Supervisor(lid))), + supervisor(* _supervisor), ourPassword(_ourPassword), ourId(_ourId), runningComms(NULL) @@ -88,8 +89,6 @@ delete runningComms; runningComms = NULL; - delete & supervisor; - garbageExit.Signal(); garbageFinished.Wait(); @@ -154,21 +153,6 @@ PTRACE(3, "Manager\tFinish CollectGarbage"); } -bool Manager::WaitUntilSupervisorOk() -{ - return supervisor.WaitUntilInitialised(); -} - -void Manager::WaitForSupervisorEnd() -{ - supervisor.WaitForTermination(); -} - -void Manager::StartSupervisor() -{ - supervisor.Resume(); -} - void Manager::RemoveMemberId(const PString & memberId) { PTRACE(3, "Remove MemberID \"" << memberId << "\" START"); Modified: sofaswitch/trunk/mcu/manager.h ============================================================================== --- sofaswitch/trunk/mcu/manager.h (original) +++ sofaswitch/trunk/mcu/manager.h Sun Jul 27 22:22:05 2008 @@ -62,7 +62,10 @@ public: /**Constructor */ - Manager(LaunchNewId & lid, PString & ourId, PString & ourPassword); + Manager(LaunchNewId & lid, + Supervisor *s, + PString & ourId, + PString & ourPassword); /**destructor */ ~Manager(); @@ -124,16 +127,6 @@ RequestNewId commands */ Comms *RemoveFromPreCallQueue(const PString & preferredId); - /**Wait (up to 1 second) to see if the supervisor is installed and - connected OK. */ - bool WaitUntilSupervisorOk(); - - /**Get the supervisor to start processing messages */ - void StartSupervisor(); - - /**Wait until the supervisor has finished */ - void WaitForSupervisorEnd(); - /**Get the status on all conferences, or just one conference */ PString ProcessStatusQuery(const PStringArray & cmds); Modified: sofaswitch/trunk/voip/main.cxx ============================================================================== --- sofaswitch/trunk/voip/main.cxx (original) +++ sofaswitch/trunk/voip/main.cxx Sun Jul 27 22:22:05 2008 @@ -52,6 +52,7 @@ #include "main.h" #include <sofa/messages.h> #include "counts.h" +#include "supervisor.h" #include "version.h" @@ -278,7 +279,19 @@ } LaunchNewId lid(ourId, ourPassword); - opal = new MyManager(lid, ourId, ourPassword); + Supervisor *s = NULL;; + do { + if (s != NULL) { + s->Terminate(); + s->WaitForTermination(); + delete s; + } + s = new Supervisor(lid); + s->Resume(); + s->WaitUntilInitialised(); + } + while (s->IsTerminating()); + opal = new MyManager(lid, s,ourId, ourPassword); if (opal->Initialise(args)) { opal->Main(args); Modified: sofaswitch/trunk/voip/mymanager.cxx ============================================================================== --- sofaswitch/trunk/voip/mymanager.cxx (original) +++ sofaswitch/trunk/voip/mymanager.cxx Sun Jul 27 22:22:05 2008 @@ -82,10 +82,11 @@ /////////////////////////////////////////////////////////////// MyManager::MyManager(LaunchNewId & _lid, + Supervisor * _supervisor, PString & _ourId, PString & _ourPassword) : lid(_lid), -supervisor(*(new Supervisor(lid))), -runningComms(*new CommsProvider(lid, *this)) + supervisor(*_supervisor), + runningComms(*new CommsProvider(lid, *this)) { allocationNumber = 0; IncMyManager(); @@ -126,12 +127,6 @@ bool MyManager::Initialise(PArgList & args) { - if (!supervisor.WaitUntilInitialised()) { - cerr << "The supervisor could not connect to the remote server. Sorry." << endl; - return false; - } - - if (args.HasOption('j')) { unsigned minJitter; unsigned maxJitter; Modified: sofaswitch/trunk/voip/mymanager.h ============================================================================== --- sofaswitch/trunk/voip/mymanager.h (original) +++ sofaswitch/trunk/voip/mymanager.h Sun Jul 27 22:22:05 2008 @@ -66,7 +66,9 @@ public: /**Constructor */ - MyManager(LaunchNewId & lid, PString & ourId, PString & ourPassword); + MyManager(LaunchNewId & lid, + Supervisor * _supervisor, + PString & ourId, PString & ourPassword); /**destructor */ ~MyManager();
participants (1)
-
SofaSWITCH SVN