summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/Glacier/ClientBlobject.cpp14
-rw-r--r--cpp/src/Glacier/ClientBlobject.h5
-rw-r--r--cpp/src/Glacier/GlacierRouter.cpp8
-rw-r--r--cpp/src/Glacier/RouterI.cpp14
-rw-r--r--cpp/src/Glacier/RouterI.h9
-rw-r--r--cpp/src/Ice/ThreadPool.cpp12
6 files changed, 31 insertions, 31 deletions
diff --git a/cpp/src/Glacier/ClientBlobject.cpp b/cpp/src/Glacier/ClientBlobject.cpp
index e0562ec718d..6821a2bfd69 100644
--- a/cpp/src/Glacier/ClientBlobject.cpp
+++ b/cpp/src/Glacier/ClientBlobject.cpp
@@ -28,15 +28,17 @@ Glacier::ClientBlobject::ClientBlobject(const CommunicatorPtr& communicator,
_traceLevel = properties->getPropertyAsInt("Glacier.Router.Trace.Client");
const string ws = " \t";
- size_t current = allowCategories.find_first_not_of(ws, 0);
+ string::size_type current = allowCategories.find_first_not_of(ws, 0);
while (current != string::npos)
{
- size_t pos = allowCategories.find_first_of(ws, current);
- size_t len = (pos == string::npos) ? string::npos : pos - current;
+ string::size_type pos = allowCategories.find_first_of(ws, current);
+ string::size_type len = (pos == string::npos) ? string::npos : pos - current;
string category = allowCategories.substr(current, len);
- _allowCategories.insert(category);
+ _allowCategories.push_back(category);
current = allowCategories.find_first_not_of(ws, pos);
}
+ sort(_allowCategories.begin(), _allowCategories.end()); // Must be sorted.
+ _allowCategories.erase(unique(_allowCategories.begin(), _allowCategories.end()), _allowCategories.end());
}
Glacier::ClientBlobject::~ClientBlobject()
@@ -63,11 +65,11 @@ Glacier::ClientBlobject::ice_invoke(const std::vector<Byte>& inParams, std::vect
assert(_communicator); // Destroyed?
//
- // If there is an allowCategories set then enforce it.
+ // If there is an _allowCategories set then enforce it.
//
if (!_allowCategories.empty())
{
- if (_allowCategories.find(current.identity.category) == _allowCategories.end())
+ if (!binary_search(_allowCategories.begin(), _allowCategories.end(), current.identity.category))
{
if (_traceLevel > 0)
{
diff --git a/cpp/src/Glacier/ClientBlobject.h b/cpp/src/Glacier/ClientBlobject.h
index 09848dae8b1..8ca92e91362 100644
--- a/cpp/src/Glacier/ClientBlobject.h
+++ b/cpp/src/Glacier/ClientBlobject.h
@@ -23,7 +23,7 @@ class ClientBlobject : public Ice::Blobject
{
public:
- ClientBlobject(const Ice::CommunicatorPtr&, const IceInternal::RoutingTablePtr&, const ::std::string&);
+ ClientBlobject(const Ice::CommunicatorPtr&, const IceInternal::RoutingTablePtr&, const std::string&);
virtual ~ClientBlobject();
void destroy();
@@ -35,8 +35,7 @@ private:
Ice::LoggerPtr _logger;
int _traceLevel;
IceInternal::RoutingTablePtr _routingTable;
-
- ::std::set< ::std::string> _allowCategories;
+ std::vector<std::string> _allowCategories;
};
}
diff --git a/cpp/src/Glacier/GlacierRouter.cpp b/cpp/src/Glacier/GlacierRouter.cpp
index 5e8e0c8e82b..6f885d3c792 100644
--- a/cpp/src/Glacier/GlacierRouter.cpp
+++ b/cpp/src/Glacier/GlacierRouter.cpp
@@ -187,13 +187,12 @@ Glacier::RouterApp::run(int argc, char* argv[])
serverAdapter = communicator()->createObjectAdapterFromProperty("Server", serverEndpointsProperty);
}
- const char* allowCategoriesProperty = "Glacier.Router.AllowCategories";
- string allowCategories = properties->getProperty(allowCategoriesProperty);
-
//
// Create the client and server blobjects and the associated
// servant locators.
//
+ const char* allowCategoriesProperty = "Glacier.Router.AllowCategories";
+ string allowCategories = properties->getProperty(allowCategoriesProperty);
ObjectPtr clientBlobject = new ClientBlobject(communicator(), routingTable, allowCategories);
Ice::ServantLocatorPtr clientServantLocator = new Glacier::ServantLocator(clientBlobject);
clientAdapter->addServantLocator(clientServantLocator, "");
@@ -283,6 +282,9 @@ Glacier::RouterApp::run(int argc, char* argv[])
// Destroy the router. The client and server blobjects get
// destroyed by ServantLocator::deactivate.
//
+ // Destroying the router will also destroy all sessions associated
+ // with the router.
+ //
RouterI* rtr = dynamic_cast<RouterI*>(router.get());
assert(rtr);
rtr->destroy();
diff --git a/cpp/src/Glacier/RouterI.cpp b/cpp/src/Glacier/RouterI.cpp
index 0876787bd86..c39459dd932 100644
--- a/cpp/src/Glacier/RouterI.cpp
+++ b/cpp/src/Glacier/RouterI.cpp
@@ -37,6 +37,7 @@ Glacier::RouterI::RouterI(const ObjectAdapterPtr& clientAdapter,
Glacier::RouterI::~RouterI()
{
assert(!_clientAdapter);
+ assert(_sessions.empty());
}
void
@@ -50,6 +51,11 @@ Glacier::RouterI::destroy()
_serverAdapter = 0;
_logger = 0;
_routingTable = 0;
+ for (vector<SessionPrx>::const_iterator p = _sessions.begin(); p != _sessions.end(); ++p)
+ {
+ (*p)->destroy();
+ }
+ _sessions.clear();
}
ObjectPrx
@@ -94,14 +100,6 @@ Glacier::RouterI::shutdown(const Current&)
{
assert(_routingTable);
_clientAdapter->getCommunicator()->shutdown();
-
- IceUtil::Mutex::Lock lock(_sessionMutex);
-
- for (list<SessionPrx>::const_iterator p = _sessions.begin(); p != _sessions.end(); ++p)
- {
- (*p)->stop();
- }
- _sessions.clear();
}
SessionPrx
diff --git a/cpp/src/Glacier/RouterI.h b/cpp/src/Glacier/RouterI.h
index 9c38887c453..03a3aaee906 100644
--- a/cpp/src/Glacier/RouterI.h
+++ b/cpp/src/Glacier/RouterI.h
@@ -13,12 +13,9 @@
#include <Ice/RoutingTableF.h>
#include <Ice/Ice.h>
-
#include <Glacier/Router.h>
#include <Glacier/SessionManagerF.h>
-#include <list>
-
namespace Glacier
{
@@ -27,7 +24,7 @@ class RouterI : public Router
public:
RouterI(const Ice::ObjectAdapterPtr&, const Ice::ObjectAdapterPtr&, const ::IceInternal::RoutingTablePtr&,
- const SessionManagerPrx&, const ::std::string&);
+ const SessionManagerPrx&, const std::string&);
virtual ~RouterI();
@@ -49,8 +46,8 @@ private:
IceUtil::Mutex _sessionMutex;
SessionManagerPrx _sessionManager;
- ::std::list<SessionPrx> _sessions;
- ::std::string _userId;
+ std::vector<SessionPrx> _sessions;
+ std::string _userId;
};
}
diff --git a/cpp/src/Ice/ThreadPool.cpp b/cpp/src/Ice/ThreadPool.cpp
index 8c5b0faa5bb..98166dbd201 100644
--- a/cpp/src/Ice/ThreadPool.cpp
+++ b/cpp/src/Ice/ThreadPool.cpp
@@ -142,13 +142,15 @@ IceInternal::ThreadPool::ThreadPool(const InstancePtr& instance, bool server) :
_threads.push_back(thread->start());
}
}
- catch (const IceUtil::Exception&)
+ catch (const IceUtil::Exception& ex)
{
- //
- // TODO: This doesn't look correct to me -- where are the
- // started threads joined with in the event of a failure?
- //
+ {
+ Error out(_instance->logger());
+ out << "cannot create threads for thread pool:\n" << ex;
+ }
+
destroy();
+ joinWithAllThreads();
throw;
}
}