diff options
author | Marc Laukien <marc@zeroc.com> | 2002-09-01 21:21:05 +0000 |
---|---|---|
committer | Marc Laukien <marc@zeroc.com> | 2002-09-01 21:21:05 +0000 |
commit | 31b064d4e4f55aadb9f03ab66ac59a94d82adfb6 (patch) | |
tree | c9e86b395f9c2c45e8205ae8ab99d3c5cbe6b838 /cpp/src | |
parent | cleaning up empty identity handling (diff) | |
download | ice-31b064d4e4f55aadb9f03ab66ac59a94d82adfb6.tar.bz2 ice-31b064d4e4f55aadb9f03ab66ac59a94d82adfb6.tar.xz ice-31b064d4e4f55aadb9f03ab66ac59a94d82adfb6.zip |
IcePatch work
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/Freeze/EvictorI.cpp | 5 | ||||
-rw-r--r-- | cpp/src/Glacier/Blobject.cpp | 6 | ||||
-rw-r--r-- | cpp/src/Glacier/Missive.cpp | 6 | ||||
-rw-r--r-- | cpp/src/Ice/Application.cpp | 35 | ||||
-rw-r--r-- | cpp/src/Ice/Incoming.cpp | 4 | ||||
-rw-r--r-- | cpp/src/Ice/LoggerI.cpp | 10 | ||||
-rw-r--r-- | cpp/src/Ice/Outgoing.cpp | 6 | ||||
-rw-r--r-- | cpp/src/Ice/Proxy.cpp | 16 | ||||
-rw-r--r-- | cpp/src/Ice/StringUtil.cpp | 14 | ||||
-rw-r--r-- | cpp/src/IcePatch/FileLocator.cpp | 20 | ||||
-rw-r--r-- | cpp/src/IcePatch/IcePatchI.cpp | 84 | ||||
-rw-r--r-- | cpp/src/IcePatch/Server.cpp | 66 | ||||
-rw-r--r-- | cpp/src/IcePatch/Util.cpp | 82 | ||||
-rw-r--r-- | cpp/src/IceStorm/IceStormInternal.ice | 4 | ||||
-rw-r--r-- | cpp/src/IceStorm/LinkSubscriber.cpp | 2 | ||||
-rw-r--r-- | cpp/src/IceStorm/OnewaySubscriber.cpp | 2 | ||||
-rw-r--r-- | cpp/src/IceStorm/Subscriber.h | 2 | ||||
-rw-r--r-- | cpp/src/IceStorm/TopicI.cpp | 6 |
18 files changed, 253 insertions, 117 deletions
diff --git a/cpp/src/Freeze/EvictorI.cpp b/cpp/src/Freeze/EvictorI.cpp index 62b40db1f59..4e11ff221ca 100644 --- a/cpp/src/Freeze/EvictorI.cpp +++ b/cpp/src/Freeze/EvictorI.cpp @@ -317,9 +317,12 @@ Freeze::EvictorI::finished(const ObjectAdapterPtr&, const Current& current, // If we are in SaveAfterMutatingOperation mode, we must save the // Ice Object if this was a mutating call. // + // TODO: ML: Badly broken now, we don't save if an operation is + // mutating and idempotent!!! + // if(_persistenceMode == SaveAfterMutatingOperation) { - if(!current.isIdempotent) + if(!current.idempotent) { _dict.insert(make_pair(current.id, servant)); } diff --git a/cpp/src/Glacier/Blobject.cpp b/cpp/src/Glacier/Blobject.cpp index 66ddf171e98..bfd9626d994 100644 --- a/cpp/src/Glacier/Blobject.cpp +++ b/cpp/src/Glacier/Blobject.cpp @@ -74,16 +74,16 @@ Glacier::Blobject::invoke(ObjectPrx& proxy, const vector<Byte>& inParams, vector out << "routing to:\n" << "proxy = " << _communicator->proxyToString(proxy) << '\n' << "operation = " << current.operation << '\n' - << "idempotent = " << (current.isIdempotent ? "true" : "false"); + << "idempotent = " << (current.idempotent ? "true" : "false"); } if(_forwardContext) { - return proxy->ice_invoke(current.operation, current.isIdempotent, inParams, outParams, current.ctx); + return proxy->ice_invoke(current.operation, current.idempotent, inParams, outParams, current.ctx); } else { - return proxy->ice_invoke(current.operation, current.isIdempotent, inParams, outParams); + return proxy->ice_invoke(current.operation, current.idempotent, inParams, outParams); } } } diff --git a/cpp/src/Glacier/Missive.cpp b/cpp/src/Glacier/Missive.cpp index 531ccb3e456..d7fdc924d6b 100644 --- a/cpp/src/Glacier/Missive.cpp +++ b/cpp/src/Glacier/Missive.cpp @@ -34,11 +34,11 @@ Glacier::Missive::invoke() std::vector<Byte> dummy; if(_forwardContext) { - _proxy->ice_invoke(_current.operation, _current.isIdempotent, _inParams, dummy, _current.ctx); + _proxy->ice_invoke(_current.operation, _current.idempotent, _inParams, dummy, _current.ctx); } else { - _proxy->ice_invoke(_current.operation, _current.isIdempotent, _inParams, dummy); + _proxy->ice_invoke(_current.operation, _current.idempotent, _inParams, dummy); } } @@ -161,7 +161,7 @@ Glacier::MissiveQueue::run() out << "batch routing to:\n" << "proxy = " << _communicator->proxyToString(proxy) << '\n' << "operation = " << current.operation << '\n' - << "isIdempotent = " << (current.isIdempotent ? "true" : "false"); + << "idempotent = " << (current.idempotent ? "true" : "false"); } (*p)->invoke(); diff --git a/cpp/src/Ice/Application.cpp b/cpp/src/Ice/Application.cpp index beb4e6eca01..d0480baa916 100644 --- a/cpp/src/Ice/Application.cpp +++ b/cpp/src/Ice/Application.cpp @@ -16,8 +16,9 @@ using namespace std; using namespace Ice; -const char* Application::_appName; +const char* Application::_appName = 0; CommunicatorPtr Application::_communicator; +bool Application::_shutdown = false; Ice::Application::Application() { @@ -101,11 +102,16 @@ Ice::Application::communicator() #ifdef _WIN32 -static BOOL WINAPI -interruptHandler(DWORD) +BOOL WINAPI +Ice::interruptHandler(DWORD) { - assert(Application::communicator()); - Application::communicator()->shutdown(); + Application::_shutdown = true; + + // + // Don't use Application::communicator(), this is not signal-safe. + // + assert(Application::_communicator); + Application::_communicator->shutdown(); return TRUE; } @@ -132,11 +138,16 @@ Ice::Application::defaultInterrupt() #else -static void -interruptHandler(int) +void +Ice::interruptHandler(int) { - assert(Application::communicator()); - Application::communicator()->shutdown(); + Application::_shutdown = true; + + // + // Don't use Application::communicator(), this is not signal-safe. + // + assert(Application::_communicator); + Application::_communicator->shutdown(); } void @@ -179,3 +190,9 @@ Ice::Application::defaultInterrupt() } #endif + +bool +Ice::Application::isShutdownFromInterrupt() +{ + return _shutdown; +} diff --git a/cpp/src/Ice/Incoming.cpp b/cpp/src/Ice/Incoming.cpp index 8275c43ed4c..3f956cef439 100644 --- a/cpp/src/Ice/Incoming.cpp +++ b/cpp/src/Ice/Incoming.cpp @@ -32,7 +32,7 @@ IceInternal::Incoming::invoke(bool response) current.id.__read(&_is); _is.read(current.facet); _is.read(current.operation); - _is.read(current.isIdempotent); + _is.read(current.idempotent); Int sz; _is.readSize(sz); while(sz--) @@ -272,7 +272,7 @@ IceInternal::Incoming::invoke(bool response) // Rethrow, so that the caller can print a warning. ex.ice_throw(); } - catch (...) + catch(...) { if(locator && servant) { diff --git a/cpp/src/Ice/LoggerI.cpp b/cpp/src/Ice/LoggerI.cpp index 3fed27a131c..04982f6a651 100644 --- a/cpp/src/Ice/LoggerI.cpp +++ b/cpp/src/Ice/LoggerI.cpp @@ -21,11 +21,6 @@ Ice::LoggerI::LoggerI(const string& prefix) if(!prefix.empty()) { _prefix = prefix + ": "; - - // - // A prefix filled with spaces and as long as the prefix. - // - _emptyPrefix.append(_prefix.length(), ' '); } } @@ -33,15 +28,14 @@ void Ice::LoggerI::trace(const string& category, const string& message) { IceUtil::Mutex::Lock sync(_globalMutex); - string s = "[ " + category + ": " + message + " ]"; + string s = "[ " + _prefix + category + ": " + message + " ]"; string::size_type idx = 0; while((idx = s.find("\n", idx)) != string::npos) { s.insert(idx + 1, " "); - s.insert(idx + 1, _emptyPrefix); ++idx; } - cerr << _prefix << s << endl; + cerr << s << endl; } void diff --git a/cpp/src/Ice/Outgoing.cpp b/cpp/src/Ice/Outgoing.cpp index f02cc10e07a..46085df1879 100644 --- a/cpp/src/Ice/Outgoing.cpp +++ b/cpp/src/Ice/Outgoing.cpp @@ -37,7 +37,7 @@ IceInternal::NonRepeatable::get() const } IceInternal::Outgoing::Outgoing(const ConnectionPtr& connection, const ReferencePtr& ref, const string& operation, - bool isIdempotent, const Context& context) : + bool idempotent, const Context& context) : _connection(connection), _reference(ref), _state(StateUnsent), @@ -65,7 +65,7 @@ IceInternal::Outgoing::Outgoing(const ConnectionPtr& connection, const Reference _reference->identity.__write(&_os); _os.write(_reference->facet); _os.write(operation); - _os.write(isIdempotent); + _os.write(idempotent); _os.writeSize(Int(context.size())); Context::const_iterator p; for(p = context.begin(); p != context.end(); ++p) @@ -85,7 +85,7 @@ IceInternal::Outgoing::Outgoing(const ConnectionPtr& connection, const Reference IceInternal::Outgoing::~Outgoing() { if(_state == StateUnsent && - (_reference->mode == Reference::ModeBatchOneway || _reference->mode == Reference::ModeBatchDatagram)) + (_reference->mode == Reference::ModeBatchOneway || _reference->mode == Reference::ModeBatchDatagram)) { _connection->abortBatchRequest(); } diff --git a/cpp/src/Ice/Proxy.cpp b/cpp/src/Ice/Proxy.cpp index 6e48eaccff3..098987d2d24 100644 --- a/cpp/src/Ice/Proxy.cpp +++ b/cpp/src/Ice/Proxy.cpp @@ -249,7 +249,7 @@ IceProxy::Ice::Object::ice_facets(const Context& __context) bool IceProxy::Ice::Object::ice_invoke(const string& operation, - bool isIdempotent, + bool idempotent, const vector<Byte>& inParams, vector<Byte>& outParams, const Context& context) @@ -260,7 +260,7 @@ IceProxy::Ice::Object::ice_invoke(const string& operation, try { Handle< ::IceDelegate::Ice::Object> __del = __getDelegate(); - return __del->ice_invoke(operation, isIdempotent, inParams, outParams, context); + return __del->ice_invoke(operation, idempotent, inParams, outParams, context); } catch(const LocationForward& __ex) { @@ -268,7 +268,7 @@ IceProxy::Ice::Object::ice_invoke(const string& operation, } catch(const NonRepeatable& __ex) { - if(isIdempotent) + if(idempotent) { __handleException(*__ex.get(), __cnt); } @@ -817,12 +817,12 @@ IceDelegateM::Ice::Object::ice_facets(const Context& __context) bool IceDelegateM::Ice::Object::ice_invoke(const string& operation, - bool isIdempotent, + bool idempotent, const vector<Byte>& inParams, vector<Byte>& outParams, const Context& context) { - Outgoing __out(__connection, __reference, operation, isIdempotent, context); + Outgoing __out(__connection, __reference, operation, idempotent, context); BasicStream* __os = __out.os(); __os->writeBlob(inParams); bool ok = __out.invoke(); @@ -1192,13 +1192,13 @@ IceDelegateD::Ice::Object::ice_facets(const ::Ice::Context& __context) bool IceDelegateD::Ice::Object::ice_invoke(const string& operation, - bool isIdempotent, + bool idempotent, const vector<Byte>& inParams, vector<Byte>& outParams, const ::Ice::Context& context) { Current current; - __initCurrent(current, operation, isIdempotent, context); + __initCurrent(current, operation, idempotent, context); while(true) { Direct __direct(__adapter, current); @@ -1258,7 +1258,7 @@ IceDelegateD::Ice::Object::__initCurrent(Current& current, const string& op, boo current.id = __reference->identity; current.facet = __reference->facet; current.operation = op; - current.isIdempotent = idempotent; + current.idempotent = idempotent; current.ctx = context; } diff --git a/cpp/src/Ice/StringUtil.cpp b/cpp/src/Ice/StringUtil.cpp index 19ae9762978..eedaa47b60e 100644 --- a/cpp/src/Ice/StringUtil.cpp +++ b/cpp/src/Ice/StringUtil.cpp @@ -78,6 +78,7 @@ encodeChar(string::value_type b, string& s, const string& special) } default: { + // TODO: ML: Don't use old C-style casts. if(((signed char)b) <= 31 || b == 127) { s.push_back('\\'); @@ -154,7 +155,7 @@ IceInternal::decodeString(const string& s, string::size_type start, string::size start++; if(start == end) { - return false; // Missing character + return false; // Missing character. } ch = s[start]; switch(ch) @@ -217,16 +218,17 @@ IceInternal::decodeString(const string& s, string::size_type start, string::size } if(val > 255) { - return false; // Octal value out of range + return false; // Octal value out of range. } result.push_back((string::value_type)val); - continue; // don't increment start + continue; // Don't increment start. } default: { + // TODO: ML: No old C-style casts. if(((signed char)ch) <= 31 || ch == 127) { - return false; // Malformed encoding + return false; // Malformed encoding. } else { @@ -267,7 +269,7 @@ IceInternal::checkQuote(const string& s, string::size_type start) } start = pos + 1; } - return string::npos; // Unmatched quote + return string::npos; // Unmatched quote. } - return 0; // Not quoted + return 0; // Not quoted. } diff --git a/cpp/src/IcePatch/FileLocator.cpp b/cpp/src/IcePatch/FileLocator.cpp index ee22b74f9c8..329cec2ce98 100644 --- a/cpp/src/IcePatch/FileLocator.cpp +++ b/cpp/src/IcePatch/FileLocator.cpp @@ -30,27 +30,37 @@ IcePatch::FileLocator::locate(const ObjectAdapterPtr& adapter, const Current& cu // string path = identityToPath(current.id); - if(path.empty()) // Empty paths are not permissible. + if(path.empty()) + { + return 0; + } + + if(path == ".") { return 0; } - if(path[0] == '/') // Path must not start with '/'. + if(path[0] == '/') // Example: /usr/mail/foo { return 0; } - if(path.find("..") != string::npos) // Path must not contain '..'. + // + // Note: We could make the following rule more selective, to allow + // names such as "...foo". But since such names are rather + // uncommon, we disallow ".." altogether, to be on the safe side. + // + if(path.find("..") != string::npos) // Example: foo/../.. { return 0; } - if(path.find(':') == 1) // Path cannot contain ':' as second character. + if(path.find(':') == 1) // Example: c:\blah { return 0; } - if(ignoreSuffix(path)) // Some suffixes are reserved. + if(ignoreSuffix(path)) // Example: foo.md5 { return 0; } diff --git a/cpp/src/IcePatch/IcePatchI.cpp b/cpp/src/IcePatch/IcePatchI.cpp index 0f1be0a563b..a9c2f480cac 100644 --- a/cpp/src/IcePatch/IcePatchI.cpp +++ b/cpp/src/IcePatch/IcePatchI.cpp @@ -32,25 +32,75 @@ IcePatch::DirectoryI::DirectoryI(const ObjectAdapterPtr& adapter) : } FileDescPtr -IcePatch::DirectoryI::describe(const Ice::Current& current) +IcePatch::DirectoryI::describe(const Current& current) { - // No lock necessary. string path = identityToPath(current.id); + DirectoryDescPtr desc = new DirectoryDesc; desc->directory = DirectoryPrx::uncheckedCast(_adapter->createProxy(current.id)); - return desc; + + try + { + IceUtil::RWRecMutex::TryRLock sync(_globalMutex, _busyTimeout); + + FileInfo info = getFileInfo(path, true); + FileInfo infoMD5 = getFileInfo(path + ".md5", false); + if(infoMD5.type == FileTypeRegular && infoMD5.time > info.time) + { + desc->md5 = getMD5(path); + return desc; + } + } + catch(const IceUtil::LockedException&) + { + throw BusyException(); + } + + // + // Force .md5 files to be created and orphaned files to be + // removed. This must be done outside the thread + // synchronization, to avoid deadlocks. + // + getContents(current); + + try + { + IceUtil::RWRecMutex::TryWLock sync(_globalMutex, _busyTimeout); + + FileInfo info = getFileInfo(path, true); + FileInfo infoMD5 = getFileInfo(path + ".md5", false); + if(infoMD5.type != FileTypeRegular || infoMD5.time <= info.time) + { + createMD5(path); + + if(_traceLevel > 0) + { + Trace out(_logger, "IcePatch"); + out << "created .md5 file for directory `" << path << "'"; + } + } + + desc->md5 = getMD5(path); + return desc; + } + catch(const IceUtil::LockedException&) + { + throw BusyException(); + } } FileDescSeq -IcePatch::DirectoryI::getContents(const Ice::Current& current) +IcePatch::DirectoryI::getContents(const Current& current) { + string path = identityToPath(current.id); + StringSeq filteredPaths; try { IceUtil::RWRecMutex::TryRLock sync(_globalMutex, _busyTimeout); + bool syncUpgraded = false; - string path = identityToPath(current.id); StringSeq paths = readDirectory(path); filteredPaths.reserve(paths.size() / 3); for(StringSeq::const_iterator p = paths.begin(); p != paths.end(); ++p) @@ -122,12 +172,13 @@ IcePatch::RegularI::RegularI(const ObjectAdapterPtr& adapter) : } FileDescPtr -IcePatch::RegularI::describe(const Ice::Current& current) +IcePatch::RegularI::describe(const Current& current) { + string path = identityToPath(current.id); + try { IceUtil::RWRecMutex::TryRLock sync(_globalMutex, _busyTimeout); - string path = identityToPath(current.id); FileInfo info = getFileInfo(path, true); FileInfo infoMD5 = getFileInfo(path + ".md5", false); @@ -142,14 +193,14 @@ IcePatch::RegularI::describe(const Ice::Current& current) if(_traceLevel > 0) { Trace out(_logger, "IcePatch"); - out << "created .md5 file for `" << path << "'"; + out << "created .md5 file for regular file `" << path << "'"; } } } RegularDescPtr desc = new RegularDesc; - desc->regular = RegularPrx::uncheckedCast(_adapter->createProxy(current.id)); desc->md5 = getMD5(path); + desc->regular = RegularPrx::uncheckedCast(_adapter->createProxy(current.id)); return desc; } catch(const IceUtil::LockedException&) @@ -159,12 +210,13 @@ IcePatch::RegularI::describe(const Ice::Current& current) } Int -IcePatch::RegularI::getBZ2Size(const Ice::Current& current) +IcePatch::RegularI::getBZ2Size(const Current& current) { + string path = identityToPath(current.id); + try { IceUtil::RWRecMutex::TryRLock sync(_globalMutex, _busyTimeout); - string path = identityToPath(current.id); FileInfo info = getFileInfo(path, true); FileInfo infoBZ2 = getFileInfo(path + ".bz2", false); @@ -198,12 +250,13 @@ IcePatch::RegularI::getBZ2Size(const Ice::Current& current) } ByteSeq -IcePatch::RegularI::getBZ2(Ice::Int pos, Ice::Int num, const Ice::Current& current) +IcePatch::RegularI::getBZ2(Int pos, Int num, const Current& current) { + string path = identityToPath(current.id); + try { IceUtil::RWRecMutex::TryRLock sync(_globalMutex, _busyTimeout); - string path = identityToPath(current.id); FileInfo info = getFileInfo(path, true); FileInfo infoBZ2 = getFileInfo(path + ".bz2", false); @@ -232,12 +285,13 @@ IcePatch::RegularI::getBZ2(Ice::Int pos, Ice::Int num, const Ice::Current& curre } ByteSeq -IcePatch::RegularI::getBZ2MD5(Ice::Int size, const Ice::Current& current) +IcePatch::RegularI::getBZ2MD5(Int size, const Current& current) { + string path = identityToPath(current.id); + try { IceUtil::RWRecMutex::TryRLock sync(_globalMutex, _busyTimeout); - string path = identityToPath(current.id); FileInfo info = getFileInfo(path, true); FileInfo infoBZ2 = getFileInfo(path + ".bz2", false); diff --git a/cpp/src/IcePatch/Server.cpp b/cpp/src/IcePatch/Server.cpp index f4d5f3667e7..4b24fd43fa8 100644 --- a/cpp/src/IcePatch/Server.cpp +++ b/cpp/src/IcePatch/Server.cpp @@ -35,14 +35,16 @@ class Updater : public IceUtil::Thread, public IceUtil::Monitor<IceUtil::Mutex> { public: - Updater(const ObjectAdapterPtr&); + Updater(const ObjectAdapterPtr&, const IceUtil::Time&); virtual void run(); void destroy(); protected: - const ObjectAdapterPtr& _adapter; + const ObjectAdapterPtr _adapter; + const LoggerPtr _logger; + const IceUtil::Time _updatePeriod; bool _destroy; void cleanup(const FileDescSeq&); @@ -125,10 +127,20 @@ IcePatch::Server::run(int argc, char* argv[]) adapter->addServantLocator(fileLocator, "IcePatch"); // - // Start updater. + // Start the updater if an update period is set. // - UpdaterPtr updater = new Updater(adapter); - updater->start(); + UpdaterPtr updater; + IceUtil::Time updatePeriod = IceUtil::Time::seconds( + properties->getPropertyAsIntWithDefault("IcePatch.UpdatePeriod", 60)); + if(updatePeriod != IceUtil::Time()) + { + if(updatePeriod < IceUtil::Time::seconds(10)) + { + updatePeriod = IceUtil::Time::seconds(10); + } + updater = new Updater(adapter, updatePeriod); + updater->start(); + } // // Everything ok, let's go. @@ -139,16 +151,21 @@ IcePatch::Server::run(int argc, char* argv[]) ignoreInterrupt(); // - // Destroy and join with updater. + // Destroy and join with the updater, if there is one. // - updater->destroy(); - updater->getThreadControl().join(); + if(updater) + { + updater->destroy(); + updater->getThreadControl().join(); + } return EXIT_SUCCESS; } -IcePatch::Updater::Updater(const ObjectAdapterPtr& adapter) : +IcePatch::Updater::Updater(const ObjectAdapterPtr& adapter, const IceUtil::Time& updatePeriod) : _adapter(adapter), + _logger(_adapter->getCommunicator()->getLogger()), + _updatePeriod(updatePeriod), _destroy(false) { } @@ -158,14 +175,6 @@ IcePatch::Updater::run() { IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this); - PropertiesPtr properties = _adapter->getCommunicator()->getProperties(); - IceUtil::Time updatePeriod = IceUtil::Time::seconds( - properties->getPropertyAsIntWithDefault("IcePatch.UpdatePeriod", 60)); - if(updatePeriod < IceUtil::Time::seconds(10)) - { - updatePeriod = IceUtil::Time::seconds(10); - } - while(!_destroy) { try @@ -180,7 +189,7 @@ IcePatch::Updater::run() } catch(const FileAccessException& ex) { - Error out(_adapter->getCommunicator()->getLogger()); + Error out(_logger); out << "exception during update:\n" << ex << ":\n" << ex.reason; } catch(const BusyException&) @@ -189,19 +198,18 @@ IcePatch::Updater::run() // Just loop if we're busy. // } - catch(const ConnectFailedException&) + catch(const Exception& ex) { // - // This exception can be raised if the adapter is shutdown - // while this thread is still running. In such case, we - // terminate this thread. + // If we are interrupted due to a shutdown, don't print + // any exceptions. Exceptions are normal in such case, for + // example, ObjectAdapterDeactivatedException. // - break; - } - catch(const Exception& ex) - { - Error out(_adapter->getCommunicator()->getLogger()); - out << "exception during update:\n" << ex; + if(!Application::isShutdownFromInterrupt()) + { + Error out(_logger); + out << "exception during update:\n" << ex; + } } if(_destroy) @@ -209,7 +217,7 @@ IcePatch::Updater::run() break; } - timedWait(updatePeriod); + timedWait(_updatePeriod); } } diff --git a/cpp/src/IcePatch/Util.cpp b/cpp/src/IcePatch/Util.cpp index 4130c14b0f7..82d33275f09 100644 --- a/cpp/src/IcePatch/Util.cpp +++ b/cpp/src/IcePatch/Util.cpp @@ -70,6 +70,11 @@ normalizePath(const string& path) result.erase(0, 2); } + if(result.size() >= 2 && result.substr(result.size() - 2, 2) == "/.") + { + result.erase(result.size() - 2, 2); + } + return result; } @@ -205,6 +210,7 @@ IcePatch::readDirectory(const string& path) while(true) { string name = data.name; + assert(!name.empty()); if(name != ".." && name != ".") { @@ -248,6 +254,7 @@ IcePatch::readDirectory(const string& path) for(int i = 0; i < n; ++i) { string name = namelist[i]->d_name; + assert(!name.empty()); free(namelist[i]); @@ -360,33 +367,60 @@ IcePatch::getPartialMD5(const string& path, Int size) void IcePatch::createMD5(const string& path) { - // - // Read the original file. - // FileInfo info = getFileInfo(path, true); - ifstream file(path.c_str(), ios::binary); - if(!file) + if(info.type == FileTypeUnknown) { FileAccessException ex; - ex.reason = "cannot open `" + path + "' for reading: " + strerror(errno); + ex.reason = "cannot create .md5 file for `" + path + "' because file type is unknown"; throw ex; } + ByteSeq bytes; - bytes.resize(info.size); - file.read(&bytes[0], bytes.size()); - if(!file) + if(info.type == FileTypeDirectory) { - FileAccessException ex; - ex.reason = "cannot read `" + path + "': " + strerror(errno); - throw ex; + // + // Read all MD5 files in the directory. + // + StringSeq paths = readDirectory(path); + for(StringSeq::const_iterator p = paths.begin(); p != paths.end(); ++p) + { + if(getSuffix(*p) == "md5") + { + ByteSeq md5 = getMD5(removeSuffix(*p)); + copy(md5.begin(), md5.end(), back_inserter(bytes)); + } + } } - if(file.gcount() < static_cast<int>(bytes.size())) + else { - FileAccessException ex; - ex.reason = "could not read all bytes from `" + path + "'"; - throw ex; + assert(info.type == FileTypeRegular); + + // + // Read the original file. + // + ifstream file(path.c_str(), ios::binary); + if(!file) + { + FileAccessException ex; + ex.reason = "cannot open `" + path + "' for reading: " + strerror(errno); + throw ex; + } + bytes.resize(info.size); + file.read(&bytes[0], bytes.size()); + if(!file) + { + FileAccessException ex; + ex.reason = "cannot read `" + path + "': " + strerror(errno); + throw ex; + } + if(file.gcount() < static_cast<int>(bytes.size())) + { + FileAccessException ex; + ex.reason = "could not read all bytes from `" + path + "'"; + throw ex; + } + file.close(); } - file.close(); // // Create the MD5 hash value. @@ -488,6 +522,20 @@ IcePatch::getBZ2(const string& path, Int pos, Int num) void IcePatch::createBZ2(const string& path) { + FileInfo info = getFileInfo(path, true); + if(info.type == FileTypeUnknown) + { + FileAccessException ex; + ex.reason = "cannot create .bz2 file for `" + path + "' because file type is unknown"; + throw ex; + } + if(info.type == FileTypeDirectory) + { + FileAccessException ex; + ex.reason = "cannot create .bz2 file for `" + path + "' because this is a directory"; + throw ex; + } + // // Read the original file in blocks and write a temporary BZ2 // file. diff --git a/cpp/src/IceStorm/IceStormInternal.ice b/cpp/src/IceStorm/IceStormInternal.ice index 8db7889c4d2..6a8170a80bd 100644 --- a/cpp/src/IceStorm/IceStormInternal.ice +++ b/cpp/src/IceStorm/IceStormInternal.ice @@ -46,7 +46,7 @@ interface TopicLink * * @param op The operation name. * - * @param isIdempotent Flag indicating whether the operation is + * @param idempotent Flag indicating whether the operation is * idempotent. * * @param data The encoded for the operation in parameters. @@ -55,7 +55,7 @@ interface TopicLink * originating request. * **/ - void forward(string op, bool isIdempotent, ByteSeq data, ContextData context); + void forward(string op, bool \idempotent, ByteSeq data, ContextData context); }; /** diff --git a/cpp/src/IceStorm/LinkSubscriber.cpp b/cpp/src/IceStorm/LinkSubscriber.cpp index 097ec8a0be0..bce15c94903 100644 --- a/cpp/src/IceStorm/LinkSubscriber.cpp +++ b/cpp/src/IceStorm/LinkSubscriber.cpp @@ -77,7 +77,7 @@ LinkSubscriber::publish(const Event& event) try { - _obj->forward(event.op, event.isIdempotent, event.data, event.context); + _obj->forward(event.op, event.idempotent, event.data, event.context); } catch(const Ice::ObjectNotExistException& e) { diff --git a/cpp/src/IceStorm/OnewaySubscriber.cpp b/cpp/src/IceStorm/OnewaySubscriber.cpp index 30553b9b275..9912e3bf382 100644 --- a/cpp/src/IceStorm/OnewaySubscriber.cpp +++ b/cpp/src/IceStorm/OnewaySubscriber.cpp @@ -63,7 +63,7 @@ OnewaySubscriber::publish(const Event& event) try { std::vector< ::Ice::Byte> dummy; - _obj->ice_invoke(event.op, event.isIdempotent, event.data, dummy, event.context); + _obj->ice_invoke(event.op, event.idempotent, event.data, dummy, event.context); } catch(const Ice::LocalException& e) { diff --git a/cpp/src/IceStorm/Subscriber.h b/cpp/src/IceStorm/Subscriber.h index 912856f19cc..289659863d6 100644 --- a/cpp/src/IceStorm/Subscriber.h +++ b/cpp/src/IceStorm/Subscriber.h @@ -38,7 +38,7 @@ struct Event bool forwarded; int cost; std::string op; - bool isIdempotent; + bool idempotent; std::vector< Ice::Byte> data; Ice::Context context; }; diff --git a/cpp/src/IceStorm/TopicI.cpp b/cpp/src/IceStorm/TopicI.cpp index b5093bcaa80..e733b675442 100644 --- a/cpp/src/IceStorm/TopicI.cpp +++ b/cpp/src/IceStorm/TopicI.cpp @@ -294,7 +294,7 @@ PublisherProxyI::ice_invoke(const vector< Ice::Byte>& inParams, vector< Ice::Byt event.cost = 0; // TODO: Default comes from property? } event.op = current.operation; - event.isIdempotent = current.isIdempotent; + event.idempotent = current.idempotent; event.data = inParams; event.context = context; @@ -307,14 +307,14 @@ PublisherProxyI::ice_invoke(const vector< Ice::Byte>& inParams, vector< Ice::Byt // Incoming events from linked topics. // void -TopicLinkI::forward(const string& op, bool isIdempotent, const ByteSeq& data, const ContextData& context, +TopicLinkI::forward(const string& op, bool idempotent, const ByteSeq& data, const ContextData& context, const Ice::Current& current) { Event event; event.forwarded = true; event.cost = 0; event.op = op; - event.isIdempotent = isIdempotent; + event.idempotent = idempotent; event.data = data; event.context = context; |