summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
authorMarc Laukien <marc@zeroc.com>2002-04-29 20:03:41 +0000
committerMarc Laukien <marc@zeroc.com>2002-04-29 20:03:41 +0000
commitbea5265a7e5cbeb0a5db284450ce8305026d0335 (patch)
treec09dda2b020fede02b6115cee0acb1a2515fb4d5 /cpp/src
parentreverting daemon changes (diff)
downloadice-bea5265a7e5cbeb0a5db284450ce8305026d0335.tar.bz2
ice-bea5265a7e5cbeb0a5db284450ce8305026d0335.tar.xz
ice-bea5265a7e5cbeb0a5db284450ce8305026d0335.zip
thread pool lazy init fix
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/Ice/CommunicatorI.cpp31
-rw-r--r--cpp/src/Ice/CommunicatorI.h7
-rw-r--r--cpp/src/Ice/Instance.cpp4
3 files changed, 29 insertions, 13 deletions
diff --git a/cpp/src/Ice/CommunicatorI.cpp b/cpp/src/Ice/CommunicatorI.cpp
index 644d09031a0..8a8249f8f2a 100644
--- a/cpp/src/Ice/CommunicatorI.cpp
+++ b/cpp/src/Ice/CommunicatorI.cpp
@@ -43,7 +43,10 @@ Ice::CommunicatorI::shutdown()
//
// No mutex locking here! This operation must be signal-safe.
//
- _serverThreadPool->initiateShutdown();
+ if (_serverThreadPool)
+ {
+ _serverThreadPool->initiateShutdown();
+ }
}
void
@@ -53,7 +56,10 @@ Ice::CommunicatorI::waitForShutdown()
// No mutex locking here, otherwise the communicator is blocked
// while waiting for shutdown.
//
- _serverThreadPool->waitUntilFinished();
+ if (_serverThreadPool)
+ {
+ _serverThreadPool->waitUntilFinished();
+ }
}
ObjectPrx
@@ -95,6 +101,11 @@ Ice::CommunicatorI::createObjectAdapter(const string& name)
adapter->addRouter(RouterPrx::uncheckedCast(_instance->proxyFactory()->stringToProxy(router)));
}
+ if (!_serverThreadPool) // Lazy initialization of _serverThreadPool.
+ {
+ _serverThreadPool = _instance->serverThreadPool();
+ }
+
return adapter;
}
@@ -108,6 +119,7 @@ Ice::CommunicatorI::createObjectAdapterFromProperty(const string& name, const st
}
string endpts = _instance->properties()->getProperty(property);
+
return createObjectAdapterWithEndpoints(name, endpts);
}
@@ -120,7 +132,14 @@ Ice::CommunicatorI::createObjectAdapterWithEndpoints(const string& name, const s
throw CommunicatorDestroyedException(__FILE__, __LINE__);
}
- return _instance->objectAdapterFactory()->createObjectAdapter(name, endpts);
+ ObjectAdapterPtr adapter = _instance->objectAdapterFactory()->createObjectAdapter(name, endpts);
+
+ if (!_serverThreadPool) // Lazy initialization of _serverThreadPool.
+ {
+ _serverThreadPool = _instance->serverThreadPool();
+ }
+
+ return adapter;
}
void
@@ -252,12 +271,6 @@ Ice::CommunicatorI::CommunicatorI(int& argc, char* argv[], const PropertiesPtr&
throw;
}
__setNoDelete(false);
-
- //
- // See the comments in the header file for an explanation of why we
- // need _serverThreadPool directly in CommunicatorI.
- //
- _serverThreadPool = _instance->serverThreadPool();
}
Ice::CommunicatorI::~CommunicatorI()
diff --git a/cpp/src/Ice/CommunicatorI.h b/cpp/src/Ice/CommunicatorI.h
index d0f0e7f10ab..7e78e07efab 100644
--- a/cpp/src/Ice/CommunicatorI.h
+++ b/cpp/src/Ice/CommunicatorI.h
@@ -70,10 +70,9 @@ private:
::IceInternal::InstancePtr _instance;
//
- // We need _serverThreadPool directly in CommunicatorI, and it
- // must never be set to null. That's because the shutdown()
- // operation is signal-safe, and thus must not access any mutex
- // locks or _instance. It may only access
+ // We need _serverThreadPool directly in CommunicatorI. That's
+ // because the shutdown() operation is signal-safe, and thus must
+ // not access any mutex locks or _instance. It may only access
// _serverThreadPool->initiateShutdown(), which is signal-safe as
// well.
//
diff --git a/cpp/src/Ice/Instance.cpp b/cpp/src/Ice/Instance.cpp
index b1eb56349f4..a8c807fe403 100644
--- a/cpp/src/Ice/Instance.cpp
+++ b/cpp/src/Ice/Instance.cpp
@@ -425,6 +425,10 @@ IceInternal::Instance::finishSetup(int& argc, char* argv[])
// installed. For example, an SSL plug-in might want to
// read a passphrase from standard input.
//
+ // TODO: This is a problem for plug-ins that open files, create
+ // threads, etc. Perhaps we need a two-stage plug-in
+ // initialization?
+ //
if (_properties->getPropertyAsInt("Ice.Daemon") > 0)
{
int noclose = _properties->getPropertyAsInt("Ice.DaemonNoClose");