summaryrefslogtreecommitdiff
path: root/cpp
diff options
context:
space:
mode:
authorBrent Eagles <brent@zeroc.com>2005-09-12 23:48:03 +0000
committerBrent Eagles <brent@zeroc.com>2005-09-12 23:48:03 +0000
commit188f3831ee428bd8517345a30b76b2ab8ff8361b (patch)
tree2d131ebf4e082adc40de933b5a8af21e338a9e4b /cpp
parentremoving print statement (diff)
downloadice-188f3831ee428bd8517345a30b76b2ab8ff8361b.tar.bz2
ice-188f3831ee428bd8517345a30b76b2ab8ff8361b.tar.xz
ice-188f3831ee428bd8517345a30b76b2ab8ff8361b.zip
fixing bug 400
Diffstat (limited to 'cpp')
-rw-r--r--cpp/src/Ice/ObjectAdapterFactory.cpp12
-rw-r--r--cpp/src/Ice/ObjectAdapterFactory.h4
-rw-r--r--cpp/src/Ice/ObjectAdapterI.cpp22
-rw-r--r--cpp/test/Ice/location/AllTests.cpp47
-rw-r--r--cpp/test/Ice/location/ServerLocator.cpp6
-rw-r--r--cpp/test/Ice/location/ServerLocator.h6
-rw-r--r--cpp/test/Ice/location/Test.ice10
7 files changed, 94 insertions, 13 deletions
diff --git a/cpp/src/Ice/ObjectAdapterFactory.cpp b/cpp/src/Ice/ObjectAdapterFactory.cpp
index e61834a856f..c2fec862545 100644
--- a/cpp/src/Ice/ObjectAdapterFactory.cpp
+++ b/cpp/src/Ice/ObjectAdapterFactory.cpp
@@ -25,7 +25,7 @@ IceInternal::ObjectAdapterFactory::shutdown()
map<string, ObjectAdapterIPtr> adapters;
{
- IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
+ IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this);
//
// Ignore shutdown requests if the object adapter factory has
@@ -56,7 +56,7 @@ void
IceInternal::ObjectAdapterFactory::waitForShutdown()
{
{
- IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
+ IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this);
//
// First we wait for the shutdown of the factory itself.
@@ -89,7 +89,7 @@ IceInternal::ObjectAdapterFactory::waitForShutdown()
_adapters.clear();
{
- IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
+ IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this);
//
// Signal that waiting is complete.
@@ -102,7 +102,7 @@ IceInternal::ObjectAdapterFactory::waitForShutdown()
ObjectAdapterPtr
IceInternal::ObjectAdapterFactory::createObjectAdapter(const string& name, const string& endpoints)
{
- IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
+ IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this);
if(!_instance)
{
@@ -123,7 +123,7 @@ IceInternal::ObjectAdapterFactory::createObjectAdapter(const string& name, const
ObjectAdapterPtr
IceInternal::ObjectAdapterFactory::findObjectAdapter(const ObjectPrx& proxy)
{
- IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
+ IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this);
if(!_instance)
{
@@ -165,7 +165,7 @@ IceInternal::ObjectAdapterFactory::flushBatchRequests() const
{
list<ObjectAdapterIPtr> a;
{
- IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
+ IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this);
for(map<string, ObjectAdapterIPtr>::const_iterator p = _adapters.begin(); p != _adapters.end(); ++p)
{
diff --git a/cpp/src/Ice/ObjectAdapterFactory.h b/cpp/src/Ice/ObjectAdapterFactory.h
index 18c419cab6f..2524ae8eeb8 100644
--- a/cpp/src/Ice/ObjectAdapterFactory.h
+++ b/cpp/src/Ice/ObjectAdapterFactory.h
@@ -11,13 +11,13 @@
#define ICE_OBJECT_ADAPTER_FACTORY_H
#include <Ice/ObjectAdapterI.h>
-#include <IceUtil/Mutex.h>
+#include <IceUtil/RecMutex.h>
#include <IceUtil/Monitor.h>
namespace IceInternal
{
-class ObjectAdapterFactory : public ::IceUtil::Shared, public ::IceUtil::Monitor< ::IceUtil::Mutex>
+class ObjectAdapterFactory : public ::IceUtil::Shared, public ::IceUtil::Monitor< ::IceUtil::RecMutex>
{
public:
diff --git a/cpp/src/Ice/ObjectAdapterI.cpp b/cpp/src/Ice/ObjectAdapterI.cpp
index 7ac0173684b..ccd18813798 100644
--- a/cpp/src/Ice/ObjectAdapterI.cpp
+++ b/cpp/src/Ice/ObjectAdapterI.cpp
@@ -552,11 +552,11 @@ bool
Ice::ObjectAdapterI::isLocal(const ObjectPrx& proxy) const
{
IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this);
-
checkForDeactivation();
ReferencePtr ref = proxy->__reference();
vector<EndpointIPtr>::const_iterator p;
+ vector<EndpointIPtr> endpoints;
IndirectReferencePtr ir = IndirectReferencePtr::dynamicCast(ref);
if(ir)
@@ -569,7 +569,24 @@ Ice::ObjectAdapterI::isLocal(const ObjectPrx& proxy) const
//
return ir->getAdapterId() == _id;
}
- return false;
+
+ //
+ // Get Locator endpoint information for indirect references.
+ //
+ LocatorInfoPtr info = ir->getLocatorInfo();
+ if(info)
+ {
+ bool isCached;
+ endpoints = info->getEndpoints(ir, isCached);
+ }
+ else
+ {
+ return false;
+ }
+ }
+ else
+ {
+ endpoints = ref->getEndpoints();
}
//
@@ -577,7 +594,6 @@ Ice::ObjectAdapterI::isLocal(const ObjectPrx& proxy) const
// endpoints used by this object adapter's incoming connection
// factories are considered local.
//
- vector<EndpointIPtr> endpoints = ref->getEndpoints();
for(p = endpoints.begin(); p != endpoints.end(); ++p)
{
vector<IncomingConnectionFactoryPtr>::const_iterator q;
diff --git a/cpp/test/Ice/location/AllTests.cpp b/cpp/test/Ice/location/AllTests.cpp
index 8737ae4fba2..980ff6b9f20 100644
--- a/cpp/test/Ice/location/AllTests.cpp
+++ b/cpp/test/Ice/location/AllTests.cpp
@@ -8,12 +8,24 @@
// **********************************************************************
#include <Ice/Ice.h>
+#include <IceUtil/UUID.h>
#include <TestCommon.h>
#include <Test.h>
using namespace std;
using namespace Test;
+class HelloI : virtual public Hello
+{
+public:
+
+ virtual void
+ sayHello(const Ice::Current& foo)
+ {
+ // Do nothing, this is just a dummy servant.
+ }
+};
+
void
allTests(const Ice::CommunicatorPtr& communicator, const string& ref)
{
@@ -231,6 +243,41 @@ allTests(const Ice::CommunicatorPtr& communicator, const string& ref)
}
cout << "ok" << endl;
+ cout << "testing indirect references to collocated objects... " << flush;
+ //
+ // Set up test for calling a collocated object through an indirect, adapterless reference.
+ //
+ Ice::PropertiesPtr properties = communicator->getProperties();
+ properties->setProperty("Ice.PrintAdapterReady", "0");
+ properties->setProperty("Hello.Endpoints",
+ properties->getPropertyWithDefault("Hello.Endpoints",
+ "default -p 10001"));
+ Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("Hello");
+ Ice::LocatorPrx locator =
+ Ice::LocatorPrx::uncheckedCast(communicator->stringToProxy(properties->getProperty("Ice.Default.Locator")));
+ adapter->setLocator(locator);
+
+ TestLocatorRegistryPrx registry = TestLocatorRegistryPrx::checkedCast(locator->getRegistry());
+ test(registry);
+
+ Ice::Identity id;
+ id.name = IceUtil::generateUUID();
+ cout << id.name << endl;
+ registry->addObject(adapter->add(new HelloI, id));
+ adapter->activate();
+
+ try
+ {
+ HelloPrx helloPrx = HelloPrx::checkedCast(communicator->stringToProxy(id.name));
+ Ice::ConnectionPtr connection = helloPrx->ice_connection();
+ test(false);
+ }
+ catch(const Ice::CollocationOptimizationException&)
+ {
+ }
+ adapter->deactivate();
+ cout << "ok" << endl;
+
cout << "shutdown server manager... " << flush;
manager->shutdown();
cout << "ok" << endl;
diff --git a/cpp/test/Ice/location/ServerLocator.cpp b/cpp/test/Ice/location/ServerLocator.cpp
index 42c431d0a93..c4031e8240a 100644
--- a/cpp/test/Ice/location/ServerLocator.cpp
+++ b/cpp/test/Ice/location/ServerLocator.cpp
@@ -34,6 +34,12 @@ ServerLocatorRegistry::setServerProcessProxy_async(const Ice::AMD_LocatorRegistr
cb->ice_response();
}
+void
+ServerLocatorRegistry::addObject(const Ice::ObjectPrx& object, const ::Ice::Current&)
+{
+ addObject(object);
+}
+
Ice::ObjectPrx
ServerLocatorRegistry::getAdapter(const ::std::string& adapter) const
{
diff --git a/cpp/test/Ice/location/ServerLocator.h b/cpp/test/Ice/location/ServerLocator.h
index 988ebc117d2..c9d7f7fe4da 100644
--- a/cpp/test/Ice/location/ServerLocator.h
+++ b/cpp/test/Ice/location/ServerLocator.h
@@ -11,9 +11,10 @@
#define SERVER_LOCATOR_H
#include <Ice/Locator.h>
+#include <Test.h>
#include <Ice/ProxyF.h>
-class ServerLocatorRegistry : public Ice::LocatorRegistry
+class ServerLocatorRegistry : public Test::TestLocatorRegistry
{
public:
@@ -24,7 +25,8 @@ public:
const ::Ice::Current&);
virtual void setServerProcessProxy_async(const Ice::AMD_LocatorRegistry_setServerProcessProxyPtr&,
const ::std::string&, const ::Ice::ProcessPrx&, const ::Ice::Current&);
-
+ void addObject(const ::Ice::ObjectPrx&, const ::Ice::Current&);
+
//
// Internal method
//
diff --git a/cpp/test/Ice/location/Test.ice b/cpp/test/Ice/location/Test.ice
index 630a3067b09..e52fcff789f 100644
--- a/cpp/test/Ice/location/Test.ice
+++ b/cpp/test/Ice/location/Test.ice
@@ -10,9 +10,19 @@
#ifndef TEST_ICE
#define TEST_ICE
+#include <Ice/Locator.ice>
+
module Test
{
+interface TestLocatorRegistry extends ::Ice::LocatorRegistry
+{
+ //
+ // Allow remote addition of objects to the locator registry.
+ //
+ void addObject(Object* obj);
+};
+
interface ServerManager
{
void startServer();