diff options
Diffstat (limited to 'cpp/src/IcePatch/IcePatchI.cpp')
-rw-r--r-- | cpp/src/IcePatch/IcePatchI.cpp | 88 |
1 files changed, 24 insertions, 64 deletions
diff --git a/cpp/src/IcePatch/IcePatchI.cpp b/cpp/src/IcePatch/IcePatchI.cpp index a9c2f480cac..502757b3232 100644 --- a/cpp/src/IcePatch/IcePatchI.cpp +++ b/cpp/src/IcePatch/IcePatchI.cpp @@ -34,66 +34,15 @@ IcePatch::DirectoryI::DirectoryI(const ObjectAdapterPtr& adapter) : FileDescPtr IcePatch::DirectoryI::describe(const Current& current) { - string path = identityToPath(current.id); - + // No mutex lock necessary. DirectoryDescPtr desc = new DirectoryDesc; desc->directory = DirectoryPrx::uncheckedCast(_adapter->createProxy(current.id)); - - 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(); - } + return desc; } FileDescSeq IcePatch::DirectoryI::getContents(const Current& current) { - string path = identityToPath(current.id); - StringSeq filteredPaths; try @@ -101,6 +50,7 @@ IcePatch::DirectoryI::getContents(const Current& current) 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) @@ -174,17 +124,19 @@ IcePatch::RegularI::RegularI(const ObjectAdapterPtr& adapter) : FileDescPtr 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); + assert(info.type == FileTypeRegular); + FileInfo infoMD5 = getFileInfo(path + ".md5", false); if(infoMD5.type != FileTypeRegular || infoMD5.time <= info.time) { sync.timedUpgrade(_busyTimeout); + infoMD5 = getFileInfo(path + ".md5", false); if(infoMD5.type != FileTypeRegular || infoMD5.time <= info.time) { @@ -193,7 +145,7 @@ IcePatch::RegularI::describe(const Current& current) if(_traceLevel > 0) { Trace out(_logger, "IcePatch"); - out << "created .md5 file for regular file `" << path << "'"; + out << "created MD5 file for file `" << path << "'"; } } } @@ -212,17 +164,19 @@ IcePatch::RegularI::describe(const Current& current) Int 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); + assert(info.type == FileTypeRegular); + FileInfo infoBZ2 = getFileInfo(path + ".bz2", false); if(infoBZ2.type != FileTypeRegular || infoBZ2.time <= info.time) { sync.timedUpgrade(_busyTimeout); + infoBZ2 = getFileInfo(path + ".bz2", false); if(infoBZ2.type != FileTypeRegular || infoBZ2.time <= info.time) { @@ -231,12 +185,14 @@ IcePatch::RegularI::getBZ2Size(const Current& current) if(_traceLevel > 0) { Trace out(_logger, "IcePatch"); - out << "created .bz2 file for `" << path << "'"; + out << "created BZ2 file for `" << path << "'"; } + // // Get the .bz2 file info again, so that we can return the // size below. This time the .bz2 file must exist, // otherwise an exception is raised. + // infoBZ2 = getFileInfo(path + ".bz2", true); } } @@ -252,17 +208,19 @@ IcePatch::RegularI::getBZ2Size(const Current& current) ByteSeq 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); + assert(info.type == FileTypeRegular); + FileInfo infoBZ2 = getFileInfo(path + ".bz2", false); if(infoBZ2.type != FileTypeRegular || infoBZ2.time <= info.time) { sync.timedUpgrade(_busyTimeout); + infoBZ2 = getFileInfo(path + ".bz2", false); if(infoBZ2.type != FileTypeRegular || infoBZ2.time <= info.time) { @@ -287,17 +245,19 @@ IcePatch::RegularI::getBZ2(Int pos, Int num, const Current& current) ByteSeq 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); + assert(info.type == FileTypeRegular); + FileInfo infoBZ2 = getFileInfo(path + ".bz2", false); if(infoBZ2.type != FileTypeRegular || infoBZ2.time <= info.time) { sync.timedUpgrade(_busyTimeout); + infoBZ2 = getFileInfo(path + ".bz2", false); if(infoBZ2.type != FileTypeRegular || infoBZ2.time <= info.time) { @@ -311,7 +271,7 @@ IcePatch::RegularI::getBZ2MD5(Int size, const Current& current) } } - return IcePatch::getPartialMD5(path + ".bz2", size); + return IcePatch::calcPartialMD5(path + ".bz2", size); } catch(const IceUtil::LockedException&) { |