diff options
-rw-r--r-- | cpp/src/Glacier2/Blobject.cpp | 8 | ||||
-rw-r--r-- | cpp/src/Glacier2/ClientBlobject.cpp | 38 | ||||
-rw-r--r-- | cpp/src/Glacier2/ClientBlobject.h | 5 | ||||
-rw-r--r-- | cpp/src/Glacier2/Makefile | 10 | ||||
-rw-r--r-- | cpp/src/Glacier2/RouterI.cpp | 1 | ||||
-rw-r--r-- | cpp/src/Glacier2/ServerBlobject.cpp | 11 | ||||
-rw-r--r-- | cpp/src/Glacier2/ServerBlobject.h | 1 | ||||
-rw-r--r-- | cpp/src/Glacier2/SessionRouterI.cpp | 53 | ||||
-rw-r--r-- | cpp/src/Glacier2/SessionRouterI.h | 20 |
9 files changed, 102 insertions, 45 deletions
diff --git a/cpp/src/Glacier2/Blobject.cpp b/cpp/src/Glacier2/Blobject.cpp index 011850c0905..334ecd3164a 100644 --- a/cpp/src/Glacier2/Blobject.cpp +++ b/cpp/src/Glacier2/Blobject.cpp @@ -34,10 +34,7 @@ Glacier2::Blobject::~Blobject() void Glacier2::Blobject::destroy() { - // - // No mutex protection necessary, destroy is only called after all - // object adapters have shut down. - // + assert(_requestQueue); // Destroyed? _requestQueue->destroy(); _requestQueue->getThreadControl().join(); _requestQueue = 0; @@ -73,6 +70,8 @@ void Glacier2::Blobject::invoke(ObjectPrx& proxy, const AMD_Object_ice_invokePtr& amdCB, const vector<Byte>& inParams, const Current& current) { + assert(_requestQueue); // Destroyed? + // // Set the correct facet on the proxy. // @@ -161,7 +160,6 @@ Glacier2::Blobject::invoke(ObjectPrx& proxy, const AMD_Object_ice_invokePtr& amd // // Create a new request and add it to the request queue. // - assert(_requestQueue); // Destroyed? if(proxy->ice_isTwoway()) { AMI_Object_ice_invokePtr amiCB = new Glacier2CB(amdCB); diff --git a/cpp/src/Glacier2/ClientBlobject.cpp b/cpp/src/Glacier2/ClientBlobject.cpp index ad3102ec247..f568efa27df 100644 --- a/cpp/src/Glacier2/ClientBlobject.cpp +++ b/cpp/src/Glacier2/ClientBlobject.cpp @@ -16,36 +16,39 @@ using namespace std; using namespace Ice; using namespace Glacier2; -static const string clientTraceReject = "Glacier2.Client.Trace.Reject"; - Glacier2::ClientBlobject::ClientBlobject(const CommunicatorPtr& communicator, const IceInternal::RoutingTablePtr& routingTable, - const string& allowCategories) : + const string& allow) : Glacier2::Blobject(communicator, false), _routingTable(routingTable), - _traceLevelReject(communicator->getProperties()->getPropertyAsInt(clientTraceReject)) + _rejectTraceLevel(communicator->getProperties()->getPropertyAsInt("Glacier2.Client.Trace.Reject")) { + vector<string>& allowCategories = const_cast<vector<string>&>(_allowCategories); + const string ws = " \t"; - string::size_type current = allowCategories.find_first_not_of(ws, 0); + string::size_type current = allow.find_first_not_of(ws, 0); while(current != string::npos) { - string::size_type pos = allowCategories.find_first_of(ws, current); + string::size_type pos = allow.find_first_of(ws, current); string::size_type len = (pos == string::npos) ? string::npos : pos - current; - string category = allowCategories.substr(current, len); - _allowCategories.push_back(category); - current = allowCategories.find_first_not_of(ws, pos); + string category = allow.substr(current, len); + allowCategories.push_back(category); + current = allow.find_first_not_of(ws, pos); } - sort(_allowCategories.begin(), _allowCategories.end()); // Must be sorted. - _allowCategories.erase(unique(_allowCategories.begin(), _allowCategories.end()), _allowCategories.end()); + + sort(allowCategories.begin(), allowCategories.end()); // Must be sorted. + allowCategories.erase(unique(allowCategories.begin(), allowCategories.end()), allowCategories.end()); +} + +Glacier2::ClientBlobject::~ClientBlobject() +{ + assert(!_routingTable); } void Glacier2::ClientBlobject::destroy() { - // - // No mutex protection necessary, destroy is only called after all - // object adapters have shut down. - // + assert(_routingTable); // Destroyed? _routingTable = 0; Blobject::destroy(); } @@ -54,6 +57,8 @@ void Glacier2::ClientBlobject::ice_invoke_async(const Ice::AMD_Object_ice_invokePtr& amdCB, const vector<Byte>& inParams, const Current& current) { + assert(_routingTable); // Destroyed? + // // If there is an _allowCategories set then enforce it. // @@ -61,7 +66,7 @@ Glacier2::ClientBlobject::ice_invoke_async(const Ice::AMD_Object_ice_invokePtr& { if(!binary_search(_allowCategories.begin(), _allowCategories.end(), current.id.category)) { - if(_traceLevelReject >= 1) + if(_rejectTraceLevel >= 1) { Trace out(current.adapter->getCommunicator()->getLogger(), "Glacier2"); out << "rejecting request\n"; @@ -73,7 +78,6 @@ Glacier2::ClientBlobject::ice_invoke_async(const Ice::AMD_Object_ice_invokePtr& } } - assert(_routingTable); // Destroyed? ObjectPrx proxy = _routingTable->get(current.id); if(!proxy) { diff --git a/cpp/src/Glacier2/ClientBlobject.h b/cpp/src/Glacier2/ClientBlobject.h index 9b1846dbd7e..412c3c9b485 100644 --- a/cpp/src/Glacier2/ClientBlobject.h +++ b/cpp/src/Glacier2/ClientBlobject.h @@ -24,6 +24,7 @@ class ClientBlobject : public Glacier2::Blobject public: ClientBlobject(const Ice::CommunicatorPtr&, const IceInternal::RoutingTablePtr&, const std::string&); + virtual ~ClientBlobject(); void destroy(); virtual void ice_invoke_async(const Ice::AMD_Object_ice_invokePtr&, const std::vector<Ice::Byte>&, @@ -32,8 +33,8 @@ public: private: IceInternal::RoutingTablePtr _routingTable; - std::vector<std::string> _allowCategories; - const int _traceLevelReject; + const std::vector<std::string> _allowCategories; + const int _rejectTraceLevel; }; } diff --git a/cpp/src/Glacier2/Makefile b/cpp/src/Glacier2/Makefile index 9427350c449..0afb181d187 100644 --- a/cpp/src/Glacier2/Makefile +++ b/cpp/src/Glacier2/Makefile @@ -18,7 +18,8 @@ ROUTER = $(top_srcdir)/bin/glacier2router LIBTARGETS = $(call mklibtargets,$(libdir)/$(LIBFILENAME),$(libdir)/$(SONAME),$(libdir)/$(LIBNAME)) TARGETS = $(LIBTARGETS) $(ROUTER) -OBJS = Router.o +OBJS = Router.o \ + PermissionsVerifier.o ROBJS = Glacier2Router.o \ SessionRouterI.o \ @@ -26,12 +27,15 @@ ROBJS = Glacier2Router.o \ Blobject.o \ ClientBlobject.o \ ServerBlobject.o \ - RequestQueue.o + RequestQueue.o \ + CryptPermissionsVerifierI.o + SRCS = $(OBJS:.o=.cpp) \ $(ROBJS:.o=.cpp) -SLICE_SRCS = $(SDIR)/Router.ice +SLICE_SRCS = $(SDIR)/Router.ice \ + $(SDIR)/PermissionsVerifier.ice HDIR = $(includedir)/Glacier2 SDIR = $(slicedir)/Glacier2 diff --git a/cpp/src/Glacier2/RouterI.cpp b/cpp/src/Glacier2/RouterI.cpp index 80b91a71a09..164fe4d0b61 100644 --- a/cpp/src/Glacier2/RouterI.cpp +++ b/cpp/src/Glacier2/RouterI.cpp @@ -93,6 +93,7 @@ Glacier2::RouterI::getServerProxy(const Current&) const void Glacier2::RouterI::addProxy(const ObjectPrx& proxy, const Current&) { + if(_routingTableTraceLevel) { Trace out(_communicator->getLogger(), "Glacier2"); diff --git a/cpp/src/Glacier2/ServerBlobject.cpp b/cpp/src/Glacier2/ServerBlobject.cpp index 691920f5a4f..43144e8f75e 100644 --- a/cpp/src/Glacier2/ServerBlobject.cpp +++ b/cpp/src/Glacier2/ServerBlobject.cpp @@ -20,13 +20,15 @@ Glacier2::ServerBlobject::ServerBlobject(const CommunicatorPtr& communicator, co { } +Glacier2::ServerBlobject::~ServerBlobject() +{ + assert(!_transport); +} + void Glacier2::ServerBlobject::destroy() { - // - // No mutex protection necessary, destroy is only called after all - // object adapters have shut down. - // + assert(_transport); // Destroyed? _transport = 0; Blobject::destroy(); } @@ -36,6 +38,7 @@ Glacier2::ServerBlobject::ice_invoke_async(const Ice::AMD_Object_ice_invokePtr& const Current& current) { assert(_transport); // Destroyed? + ObjectPrx proxy = _transport->createProxy(current.id); assert(proxy); diff --git a/cpp/src/Glacier2/ServerBlobject.h b/cpp/src/Glacier2/ServerBlobject.h index 17fc2f8862a..fa6b7b906de 100644 --- a/cpp/src/Glacier2/ServerBlobject.h +++ b/cpp/src/Glacier2/ServerBlobject.h @@ -23,6 +23,7 @@ class ServerBlobject : public Glacier2::Blobject public: ServerBlobject(const Ice::CommunicatorPtr&, const Ice::TransportInfoPtr&); + virtual ~ServerBlobject(); void destroy(); virtual void ice_invoke_async(const Ice::AMD_Object_ice_invokePtr&, const std::vector<Ice::Byte>&, diff --git a/cpp/src/Glacier2/SessionRouterI.cpp b/cpp/src/Glacier2/SessionRouterI.cpp index 0342c602dc2..86374159d72 100644 --- a/cpp/src/Glacier2/SessionRouterI.cpp +++ b/cpp/src/Glacier2/SessionRouterI.cpp @@ -49,6 +49,7 @@ Glacier2::SessionRouterI::SessionRouterI(const ObjectAdapterPtr& clientAdapter) _logger(clientAdapter->getCommunicator()->getLogger()), _clientAdapter(clientAdapter), _traceLevel(clientAdapter->getCommunicator()->getProperties()->getPropertyAsInt("Glacier2.Trace.Session")), + _sessionThread(new SessionThread(this)), _serverAdapterCount(0), _routersHint(_routers.end()), _destroy(false) @@ -65,38 +66,39 @@ Glacier2::SessionRouterI::~SessionRouterI() void Glacier2::SessionRouterI::destroy() { - IceUtil::Monitor<IceUtil::Mutex>::Lock lock(*this); - - assert(!_destroy); - - _destroy = true; - - for_each(_routers.begin(), _routers.end(), - Ice::secondVoidMemFun<const TransportInfoPtr, RouterI>(&RouterI::destroy)); - _routers.clear(); - _routersHint = _routers.end(); + { + IceUtil::Monitor<IceUtil::Mutex>::Lock lock(*this); + + assert(!_destroy); + + _destroy = true; + + for_each(_routers.begin(), _routers.end(), + Ice::secondVoidMemFun<const TransportInfoPtr, RouterI>(&RouterI::destroy)); + _routers.clear(); + _routersHint = _routers.end(); + + notify(); + } - notify(); + _sessionThread->getThreadControl().join(); } ObjectPrx Glacier2::SessionRouterI::getClientProxy(const Current& current) const { - assert(!_destroy); return getRouter(current.transport)->getClientProxy(current); // Forward to the per-client router. } ObjectPrx Glacier2::SessionRouterI::getServerProxy(const Current& current) const { - assert(!_destroy); return getRouter(current.transport)->getServerProxy(current); // Forward to the per-client router. } void Glacier2::SessionRouterI::addProxy(const ObjectPrx& proxy, const Current& current) { - assert(!_destroy); getRouter(current.transport)->addProxy(proxy, current); // Forward to the per-client router. } @@ -170,3 +172,26 @@ Glacier2::SessionRouterI::getRouter(const TransportInfoPtr& transport) const return 0; } } + +void +Glacier2::SessionRouterI::run() +{ + IceUtil::Monitor<IceUtil::Mutex>::Lock lock(*this); + + while(!_destroy) + { + wait(); + } +} + +Glacier2::SessionRouterI::SessionThread::SessionThread(const SessionRouterIPtr& sessionRouter) : + _sessionRouter(sessionRouter) +{ +} + +void +Glacier2::SessionRouterI::SessionThread::SessionThread::run() +{ + _sessionRouter->run(); + _sessionRouter = 0; // Break cyclic dependencies. +} diff --git a/cpp/src/Glacier2/SessionRouterI.h b/cpp/src/Glacier2/SessionRouterI.h index 196a17e4296..a614774cb1f 100644 --- a/cpp/src/Glacier2/SessionRouterI.h +++ b/cpp/src/Glacier2/SessionRouterI.h @@ -39,12 +39,32 @@ public: RouterIPtr getRouter(const Ice::TransportInfoPtr&) const; + virtual void run(); + private: const Ice::LoggerPtr _logger; const Ice::ObjectAdapterPtr _clientAdapter; const int _traceLevel; + // + // TODO: I can't inherit directly from IceUtil::Thread, because of + // the inheritance of GCShared. + // + class SessionThread : public IceUtil::Thread + { + public: + + SessionThread(const SessionRouterIPtr&); + + virtual void run(); + + private: + + SessionRouterIPtr _sessionRouter; + }; + const IceUtil::Handle<SessionThread> _sessionThread; + int _serverAdapterCount; std::map<Ice::TransportInfoPtr, RouterIPtr> _routers; |