diff options
author | Mark Spruiell <mes@zeroc.com> | 2002-04-29 19:23:33 +0000 |
---|---|---|
committer | Mark Spruiell <mes@zeroc.com> | 2002-04-29 19:23:33 +0000 |
commit | f168a466624900a78b174828f1ca552e786090a4 (patch) | |
tree | 1d767403d3ba345a593aba186204baf12fe582f1 /cpp/src | |
parent | fixes (diff) | |
download | ice-f168a466624900a78b174828f1ca552e786090a4.tar.bz2 ice-f168a466624900a78b174828f1ca552e786090a4.tar.xz ice-f168a466624900a78b174828f1ca552e786090a4.zip |
fixing daemon problem
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/Ice/CommunicatorI.cpp | 4 | ||||
-rw-r--r-- | cpp/src/Ice/CommunicatorI.h | 5 | ||||
-rw-r--r-- | cpp/src/Ice/Initialize.cpp | 4 | ||||
-rw-r--r-- | cpp/src/Ice/Instance.cpp | 91 | ||||
-rw-r--r-- | cpp/src/Ice/Instance.h | 2 |
5 files changed, 53 insertions, 53 deletions
diff --git a/cpp/src/Ice/CommunicatorI.cpp b/cpp/src/Ice/CommunicatorI.cpp index 644d09031a0..27dfcb5906c 100644 --- a/cpp/src/Ice/CommunicatorI.cpp +++ b/cpp/src/Ice/CommunicatorI.cpp @@ -270,7 +270,7 @@ Ice::CommunicatorI::~CommunicatorI() } void -Ice::CommunicatorI::finishSetup(int& argc, char* argv[]) +Ice::CommunicatorI::loadPlugins(int& argc, char* argv[]) { - _instance->finishSetup(argc, argv); + _instance->loadPlugins(argc, argv); } diff --git a/cpp/src/Ice/CommunicatorI.h b/cpp/src/Ice/CommunicatorI.h index d0f0e7f10ab..df7b2a2a2ea 100644 --- a/cpp/src/Ice/CommunicatorI.h +++ b/cpp/src/Ice/CommunicatorI.h @@ -58,10 +58,9 @@ private: virtual ~CommunicatorI(); // - // Certain initialization tasks need to be completed after the - // constructor. + // Load plug-ins after the constructor has completed. // - void finishSetup(int&, char*[]); + void loadPlugins(int&, char*[]); friend ICE_API CommunicatorPtr initialize(int&, char*[], Int); friend ICE_API CommunicatorPtr initializeWithProperties(int&, char*[], const PropertiesPtr&, Int); diff --git a/cpp/src/Ice/Initialize.cpp b/cpp/src/Ice/Initialize.cpp index 6bff3fa51ec..fead3c66b07 100644 --- a/cpp/src/Ice/Initialize.cpp +++ b/cpp/src/Ice/Initialize.cpp @@ -30,7 +30,7 @@ Ice::initialize(int& argc, char* argv[], Int version) PropertiesPtr defaultProperties = getDefaultProperties(argc, argv); CommunicatorI* communicatorI = new CommunicatorI(argc, argv, defaultProperties); CommunicatorPtr result = communicatorI; // For exception safety. - communicatorI->finishSetup(argc, argv); + communicatorI->loadPlugins(argc, argv); return result; } @@ -46,7 +46,7 @@ Ice::initializeWithProperties(int& argc, char* argv[], const PropertiesPtr& prop CommunicatorI* communicatorI = new CommunicatorI(argc, argv, properties); CommunicatorPtr result = communicatorI; // For exception safety. - communicatorI->finishSetup(argc, argv); + communicatorI->loadPlugins(argc, argv); return result; } diff --git a/cpp/src/Ice/Instance.cpp b/cpp/src/Ice/Instance.cpp index b1eb56349f4..bacf75e1125 100644 --- a/cpp/src/Ice/Instance.cpp +++ b/cpp/src/Ice/Instance.cpp @@ -348,6 +348,51 @@ IceInternal::Instance::Instance(const CommunicatorPtr& communicator, int& argc, _objectAdapterFactory = new ObjectAdapterFactory(this); +#ifndef _WIN32 + // + // daemon() is called before the plug-ins are loaded. + // If a plug-in needs to use a resource such as stdin + // (e.g., the SSL plug-in might want to read a passphrase), + // then Ice.DaemonNoClose must be specified. + // + if (_properties->getPropertyAsInt("Ice.Daemon") > 0) + { + int noclose = _properties->getPropertyAsInt("Ice.DaemonNoClose"); + int nochdir = _properties->getPropertyAsInt("Ice.DaemonNoChdir"); + + if (daemon(nochdir, noclose) == -1) + { + SystemException ex(__FILE__, __LINE__); + ex.error = getSystemErrno(); + throw ex; + } + } +#endif + + // + // Must be done after daemon() is called, since daemon() + // forks. Does not work together with Ice.Daemon if + // Ice.DaemonNoClose is not set. + // + if (_properties->getPropertyAsInt("Ice.PrintProcessId") > 0) + { +#ifdef _WIN32 + cout << _getpid() << endl; +#else + cout << getpid() << endl; +#endif + } + + // + // Thread pool initializations must be done after daemon() is + // called, since daemon() forks. + // + + // + // Thread pool initialization is now lazy initialization in + // clientThreadPool() and serverThreadPool(). + // + __setNoDelete(false); } catch(...) @@ -410,7 +455,7 @@ IceInternal::Instance::~Instance() } void -IceInternal::Instance::finishSetup(int& argc, char* argv[]) +IceInternal::Instance::loadPlugins(int& argc, char* argv[]) { // // Load plug-ins. @@ -418,50 +463,6 @@ IceInternal::Instance::finishSetup(int& argc, char* argv[]) PluginManagerI* pluginManagerImpl = dynamic_cast<PluginManagerI*>(_pluginManager.get()); assert(pluginManagerImpl); pluginManagerImpl->loadPlugins(argc, argv); - -#ifndef _WIN32 - // - // daemon() must be called after any plug-ins have been - // installed. For example, an SSL plug-in might want to - // read a passphrase from standard input. - // - if (_properties->getPropertyAsInt("Ice.Daemon") > 0) - { - int noclose = _properties->getPropertyAsInt("Ice.DaemonNoClose"); - int nochdir = _properties->getPropertyAsInt("Ice.DaemonNoChdir"); - - if (daemon(nochdir, noclose) == -1) - { - SystemException ex(__FILE__, __LINE__); - ex.error = getSystemErrno(); - throw ex; - } - } -#endif - - // - // Must be done after daemon() is called, since daemon() - // forks. Does not work together with Ice.Daemon if - // Ice.DaemonNoClose is not set. - // - if (_properties->getPropertyAsInt("Ice.PrintProcessId") > 0) - { -#ifdef _WIN32 - cout << _getpid() << endl; -#else - cout << getpid() << endl; -#endif - } - - // - // Thread pool initializations must be done after daemon() is - // called, since daemon() forks. - // - - // - // Thread pool initialization is now lazy initialization in - // clientThreadPool() and serverThreadPool(). - // } void diff --git a/cpp/src/Ice/Instance.h b/cpp/src/Ice/Instance.h index 5e1b105dd35..63ea54e66fa 100644 --- a/cpp/src/Ice/Instance.h +++ b/cpp/src/Ice/Instance.h @@ -68,7 +68,7 @@ private: Instance(const ::Ice::CommunicatorPtr&, int&, char*[], const ::Ice::PropertiesPtr&); virtual ~Instance(); - void finishSetup(int&, char*[]); + void loadPlugins(int&, char*[]); void destroy(); friend class ::Ice::CommunicatorI; |