From 3f86d161145df5a5ed65affcd432059900d57549 Mon Sep 17 00:00:00 2001 From: Benoit Foucher Date: Thu, 8 May 2008 12:22:27 +0200 Subject: Fixed bug 3096 - IceGrid registry or node abort on Solaris/64bits --- cpp/src/IceGrid/NodeSessionManager.cpp | 2 +- cpp/src/IceGrid/ReplicaSessionManager.cpp | 2 +- cpp/src/IceGrid/ReplicaSessionManager.h | 4 +- cpp/src/IceGrid/SessionManager.h | 172 ++++++++++++++++-------------- 4 files changed, 98 insertions(+), 82 deletions(-) (limited to 'cpp') diff --git a/cpp/src/IceGrid/NodeSessionManager.cpp b/cpp/src/IceGrid/NodeSessionManager.cpp index 38ee0b5343c..06ae7828d3f 100644 --- a/cpp/src/IceGrid/NodeSessionManager.cpp +++ b/cpp/src/IceGrid/NodeSessionManager.cpp @@ -19,7 +19,7 @@ using namespace IceGrid; NodeSessionKeepAliveThread::NodeSessionKeepAliveThread(const InternalRegistryPrx& registry, const NodeIPtr& node, const vector& queryObjects) : - SessionKeepAliveThread(registry), + SessionKeepAliveThread(registry, node->getTraceLevels()->logger), _node(node), _queryObjects(queryObjects) { diff --git a/cpp/src/IceGrid/ReplicaSessionManager.cpp b/cpp/src/IceGrid/ReplicaSessionManager.cpp index 665a8a4f08e..a1f4e26c229 100644 --- a/cpp/src/IceGrid/ReplicaSessionManager.cpp +++ b/cpp/src/IceGrid/ReplicaSessionManager.cpp @@ -300,7 +300,7 @@ ReplicaSessionManager::create(const string& name, _queryObjects.push_back(QueryPrx::uncheckedCast(query->ice_endpoints(singleEndpoint))); } - _thread = new Thread(*this, _master); + _thread = new Thread(*this, _master, _traceLevels->logger); _thread->start(); notifyAll(); } diff --git a/cpp/src/IceGrid/ReplicaSessionManager.h b/cpp/src/IceGrid/ReplicaSessionManager.h index dea09b439a7..49f052cb32f 100644 --- a/cpp/src/IceGrid/ReplicaSessionManager.h +++ b/cpp/src/IceGrid/ReplicaSessionManager.h @@ -37,8 +37,8 @@ public: { public: - Thread(ReplicaSessionManager& manager, const InternalRegistryPrx& master) : - SessionKeepAliveThread(master), + Thread(ReplicaSessionManager& manager, const InternalRegistryPrx& master, const Ice::LoggerPtr& logger) : + SessionKeepAliveThread(master, logger), _manager(manager) { } diff --git a/cpp/src/IceGrid/SessionManager.h b/cpp/src/IceGrid/SessionManager.h index 9340699dab5..7760241e865 100644 --- a/cpp/src/IceGrid/SessionManager.h +++ b/cpp/src/IceGrid/SessionManager.h @@ -42,8 +42,9 @@ class SessionKeepAliveThread : public IceUtil::Thread, public IceUtil::Monitor now) { - break; + timedWait(wakeTime - now); + now = IceUtil::Time::now(); } } + if(_nextAction == None) + { + _nextAction = session ? KeepAlive : Connect; + } } - if(_nextAction == None) + + if(_state == Destroyed) { - _nextAction = session ? KeepAlive : Connect; + break; } + + assert(_nextAction != None); + + action = _nextAction; + registry = InternalRegistryPrx::uncheckedCast( + _registry->ice_timeout(static_cast(timeout.toMilliSeconds()))); + _nextAction = None; + _state = InProgress; + notifyAll(); } - if(_state == Destroyed) + switch(action) { + case Connect: + assert(!session); + session = createSession(registry, timeout); + break; + case Disconnect: + assert(session); + destroySession(session); + session = 0; + break; + case KeepAlive: + assert(session); + if(!keepAlive(session)) + { + session = createSession(registry, timeout); + } break; + case None: + default: + assert(false); } - - assert(_nextAction != None); - - action = _nextAction; - registry = InternalRegistryPrx::uncheckedCast( - _registry->ice_timeout(static_cast(timeout.toMilliSeconds()))); - _nextAction = None; - _state = InProgress; - notifyAll(); } - - switch(action) + + // + // Destroy the session. + // + if(_nextAction == Disconnect && session) { - case Connect: - assert(!session); - session = createSession(registry, timeout); - break; - case Disconnect: - assert(session); destroySession(session); - session = 0; - break; - case KeepAlive: - assert(session); - if(!keepAlive(session)) - { - session = createSession(registry, timeout); - } - break; - case None: - default: - assert(false); } } - - // - // Destroy the session. - // - if(_nextAction == Disconnect && session) + catch(const std::exception& ex) + { + Ice::Error out(_logger); + out << "unknown exception in session manager keep alive thread:\n" << ex.what(); + throw; + } + catch(...) { - destroySession(session); + Ice::Error out(_logger); + out << "unknown exception in session manager keep alive thread"; + throw; } } @@ -274,6 +289,7 @@ public: protected: InternalRegistryPrx _registry; + Ice::LoggerPtr _logger; TPrx _session; State _state; Action _nextAction; -- cgit v1.2.3