summaryrefslogtreecommitdiff
path: root/cpp/src/IceGrid/SessionI.cpp
diff options
context:
space:
mode:
authorMatthew Newhook <matthew@zeroc.com>2006-09-04 01:14:49 +0000
committerMatthew Newhook <matthew@zeroc.com>2006-09-04 01:14:49 +0000
commit25aff3e218350ea323a55ca7fa4247d9da61aac7 (patch)
tree2f04fb173eacceb007dda8696414c1d370f4c442 /cpp/src/IceGrid/SessionI.cpp
parentfixing a bug with generated #include statements (diff)
downloadice-25aff3e218350ea323a55ca7fa4247d9da61aac7.tar.bz2
ice-25aff3e218350ea323a55ca7fa4247d9da61aac7.tar.xz
ice-25aff3e218350ea323a55ca7fa4247d9da61aac7.zip
http://bugzilla.zeroc.com/bugzilla/show_bug.cgi?id=1331
Diffstat (limited to 'cpp/src/IceGrid/SessionI.cpp')
-rw-r--r--cpp/src/IceGrid/SessionI.cpp60
1 files changed, 58 insertions, 2 deletions
diff --git a/cpp/src/IceGrid/SessionI.cpp b/cpp/src/IceGrid/SessionI.cpp
index d6e608f1049..5cb8d3b42f2 100644
--- a/cpp/src/IceGrid/SessionI.cpp
+++ b/cpp/src/IceGrid/SessionI.cpp
@@ -13,6 +13,7 @@
#include <IceGrid/QueryI.h>
#include <IceGrid/LocatorI.h>
#include <IceGrid/Database.h>
+#include <IceGrid/Admin.h>
#include <IceSSL/Plugin.h>
@@ -154,6 +155,57 @@ BaseSessionI::setServantLocator(const SessionServantLocatorIPtr& servantLocator)
const_cast<SessionServantLocatorIPtr&>(_servantLocator) = servantLocator;
}
+SessionReapable::SessionReapable(const Ice::ObjectAdapterPtr& adapter,
+ const Ice::ObjectPtr& session,
+ const Ice::Identity& id) :
+ _adapter(adapter),
+ _servant(session),
+ _session(dynamic_cast<BaseSessionI*>(_servant.get())),
+ _id(id)
+{
+}
+
+SessionReapable::~SessionReapable()
+{
+}
+
+IceUtil::Time
+SessionReapable::timestamp() const
+{
+ return _session->timestamp();
+}
+
+void
+SessionReapable::destroy(bool destroy)
+{
+ try
+ {
+ //
+ // Invoke on the servant directly instead of the
+ // proxy. Invoking on the proxy might not always work if the
+ // communicator is being shutdown/destroyed. We have to create
+ // a fake "current" because the session destroy methods needs
+ // the adapter and object identity to unregister the servant
+ // from the adapter.
+ //
+ Ice::Current current;
+ if(!destroy)
+ {
+ current.adapter = _adapter;
+ current.id = _id;
+ }
+ _session->destroy(current);
+ }
+ catch(const Ice::ObjectNotExistException&)
+ {
+ }
+ catch(const Ice::LocalException& ex)
+ {
+ Ice::Warning out(_adapter->getCommunicator()->getLogger());
+ out << "unexpected exception while reaping node session:\n" << ex;
+ }
+}
+
SessionI::SessionI(const string& id,
const DatabasePtr& database,
const WaitQueuePtr& waitQueue,
@@ -282,10 +334,12 @@ SessionI::removeAllocation(const AllocatablePtr& allocatable)
ClientSessionFactory::ClientSessionFactory(const Ice::ObjectAdapterPtr& adapter,
const DatabasePtr& database,
- const WaitQueuePtr& waitQueue) :
+ const WaitQueuePtr& waitQueue,
+ const ReapThreadPtr& reapThread) :
_adapter(adapter),
_database(database),
- _waitQueue(waitQueue)
+ _waitQueue(waitQueue),
+ _reapThread(reapThread)
{
}
@@ -320,6 +374,8 @@ ClientSessionFactory::createGlacier2Session(const string& sessionId, const Glaci
}
}
+ _reapThread->add(new SessionReapable(_adapter, session, s->ice_getIdentity()), ctl->getSessionTimeout());
+
return s;
}