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/SessionManager.h | 172 +++++++++++++++++++++------------------ 1 file changed, 94 insertions(+), 78 deletions(-) (limited to 'cpp/src/IceGrid/SessionManager.h') 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