summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
authorBenoit Foucher <benoit@zeroc.com>2008-05-08 12:22:27 +0200
committerBenoit Foucher <benoit@zeroc.com>2008-05-08 12:22:27 +0200
commit3f86d161145df5a5ed65affcd432059900d57549 (patch)
treea3d77602281014f7297b20f0bf331dfd022ecfbb /cpp/src
parentFixed bug 3100 - C# binding test failure (diff)
downloadice-3f86d161145df5a5ed65affcd432059900d57549.tar.bz2
ice-3f86d161145df5a5ed65affcd432059900d57549.tar.xz
ice-3f86d161145df5a5ed65affcd432059900d57549.zip
Fixed bug 3096 - IceGrid registry or node abort on Solaris/64bits
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/IceGrid/NodeSessionManager.cpp2
-rw-r--r--cpp/src/IceGrid/ReplicaSessionManager.cpp2
-rw-r--r--cpp/src/IceGrid/ReplicaSessionManager.h4
-rw-r--r--cpp/src/IceGrid/SessionManager.h172
4 files changed, 98 insertions, 82 deletions
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<QueryPrx>& queryObjects) :
- SessionKeepAliveThread<NodeSessionPrx>(registry),
+ SessionKeepAliveThread<NodeSessionPrx>(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<ReplicaSessionPrx>(master),
+ Thread(ReplicaSessionManager& manager, const InternalRegistryPrx& master, const Ice::LoggerPtr& logger) :
+ SessionKeepAliveThread<ReplicaSessionPrx>(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<I
public:
- SessionKeepAliveThread(const InternalRegistryPrx& registry) :
+ SessionKeepAliveThread(const InternalRegistryPrx& registry, const Ice::LoggerPtr& logger) :
_registry(registry),
+ _logger(logger),
_state(InProgress),
_nextAction(None)
{
@@ -57,108 +58,122 @@ public:
IceUtil::Time timeout = IceUtil::Time::seconds(15);
Action action = Connect;
- while(true)
+ try
{
+ while(true)
{
- Lock sync(*this);
- if(_state == Destroyed)
{
- break;
- }
+ Lock sync(*this);
+ if(_state == Destroyed)
+ {
+ break;
+ }
- //
- // Update the current state.
- //
- assert(_state == InProgress);
- _state = session ? Connected : Disconnected;
- _session = session;
- if(_session)
- {
- _registry = registry;
- }
+ //
+ // Update the current state.
+ //
+ assert(_state == InProgress);
+ _state = session ? Connected : Disconnected;
+ _session = session;
+ if(_session)
+ {
+ _registry = registry;
+ }
- if(_nextAction == Connect && _state == Connected)
- {
- _nextAction = KeepAlive;
- }
- else if(_nextAction == Disconnect && _state == Disconnected)
- {
- _nextAction = None;
- }
- else if(_nextAction == KeepAlive && _state == Disconnected)
- {
- _nextAction = Connect;
- }
- notifyAll();
+ if(_nextAction == Connect && _state == Connected)
+ {
+ _nextAction = KeepAlive;
+ }
+ else if(_nextAction == Disconnect && _state == Disconnected)
+ {
+ _nextAction = None;
+ }
+ else if(_nextAction == KeepAlive && _state == Disconnected)
+ {
+ _nextAction = Connect;
+ }
+ notifyAll();
- //
- // Wait if there's nothing to do and if we are
- // connected or if we've just tried to connect.
- //
- if(_nextAction == None)
- {
- if(_state == Connected || action == Connect || action == KeepAlive)
+ //
+ // Wait if there's nothing to do and if we are
+ // connected or if we've just tried to connect.
+ //
+ if(_nextAction == None)
{
- IceUtil::Time wakeTime = IceUtil::Time::now() + timeout;
- while(_state != Destroyed && _nextAction == None)
+ if(_state == Connected || action == Connect || action == KeepAlive)
{
- if(!timedWait(wakeTime - IceUtil::Time::now()))
+ IceUtil::Time now = IceUtil::Time::now();
+ IceUtil::Time wakeTime = now + timeout;
+ while(_state != Destroyed && _nextAction == None && wakeTime > 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<int>(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<int>(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;