diff options
author | Marc Laukien <marc@zeroc.com> | 2002-04-18 04:40:41 +0000 |
---|---|---|
committer | Marc Laukien <marc@zeroc.com> | 2002-04-18 04:40:41 +0000 |
commit | 24dcb8de1ba0b658936bde3681c0105d78f66dfd (patch) | |
tree | a645dd5ab376e83f092cc439673ab3899ac4035f /cpp | |
parent | Fixes (diff) | |
download | ice-24dcb8de1ba0b658936bde3681c0105d78f66dfd.tar.bz2 ice-24dcb8de1ba0b658936bde3681c0105d78f66dfd.tar.xz ice-24dcb8de1ba0b658936bde3681c0105d78f66dfd.zip |
updater thread
Diffstat (limited to 'cpp')
-rw-r--r-- | cpp/include/IceUtil/Thread.h | 3 | ||||
-rw-r--r-- | cpp/src/IcePatch/.depend | 4 | ||||
-rw-r--r-- | cpp/src/IcePatch/Server.cpp | 241 |
3 files changed, 164 insertions, 84 deletions
diff --git a/cpp/include/IceUtil/Thread.h b/cpp/include/IceUtil/Thread.h index 606b356b6cd..d0364f5581e 100644 --- a/cpp/include/IceUtil/Thread.h +++ b/cpp/include/IceUtil/Thread.h @@ -41,9 +41,6 @@ struct HandleWrapper : public Shared typedef Handle<HandleWrapper> HandleWrapperPtr; #endif -// -// -// class ICE_UTIL_API ThreadControl { public: diff --git a/cpp/src/IcePatch/.depend b/cpp/src/IcePatch/.depend index 6de72b08a9f..e42b5f58b50 100644 --- a/cpp/src/IcePatch/.depend +++ b/cpp/src/IcePatch/.depend @@ -1,8 +1,8 @@ IcePatch.o: IcePatch.cpp ../../include/Ice/Stream.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/IceUtil/Handle.h ../../include/IceUtil/Exception.h ../../include/IceUtil/Config.h ../../include/Ice/Config.h ../../include/Ice/ObjectF.h ../../include/Ice/Handle.h ../../include/Ice/LocalObjectF.h ../../include/Ice/Exception.h ../../include/Ice/LocalException.h ../../include/Ice/ObjectFactoryF.h ../../include/Ice/LocalObject.h ../../include/IceUtil/Shared.h ../../include/Ice/StreamF.h ../../include/Ice/BuiltinSequences.h ../../include/IcePatch/IcePatch.h ../../include/Ice/Proxy.h ../../include/IceUtil/Mutex.h ../../include/IceUtil/Lock.h ../../include/Ice/ProxyFactoryF.h ../../include/Ice/ConnectionF.h ../../include/Ice/EndpointF.h ../../include/Ice/ObjectAdapterF.h ../../include/Ice/ReferenceF.h ../../include/Ice/Current.h ../../include/Ice/Identity.h ../../include/Ice/Object.h ../../include/Ice/Outgoing.h ../../include/IceUtil/Monitor.h ../../include/IceUtil/Cond.h ../../include/Ice/BasicStream.h ../../include/Ice/InstanceF.h ../../include/Ice/Buffer.h ../../include/Ice/Incoming.h ../../include/Ice/Direct.h ../../include/Ice/ServantLocatorF.h ../../include/Ice/ObjectFactory.h FileDescFactory.o: FileDescFactory.cpp ../../include/IcePatch/FileDescFactory.h ../../include/Ice/Ice.h ../../include/Ice/Initialize.h ../../include/Ice/CommunicatorF.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/IceUtil/Handle.h ../../include/IceUtil/Exception.h ../../include/IceUtil/Config.h ../../include/Ice/Config.h ../../include/Ice/ObjectF.h ../../include/Ice/Handle.h ../../include/Ice/LocalObjectF.h ../../include/Ice/Exception.h ../../include/Ice/LocalException.h ../../include/Ice/ObjectFactoryF.h ../../include/Ice/LocalObject.h ../../include/IceUtil/Shared.h ../../include/Ice/StreamF.h ../../include/Ice/PropertiesF.h ../../include/Ice/InstanceF.h ../../include/Ice/Properties.h ../../include/Ice/BuiltinSequences.h ../../include/Ice/Logger.h ../../include/Ice/LoggerUtil.h ../../include/Ice/LoggerF.h ../../include/Ice/Communicator.h ../../include/Ice/Proxy.h ../../include/IceUtil/Mutex.h ../../include/IceUtil/Lock.h ../../include/Ice/ProxyFactoryF.h ../../include/Ice/ConnectionF.h ../../include/Ice/EndpointF.h ../../include/Ice/ObjectAdapterF.h ../../include/Ice/ReferenceF.h ../../include/Ice/Current.h ../../include/Ice/Identity.h ../../include/Ice/Object.h ../../include/Ice/Outgoing.h ../../include/IceUtil/Monitor.h ../../include/IceUtil/Cond.h ../../include/Ice/BasicStream.h ../../include/Ice/Buffer.h ../../include/Ice/Incoming.h ../../include/Ice/Direct.h ../../include/Ice/ServantLocatorF.h ../../include/Ice/UserExceptionFactoryF.h ../../include/Ice/RouterF.h ../../include/Ice/SystemF.h ../../include/Ice/SslExtensionF.h ../../include/Ice/ObjectFactory.h ../../include/Ice/UserExceptionFactory.h ../../include/Ice/ObjectAdapter.h ../../include/Ice/ServantLocator.h ../../include/Ice/IdentityUtil.h ../../include/IcePatch/IcePatch.h Util.o: Util.cpp ../../include/IcePatch/Util.h ../../include/Ice/Ice.h ../../include/Ice/Initialize.h ../../include/Ice/CommunicatorF.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/IceUtil/Handle.h ../../include/IceUtil/Exception.h ../../include/IceUtil/Config.h ../../include/Ice/Config.h ../../include/Ice/ObjectF.h ../../include/Ice/Handle.h ../../include/Ice/LocalObjectF.h ../../include/Ice/Exception.h ../../include/Ice/LocalException.h ../../include/Ice/ObjectFactoryF.h ../../include/Ice/LocalObject.h ../../include/IceUtil/Shared.h ../../include/Ice/StreamF.h ../../include/Ice/PropertiesF.h ../../include/Ice/InstanceF.h ../../include/Ice/Properties.h ../../include/Ice/BuiltinSequences.h ../../include/Ice/Logger.h ../../include/Ice/LoggerUtil.h ../../include/Ice/LoggerF.h ../../include/Ice/Communicator.h ../../include/Ice/Proxy.h ../../include/IceUtil/Mutex.h ../../include/IceUtil/Lock.h ../../include/Ice/ProxyFactoryF.h ../../include/Ice/ConnectionF.h ../../include/Ice/EndpointF.h ../../include/Ice/ObjectAdapterF.h ../../include/Ice/ReferenceF.h ../../include/Ice/Current.h ../../include/Ice/Identity.h ../../include/Ice/Object.h ../../include/Ice/Outgoing.h ../../include/IceUtil/Monitor.h ../../include/IceUtil/Cond.h ../../include/Ice/BasicStream.h ../../include/Ice/Buffer.h ../../include/Ice/Incoming.h ../../include/Ice/Direct.h ../../include/Ice/ServantLocatorF.h ../../include/Ice/UserExceptionFactoryF.h ../../include/Ice/RouterF.h ../../include/Ice/SystemF.h ../../include/Ice/SslExtensionF.h ../../include/Ice/ObjectFactory.h ../../include/Ice/UserExceptionFactory.h ../../include/Ice/ObjectAdapter.h ../../include/Ice/ServantLocator.h ../../include/Ice/IdentityUtil.h ../../include/IcePatch/IcePatch.h -Client.o: Client.cpp ../../include/Ice/Application.h ../../include/Ice/Ice.h ../../include/Ice/Initialize.h ../../include/Ice/CommunicatorF.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/IceUtil/Handle.h ../../include/IceUtil/Exception.h ../../include/IceUtil/Config.h ../../include/Ice/Config.h ../../include/Ice/ObjectF.h ../../include/Ice/Handle.h ../../include/Ice/LocalObjectF.h ../../include/Ice/Exception.h ../../include/Ice/LocalException.h ../../include/Ice/ObjectFactoryF.h ../../include/Ice/LocalObject.h ../../include/IceUtil/Shared.h ../../include/Ice/StreamF.h ../../include/Ice/PropertiesF.h ../../include/Ice/InstanceF.h ../../include/Ice/Properties.h ../../include/Ice/BuiltinSequences.h ../../include/Ice/Logger.h ../../include/Ice/LoggerUtil.h ../../include/Ice/LoggerF.h ../../include/Ice/Communicator.h ../../include/Ice/Proxy.h ../../include/IceUtil/Mutex.h ../../include/IceUtil/Lock.h ../../include/Ice/ProxyFactoryF.h ../../include/Ice/ConnectionF.h ../../include/Ice/EndpointF.h ../../include/Ice/ObjectAdapterF.h ../../include/Ice/ReferenceF.h ../../include/Ice/Current.h ../../include/Ice/Identity.h ../../include/Ice/Object.h ../../include/Ice/Outgoing.h ../../include/IceUtil/Monitor.h ../../include/IceUtil/Cond.h ../../include/Ice/BasicStream.h ../../include/Ice/Buffer.h ../../include/Ice/Incoming.h ../../include/Ice/Direct.h ../../include/Ice/ServantLocatorF.h ../../include/Ice/UserExceptionFactoryF.h ../../include/Ice/RouterF.h ../../include/Ice/SystemF.h ../../include/Ice/SslExtensionF.h ../../include/Ice/ObjectFactory.h ../../include/Ice/UserExceptionFactory.h ../../include/Ice/ObjectAdapter.h ../../include/Ice/ServantLocator.h ../../include/Ice/IdentityUtil.h ../../include/IcePatch/FileDescFactory.h ../../include/IcePatch/IcePatch.h ../../include/IcePatch/Util.h -Server.o: Server.cpp ../../include/Ice/Application.h ../../include/Ice/Ice.h ../../include/Ice/Initialize.h ../../include/Ice/CommunicatorF.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/IceUtil/Handle.h ../../include/IceUtil/Exception.h ../../include/IceUtil/Config.h ../../include/Ice/Config.h ../../include/Ice/ObjectF.h ../../include/Ice/Handle.h ../../include/Ice/LocalObjectF.h ../../include/Ice/Exception.h ../../include/Ice/LocalException.h ../../include/Ice/ObjectFactoryF.h ../../include/Ice/LocalObject.h ../../include/IceUtil/Shared.h ../../include/Ice/StreamF.h ../../include/Ice/PropertiesF.h ../../include/Ice/InstanceF.h ../../include/Ice/Properties.h ../../include/Ice/BuiltinSequences.h ../../include/Ice/Logger.h ../../include/Ice/LoggerUtil.h ../../include/Ice/LoggerF.h ../../include/Ice/Communicator.h ../../include/Ice/Proxy.h ../../include/IceUtil/Mutex.h ../../include/IceUtil/Lock.h ../../include/Ice/ProxyFactoryF.h ../../include/Ice/ConnectionF.h ../../include/Ice/EndpointF.h ../../include/Ice/ObjectAdapterF.h ../../include/Ice/ReferenceF.h ../../include/Ice/Current.h ../../include/Ice/Identity.h ../../include/Ice/Object.h ../../include/Ice/Outgoing.h ../../include/IceUtil/Monitor.h ../../include/IceUtil/Cond.h ../../include/Ice/BasicStream.h ../../include/Ice/Buffer.h ../../include/Ice/Incoming.h ../../include/Ice/Direct.h ../../include/Ice/ServantLocatorF.h ../../include/Ice/UserExceptionFactoryF.h ../../include/Ice/RouterF.h ../../include/Ice/SystemF.h ../../include/Ice/SslExtensionF.h ../../include/Ice/ObjectFactory.h ../../include/Ice/UserExceptionFactory.h ../../include/Ice/ObjectAdapter.h ../../include/Ice/ServantLocator.h ../../include/Ice/IdentityUtil.h ../IcePatch/FileLocator.h ../../include/IcePatch/IcePatch.h ../../include/IcePatch/Util.h +Client.o: Client.cpp ../../include/Ice/Application.h ../../include/Ice/Ice.h ../../include/Ice/Initialize.h ../../include/Ice/CommunicatorF.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/IceUtil/Handle.h ../../include/IceUtil/Exception.h ../../include/IceUtil/Config.h ../../include/Ice/Config.h ../../include/Ice/ObjectF.h ../../include/Ice/Handle.h ../../include/Ice/LocalObjectF.h ../../include/Ice/Exception.h ../../include/Ice/LocalException.h ../../include/Ice/ObjectFactoryF.h ../../include/Ice/LocalObject.h ../../include/IceUtil/Shared.h ../../include/Ice/StreamF.h ../../include/Ice/PropertiesF.h ../../include/Ice/InstanceF.h ../../include/Ice/Properties.h ../../include/Ice/BuiltinSequences.h ../../include/Ice/Logger.h ../../include/Ice/LoggerUtil.h ../../include/Ice/LoggerF.h ../../include/Ice/Communicator.h ../../include/Ice/Proxy.h ../../include/IceUtil/Mutex.h ../../include/IceUtil/Lock.h ../../include/Ice/ProxyFactoryF.h ../../include/Ice/ConnectionF.h ../../include/Ice/EndpointF.h ../../include/Ice/ObjectAdapterF.h ../../include/Ice/ReferenceF.h ../../include/Ice/Current.h ../../include/Ice/Identity.h ../../include/Ice/Object.h ../../include/Ice/Outgoing.h ../../include/IceUtil/Monitor.h ../../include/IceUtil/Cond.h ../../include/Ice/BasicStream.h ../../include/Ice/Buffer.h ../../include/Ice/Incoming.h ../../include/Ice/Direct.h ../../include/Ice/ServantLocatorF.h ../../include/Ice/UserExceptionFactoryF.h ../../include/Ice/RouterF.h ../../include/Ice/SystemF.h ../../include/Ice/SslExtensionF.h ../../include/Ice/ObjectFactory.h ../../include/Ice/UserExceptionFactory.h ../../include/Ice/ObjectAdapter.h ../../include/Ice/ServantLocator.h ../../include/Ice/IdentityUtil.h ../../include/Glacier/Glacier.h ../../include/Ice/Router.h ../../include/IcePatch/FileDescFactory.h ../../include/IcePatch/IcePatch.h ../../include/IcePatch/Util.h ../../include/IceUtil/Base64.h ../../include/Ice/System.h ../../include/Ice/CertificateVerifierF.h ../../include/Ice/SslExtension.h +Server.o: Server.cpp ../../include/IceUtil/IceUtil.h ../../include/IceUtil/Functional.h ../../include/IceUtil/Handle.h ../../include/IceUtil/Exception.h ../../include/IceUtil/Config.h ../../include/IceUtil/Shared.h ../../include/IceUtil/Unicode.h ../../include/IceUtil/UUID.h ../../include/IceUtil/Mutex.h ../../include/IceUtil/Lock.h ../../include/IceUtil/RecMutex.h ../../include/IceUtil/RWRecMutex.h ../../include/IceUtil/Cond.h ../../include/IceUtil/Monitor.h ../../include/IceUtil/Thread.h ../../include/IceUtil/Base64.h ../../include/Ice/Application.h ../../include/Ice/Ice.h ../../include/Ice/Initialize.h ../../include/Ice/CommunicatorF.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/Ice/Config.h ../../include/Ice/ObjectF.h ../../include/Ice/Handle.h ../../include/Ice/LocalObjectF.h ../../include/Ice/Exception.h ../../include/Ice/LocalException.h ../../include/Ice/ObjectFactoryF.h ../../include/Ice/LocalObject.h ../../include/Ice/StreamF.h ../../include/Ice/PropertiesF.h ../../include/Ice/InstanceF.h ../../include/Ice/Properties.h ../../include/Ice/BuiltinSequences.h ../../include/Ice/Logger.h ../../include/Ice/LoggerUtil.h ../../include/Ice/LoggerF.h ../../include/Ice/Communicator.h ../../include/Ice/Proxy.h ../../include/Ice/ProxyFactoryF.h ../../include/Ice/ConnectionF.h ../../include/Ice/EndpointF.h ../../include/Ice/ObjectAdapterF.h ../../include/Ice/ReferenceF.h ../../include/Ice/Current.h ../../include/Ice/Identity.h ../../include/Ice/Object.h ../../include/Ice/Outgoing.h ../../include/Ice/BasicStream.h ../../include/Ice/Buffer.h ../../include/Ice/Incoming.h ../../include/Ice/Direct.h ../../include/Ice/ServantLocatorF.h ../../include/Ice/UserExceptionFactoryF.h ../../include/Ice/RouterF.h ../../include/Ice/SystemF.h ../../include/Ice/SslExtensionF.h ../../include/Ice/ObjectFactory.h ../../include/Ice/UserExceptionFactory.h ../../include/Ice/ObjectAdapter.h ../../include/Ice/ServantLocator.h ../../include/Ice/IdentityUtil.h ../IcePatch/FileLocator.h ../../include/IcePatch/IcePatch.h ../../include/IcePatch/Util.h IcePatchI.o: IcePatchI.cpp ../IcePatch/IcePatchI.h ../../include/Ice/Ice.h ../../include/Ice/Initialize.h ../../include/Ice/CommunicatorF.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/IceUtil/Handle.h ../../include/IceUtil/Exception.h ../../include/IceUtil/Config.h ../../include/Ice/Config.h ../../include/Ice/ObjectF.h ../../include/Ice/Handle.h ../../include/Ice/LocalObjectF.h ../../include/Ice/Exception.h ../../include/Ice/LocalException.h ../../include/Ice/ObjectFactoryF.h ../../include/Ice/LocalObject.h ../../include/IceUtil/Shared.h ../../include/Ice/StreamF.h ../../include/Ice/PropertiesF.h ../../include/Ice/InstanceF.h ../../include/Ice/Properties.h ../../include/Ice/BuiltinSequences.h ../../include/Ice/Logger.h ../../include/Ice/LoggerUtil.h ../../include/Ice/LoggerF.h ../../include/Ice/Communicator.h ../../include/Ice/Proxy.h ../../include/IceUtil/Mutex.h ../../include/IceUtil/Lock.h ../../include/Ice/ProxyFactoryF.h ../../include/Ice/ConnectionF.h ../../include/Ice/EndpointF.h ../../include/Ice/ObjectAdapterF.h ../../include/Ice/ReferenceF.h ../../include/Ice/Current.h ../../include/Ice/Identity.h ../../include/Ice/Object.h ../../include/Ice/Outgoing.h ../../include/IceUtil/Monitor.h ../../include/IceUtil/Cond.h ../../include/Ice/BasicStream.h ../../include/Ice/Buffer.h ../../include/Ice/Incoming.h ../../include/Ice/Direct.h ../../include/Ice/ServantLocatorF.h ../../include/Ice/UserExceptionFactoryF.h ../../include/Ice/RouterF.h ../../include/Ice/SystemF.h ../../include/Ice/SslExtensionF.h ../../include/Ice/ObjectFactory.h ../../include/Ice/UserExceptionFactory.h ../../include/Ice/ObjectAdapter.h ../../include/Ice/ServantLocator.h ../../include/Ice/IdentityUtil.h ../../include/IceUtil/RWRecMutex.h ../../include/IcePatch/IcePatch.h ../../include/IcePatch/Util.h FileLocator.o: FileLocator.cpp ../IcePatch/FileLocator.h ../../include/Ice/Ice.h ../../include/Ice/Initialize.h ../../include/Ice/CommunicatorF.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/IceUtil/Handle.h ../../include/IceUtil/Exception.h ../../include/IceUtil/Config.h ../../include/Ice/Config.h ../../include/Ice/ObjectF.h ../../include/Ice/Handle.h ../../include/Ice/LocalObjectF.h ../../include/Ice/Exception.h ../../include/Ice/LocalException.h ../../include/Ice/ObjectFactoryF.h ../../include/Ice/LocalObject.h ../../include/IceUtil/Shared.h ../../include/Ice/StreamF.h ../../include/Ice/PropertiesF.h ../../include/Ice/InstanceF.h ../../include/Ice/Properties.h ../../include/Ice/BuiltinSequences.h ../../include/Ice/Logger.h ../../include/Ice/LoggerUtil.h ../../include/Ice/LoggerF.h ../../include/Ice/Communicator.h ../../include/Ice/Proxy.h ../../include/IceUtil/Mutex.h ../../include/IceUtil/Lock.h ../../include/Ice/ProxyFactoryF.h ../../include/Ice/ConnectionF.h ../../include/Ice/EndpointF.h ../../include/Ice/ObjectAdapterF.h ../../include/Ice/ReferenceF.h ../../include/Ice/Current.h ../../include/Ice/Identity.h ../../include/Ice/Object.h ../../include/Ice/Outgoing.h ../../include/IceUtil/Monitor.h ../../include/IceUtil/Cond.h ../../include/Ice/BasicStream.h ../../include/Ice/Buffer.h ../../include/Ice/Incoming.h ../../include/Ice/Direct.h ../../include/Ice/ServantLocatorF.h ../../include/Ice/UserExceptionFactoryF.h ../../include/Ice/RouterF.h ../../include/Ice/SystemF.h ../../include/Ice/SslExtensionF.h ../../include/Ice/ObjectFactory.h ../../include/Ice/UserExceptionFactory.h ../../include/Ice/ObjectAdapter.h ../../include/Ice/ServantLocator.h ../../include/Ice/IdentityUtil.h ../../include/IcePatch/IcePatch.h ../../include/IcePatch/Util.h ../IcePatch/IcePatchI.h ../../include/IceUtil/RWRecMutex.h blocksort.o: blocksort.c bzlib_private.h bzlib.h diff --git a/cpp/src/IcePatch/Server.cpp b/cpp/src/IcePatch/Server.cpp index a84c71a1476..c35ffcd4ac7 100644 --- a/cpp/src/IcePatch/Server.cpp +++ b/cpp/src/IcePatch/Server.cpp @@ -8,6 +8,7 @@ // // ********************************************************************** +#include <IceUtil/IceUtil.h> #include <Ice/Application.h> #include <IcePatch/FileLocator.h> #include <IcePatch/Util.h> @@ -28,10 +29,27 @@ public: void usage(); virtual int run(int, char*[]); +}; + +class Updater : public IceUtil::Thread, public IceUtil::Monitor<IceUtil::Mutex> +{ +public: + + Updater(const ObjectAdapterPtr&); + + virtual void run(); + void destroy(); + +protected: + + const ObjectAdapterPtr& _adapter; + bool _destroy; - static void cleanup(const FileDescSeq&); + void cleanup(const FileDescSeq&); }; +typedef IceUtil::Handle<Updater> UpdaterPtr; + }; void @@ -48,96 +66,161 @@ IcePatch::Server::usage() int IcePatch::Server::run(int argc, char* argv[]) { - try + for (int i = 1; i < argc; ++i) + { + if (strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "--help") == 0) + { + usage(); + return EXIT_SUCCESS; + } + else if (strcmp(argv[i], "-v") == 0 || strcmp(argv[i], "--version") == 0) + { + cout << ICE_STRING_VERSION << endl; + return EXIT_SUCCESS; + } + else + { + cerr << appName() << ": unknown option `" << argv[i] << "'" << endl; + usage(); + return EXIT_FAILURE; + } + } + + PropertiesPtr properties = communicator()->getProperties(); + + // + // Get the IcePatch endpoints. + // + const char* endpointsProperty = "IcePatch.Endpoints"; + string endpoints = properties->getProperty(endpointsProperty); + if (endpoints.empty()) + { + cerr << appName() << ": property `" << endpointsProperty << "' is not set" << endl; + return EXIT_FAILURE; + } + + // + // Get the working directory and change to this directory. + // + const char* directoryProperty = "IcePatch.Directory"; + string directory = properties->getProperty(directoryProperty); + if (!directory.empty()) { - for (int i = 1; i < argc; ++i) - { - if (strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "--help") == 0) - { - usage(); - return EXIT_SUCCESS; - } - else if (strcmp(argv[i], "-v") == 0 || strcmp(argv[i], "--version") == 0) - { - cout << ICE_STRING_VERSION << endl; - return EXIT_SUCCESS; - } - else - { - cerr << appName() << ": unknown option `" << argv[i] << "'" << endl; - usage(); - return EXIT_FAILURE; - } - } - - PropertiesPtr properties = communicator()->getProperties(); - - // - // Get the IcePatch endpoints. - // - const char* endpointsProperty = "IcePatch.Endpoints"; - string endpoints = properties->getProperty(endpointsProperty); - if (endpoints.empty()) - { - cerr << appName() << ": property `" << endpointsProperty << "' is not set" << endl; - return EXIT_FAILURE; - } - - // - // Get the working directory and change to this directory. - // - const char* directoryProperty = "IcePatch.Directory"; - string directory = properties->getProperty(directoryProperty); - if (!directory.empty()) - { #ifdef _WIN32 - if (_chdir(directory.c_str()) == -1) + if (_chdir(directory.c_str()) == -1) #else - if (chdir(directory.c_str()) == -1) + if (chdir(directory.c_str()) == -1) #endif - { - cerr << appName() << ": cannot change to directory `" << directory << "': " << strerror(errno) << endl; - } - } - - // - // Create and initialize the object adapter and the file locator. - // - ObjectAdapterPtr adapter = communicator()->createObjectAdapterFromProperty("IcePatch", endpointsProperty); - ServantLocatorPtr fileLocator = new FileLocator(adapter); - adapter->addServantLocator(fileLocator, "IcePatch"); - - // - // Do cleanup. - // - Identity identity = pathToIdentity("."); - ObjectPrx topObj = communicator()->stringToProxy(identityToString(identity) + ':' + endpoints); - FilePrx top = FilePrx::checkedCast(topObj); - assert(top); - DirectoryDescPtr topDesc = DirectoryDescPtr::dynamicCast(top->describe()); - assert(topDesc); - cleanup(topDesc->directory->getContents()); - - // - // Everything ok, let's go. - // - shutdownOnInterrupt(); - adapter->activate(); - communicator()->waitForShutdown(); - ignoreInterrupt(); + { + cerr << appName() << ": cannot change to directory `" << directory << "': " << strerror(errno) << endl; + } + } + + // + // Create and initialize the object adapter and the file locator. + // + ObjectAdapterPtr adapter = communicator()->createObjectAdapterFromProperty("IcePatch", endpointsProperty); + ServantLocatorPtr fileLocator = new FileLocator(adapter); + adapter->addServantLocator(fileLocator, "IcePatch"); + + // + // Start updater. + // + UpdaterPtr updater = new Updater(adapter); + updater->start(); + + // + // Everything ok, let's go. + // + shutdownOnInterrupt(); + adapter->activate(); + communicator()->waitForShutdown(); + ignoreInterrupt(); + + // + // Destroy and join with updater. + // + updater->destroy(); + updater->getThreadControl().join(); + + return EXIT_SUCCESS; +} + +IcePatch::Updater::Updater(const ObjectAdapterPtr& adapter) : + _adapter(adapter), + _destroy(false) +{ +} + +void +IcePatch::Updater::run() +{ + IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this); + + PropertiesPtr properties = _adapter->getCommunicator()->getProperties(); + Int updatePeriod = properties->getPropertyAsIntWithDefault("IcePatch.UpdatePeriod", 60); + if (updatePeriod < 10) + { + updatePeriod = 10; } - catch (const FileAccessException& ex) + + while (!_destroy) { - cerr << appName() << ": " << ex << ":\n" << ex.reason << endl; - return EXIT_FAILURE; + try + { + Identity identity = pathToIdentity("."); + ObjectPrx topObj = _adapter->createProxy(identity); + FilePrx top = FilePrx::checkedCast(topObj); + assert(top); + DirectoryDescPtr topDesc = DirectoryDescPtr::dynamicCast(top->describe()); + assert(topDesc); + cleanup(topDesc->directory->getContents()); + } + catch (const FileAccessException& ex) + { + Error out(_adapter->getCommunicator()->getLogger()); + out << "exception during update:\n" << ex << ":\n" << ex.reason; + } + catch (const ConnectFailedException&) + { + // + // This exception can be raised if the adapter is shutdown + // while this thread is still running. In such case, we + // terminate this thread. + // + break; + } + catch (const Exception& ex) + { + Error out(_adapter->getCommunicator()->getLogger()); + out << "exception during update:\n" << ex; + } + + if (_destroy) + { + break; + } + + timedwait(updatePeriod * 1000); } +} - return EXIT_SUCCESS; +void +IcePatch::Updater::destroy() +{ + IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this); + _destroy = true; + notify(); } void -IcePatch::Server::cleanup(const FileDescSeq& fileDescSeq) +IcePatch::Updater::cleanup(const FileDescSeq& fileDescSeq) { + if (_destroy) + { + return; + } + for (FileDescSeq::const_iterator p = fileDescSeq.begin(); p != fileDescSeq.end(); ++p) { DirectoryDescPtr directoryDesc = DirectoryDescPtr::dynamicCast(*p); |