diff options
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/IcePatch/FileLocator.cpp | 9 | ||||
-rw-r--r-- | cpp/src/IcePatch/FileLocator.h | 3 | ||||
-rw-r--r-- | cpp/src/IcePatch/IcePatchI.cpp | 56 | ||||
-rw-r--r-- | cpp/src/IcePatch/IcePatchI.h | 3 | ||||
-rw-r--r-- | cpp/src/IcePatch/Server.cpp | 10 | ||||
-rw-r--r-- | cpp/src/IcePatch/Util.cpp | 16 |
6 files changed, 51 insertions, 46 deletions
diff --git a/cpp/src/IcePatch/FileLocator.cpp b/cpp/src/IcePatch/FileLocator.cpp index a7687512561..9e7da87be25 100644 --- a/cpp/src/IcePatch/FileLocator.cpp +++ b/cpp/src/IcePatch/FileLocator.cpp @@ -22,7 +22,10 @@ using namespace IcePatch; IcePatch::FileLocator::FileLocator(const Ice::ObjectAdapterPtr& adapter) : _directory(new DirectoryI(adapter)), - _regular(new RegularI(adapter)) + _regular(new RegularI(adapter)), + _logger(adapter->getCommunicator()->getLogger()), + _fileTraceLogger(adapter->getCommunicator()->getProperties()->getPropertyAsInt("IcePatch.Trace.Files") > 0 ? + _logger : LoggerPtr()) { } @@ -68,11 +71,11 @@ IcePatch::FileLocator::locate(const Current& current, LocalObjectPtr&) FileInfo info; try { - info = getFileInfo(path, true); + info = getFileInfo(path, true, _fileTraceLogger); } catch(const FileAccessException& ex) { - Warning out(current.adapter->getCommunicator()->getLogger()); + Warning out(_logger); out << ex << ":\n" << ex.reason; return 0; } diff --git a/cpp/src/IcePatch/FileLocator.h b/cpp/src/IcePatch/FileLocator.h index 3f6c159c29b..231b08bfe34 100644 --- a/cpp/src/IcePatch/FileLocator.h +++ b/cpp/src/IcePatch/FileLocator.h @@ -37,6 +37,9 @@ private: DirectoryPtr _directory; // The stateless default servant for all directories. RegularPtr _regular; // The stateless default servant for all regular files. + + const Ice::LoggerPtr _logger; + const Ice::LoggerPtr _fileTraceLogger; }; } diff --git a/cpp/src/IcePatch/IcePatchI.cpp b/cpp/src/IcePatch/IcePatchI.cpp index 2aae5148bef..dc494bebfc3 100644 --- a/cpp/src/IcePatch/IcePatchI.cpp +++ b/cpp/src/IcePatch/IcePatchI.cpp @@ -23,8 +23,8 @@ static IceUtil::RWRecMutex globalMutex; IcePatch::FileI::FileI(const ObjectAdapterPtr& adapter) : _adapter(adapter), - _logger(adapter->getCommunicator()->getLogger()), - _traceLevel(adapter->getCommunicator()->getProperties()->getPropertyAsInt("IcePatch.Trace.Files")), + _fileTraceLogger(adapter->getCommunicator()->getProperties()->getPropertyAsInt("IcePatch.Trace.Files") > 0 ? + adapter->getCommunicator()->getLogger() : LoggerPtr()), _busyTimeout(IceUtil::Time::seconds(adapter->getCommunicator()->getProperties()-> getPropertyAsIntWithDefault("IcePatch.BusyTimeout", 10))) { @@ -47,14 +47,14 @@ IcePatch::FileI::readMD5(const Current& current) const { IceUtil::RWRecMutex::TryRLock sync(globalMutex, _busyTimeout); - FileInfo info = getFileInfo(path, true); - FileInfo infoMD5 = getFileInfo(path + ".md5", false); + FileInfo info = getFileInfo(path, true, _fileTraceLogger); + FileInfo infoMD5 = getFileInfo(path + ".md5", false, _fileTraceLogger); if(infoMD5.type != FileTypeRegular || infoMD5.time <= info.time) { sync.timedUpgrade(_busyTimeout); - infoMD5 = getFileInfo(path + ".md5", false); + infoMD5 = getFileInfo(path + ".md5", false, _fileTraceLogger); while(infoMD5.type != FileTypeRegular || infoMD5.time <= info.time) { // @@ -68,15 +68,15 @@ IcePatch::FileI::readMD5(const Current& current) const IceUtil::ThreadControl::sleep(diff); } - createMD5(path, _traceLevel > 0 ? _logger : LoggerPtr()); + createMD5(path, _fileTraceLogger); // // If the source file size has changed after we // created the MD5 file, we try again. // FileInfo oldInfo = info; - info = getFileInfo(path, true); - infoMD5 = getFileInfo(path + ".md5", true); // Must exist. + info = getFileInfo(path, true, _fileTraceLogger); + infoMD5 = getFileInfo(path + ".md5", true, _fileTraceLogger); // Must exist. if(info.size != oldInfo.size) { info.time = infoMD5.time; @@ -138,7 +138,7 @@ IcePatch::DirectoryI::getContents(const Current& current) const equal_range(paths2.begin(), paths2.end(), removeSuffix(*p)); if(r2.first == r2.second) { - removeRecursive(*p, _traceLevel > 0 ? _logger : LoggerPtr()); + removeRecursive(*p, _fileTraceLogger); } } } @@ -201,26 +201,26 @@ IcePatch::RegularI::getBZ2Size(const Current& current) const string path = identityToPath(current.id); - FileInfo info = getFileInfo(path, true); + FileInfo info = getFileInfo(path, true, _fileTraceLogger); assert(info.type == FileTypeRegular); - FileInfo infoBZ2 = getFileInfo(path + ".bz2", false); + FileInfo infoBZ2 = getFileInfo(path + ".bz2", false, _fileTraceLogger); if(infoBZ2.type != FileTypeRegular || infoBZ2.time <= info.time) { sync.timedUpgrade(_busyTimeout); - infoBZ2 = getFileInfo(path + ".bz2", false); + infoBZ2 = getFileInfo(path + ".bz2", false, _fileTraceLogger); while(infoBZ2.type != FileTypeRegular || infoBZ2.time <= info.time) { - createBZ2(path, _traceLevel > 0 ? _logger : LoggerPtr()); + createBZ2(path, _fileTraceLogger); // // If the source file size has changed after we // created the BZ2 file, we try again. // FileInfo oldInfo = info; - info = getFileInfo(path, true); - infoBZ2 = getFileInfo(path + ".bz2", true); // Must exist. + info = getFileInfo(path, true, _fileTraceLogger); + infoBZ2 = getFileInfo(path + ".bz2", true, _fileTraceLogger); // Must exist. if(info.size != oldInfo.size) { info.time = infoBZ2.time; @@ -245,26 +245,26 @@ IcePatch::RegularI::getBZ2(Int pos, Int num, const Current& current) const string path = identityToPath(current.id); - FileInfo info = getFileInfo(path, true); + FileInfo info = getFileInfo(path, true, _fileTraceLogger); assert(info.type == FileTypeRegular); - FileInfo infoBZ2 = getFileInfo(path + ".bz2", false); + FileInfo infoBZ2 = getFileInfo(path + ".bz2", false, _fileTraceLogger); if(infoBZ2.type != FileTypeRegular || infoBZ2.time <= info.time) { sync.timedUpgrade(_busyTimeout); - infoBZ2 = getFileInfo(path + ".bz2", false); + infoBZ2 = getFileInfo(path + ".bz2", false, _fileTraceLogger); while(infoBZ2.type != FileTypeRegular || infoBZ2.time <= info.time) { - createBZ2(path, _traceLevel > 0 ? _logger : LoggerPtr()); + createBZ2(path, _fileTraceLogger); // // If the source file size has changed after we // created the BZ2 file, we try again. // FileInfo oldInfo = info; - info = getFileInfo(path, true); - infoBZ2 = getFileInfo(path + ".bz2", true); // Must exist. + info = getFileInfo(path, true, _fileTraceLogger); + infoBZ2 = getFileInfo(path + ".bz2", true, _fileTraceLogger); // Must exist. if(info.size != oldInfo.size) { info.time = infoBZ2.time; @@ -289,26 +289,26 @@ IcePatch::RegularI::getBZ2MD5(Int size, const Current& current) const string path = identityToPath(current.id); - FileInfo info = getFileInfo(path, true); + FileInfo info = getFileInfo(path, true, _fileTraceLogger); assert(info.type == FileTypeRegular); - FileInfo infoBZ2 = getFileInfo(path + ".bz2", false); + FileInfo infoBZ2 = getFileInfo(path + ".bz2", false, _fileTraceLogger); if(infoBZ2.type != FileTypeRegular || infoBZ2.time <= info.time) { sync.timedUpgrade(_busyTimeout); - infoBZ2 = getFileInfo(path + ".bz2", false); + infoBZ2 = getFileInfo(path + ".bz2", false, _fileTraceLogger); while(infoBZ2.type != FileTypeRegular || infoBZ2.time <= info.time) { - createBZ2(path, _traceLevel > 0 ? _logger : LoggerPtr()); + createBZ2(path, _fileTraceLogger); // // If the source file size has changed after we // created the BZ2 file, we try again. // FileInfo oldInfo = info; - info = getFileInfo(path, true); - infoBZ2 = getFileInfo(path + ".bz2", true); // Must exist. + info = getFileInfo(path, true, _fileTraceLogger); + infoBZ2 = getFileInfo(path + ".bz2", true, _fileTraceLogger); // Must exist. if(info.size != oldInfo.size) { info.time = infoBZ2.time; @@ -316,7 +316,7 @@ IcePatch::RegularI::getBZ2MD5(Int size, const Current& current) const } } - return IcePatch::calcPartialMD5(path + ".bz2", size); + return IcePatch::calcPartialMD5(path + ".bz2", size, _fileTraceLogger); } catch(const IceUtil::ThreadLockedException&) { diff --git a/cpp/src/IcePatch/IcePatchI.h b/cpp/src/IcePatch/IcePatchI.h index b3d6eed3dd2..2f58ea93fc5 100644 --- a/cpp/src/IcePatch/IcePatchI.h +++ b/cpp/src/IcePatch/IcePatchI.h @@ -33,8 +33,7 @@ protected: Ice::ByteSeq readMD5(const Ice::Current&) const; const Ice::ObjectAdapterPtr _adapter; - const Ice::LoggerPtr _logger; - const Ice::Int _traceLevel; + const Ice::LoggerPtr _fileTraceLogger; const IceUtil::Time _busyTimeout; }; diff --git a/cpp/src/IcePatch/Server.cpp b/cpp/src/IcePatch/Server.cpp index 54103864ee7..e7f416d1195 100644 --- a/cpp/src/IcePatch/Server.cpp +++ b/cpp/src/IcePatch/Server.cpp @@ -230,13 +230,13 @@ IcePatch::Updater::destroy() void IcePatch::Updater::cleanup(const FileDescSeq& fileDescSeq) { - if(_destroy) - { - return; - } - for(FileDescSeq::const_iterator p = fileDescSeq.begin(); p != fileDescSeq.end(); ++p) { + if(_destroy) + { + return; + } + DirectoryDescPtr directoryDesc = DirectoryDescPtr::dynamicCast(*p); if(directoryDesc) { diff --git a/cpp/src/IcePatch/Util.cpp b/cpp/src/IcePatch/Util.cpp index a413bd55f36..7a68790a3e3 100644 --- a/cpp/src/IcePatch/Util.cpp +++ b/cpp/src/IcePatch/Util.cpp @@ -190,7 +190,7 @@ IcePatch::getFileInfo(const string& path, bool exceptionIfNotExist, const Ice::L { try { - removeRecursive(path + ".md5"); + removeRecursive(path + ".md5", logger); } catch(const FileAccessException&) { @@ -198,7 +198,7 @@ IcePatch::getFileInfo(const string& path, bool exceptionIfNotExist, const Ice::L try { - removeRecursive(path + ".bz2"); + removeRecursive(path + ".bz2", logger); } catch(const FileAccessException&) { @@ -227,12 +227,12 @@ IcePatch::getFileInfo(const string& path, bool exceptionIfNotExist, const Ice::L void IcePatch::removeRecursive(const string& path, const Ice::LoggerPtr& logger) { - if(getFileInfo(path, true).type == FileTypeDirectory) + if(getFileInfo(path, true, logger).type == FileTypeDirectory) { StringSeq paths = readDirectory(path); for(StringSeq::const_iterator p = paths.begin(); p != paths.end(); ++p) { - removeRecursive(*p); + removeRecursive(*p, logger); } #ifdef _WIN32 @@ -443,7 +443,7 @@ IcePatch::createMD5(const string& path, const LoggerPtr& logger) ByteSeq bytes; - FileInfo info = getFileInfo(path, true); + FileInfo info = getFileInfo(path, true, logger); if(info.type == FileTypeDirectory) { // @@ -530,7 +530,7 @@ IcePatch::createMD5(const string& path, const LoggerPtr& logger) } ByteSeq -IcePatch::calcPartialMD5(const string& path, Int size) +IcePatch::calcPartialMD5(const string& path, Int size, const LoggerPtr& logger) { if(size < 0) { @@ -539,7 +539,7 @@ IcePatch::calcPartialMD5(const string& path, Int size) throw ex; } - FileInfo info = getFileInfo(path, true); + FileInfo info = getFileInfo(path, true, logger); if(info.type == FileTypeDirectory) { FileAccessException ex; @@ -660,7 +660,7 @@ IcePatch::getBZ2(const string& path, Int pos, Int num) void IcePatch::createBZ2(const string& path, const Ice::LoggerPtr& logger) { - FileInfo info = getFileInfo(path, true); + FileInfo info = getFileInfo(path, true, logger); if(info.type == FileTypeDirectory) { FileAccessException ex; |