summaryrefslogtreecommitdiff
path: root/cpp/src/IcePatch/IcePatchI.cpp
diff options
context:
space:
mode:
authorMarc Laukien <marc@zeroc.com>2002-09-05 15:48:46 +0000
committerMarc Laukien <marc@zeroc.com>2002-09-05 15:48:46 +0000
commit22a89af145cfe3fd5fe9817ddd36c0191563cc67 (patch)
tree9d94fefa6080f0b4d81688a5617ee5a5302cbce9 /cpp/src/IcePatch/IcePatchI.cpp
parentfixes (diff)
downloadice-22a89af145cfe3fd5fe9817ddd36c0191563cc67.tar.bz2
ice-22a89af145cfe3fd5fe9817ddd36c0191563cc67.tar.xz
ice-22a89af145cfe3fd5fe9817ddd36c0191563cc67.zip
more icepatch work
Diffstat (limited to 'cpp/src/IcePatch/IcePatchI.cpp')
-rw-r--r--cpp/src/IcePatch/IcePatchI.cpp115
1 files changed, 54 insertions, 61 deletions
diff --git a/cpp/src/IcePatch/IcePatchI.cpp b/cpp/src/IcePatch/IcePatchI.cpp
index 19cd69e0203..5dbf5709caa 100644
--- a/cpp/src/IcePatch/IcePatchI.cpp
+++ b/cpp/src/IcePatch/IcePatchI.cpp
@@ -17,26 +17,54 @@ using namespace IcePatch;
static IceUtil::RWRecMutex globalMutex;
-IcePatch::InfoI::InfoI(const ObjectAdapterPtr& adapter) :
+IcePatch::FileI::FileI(const ObjectAdapterPtr& adapter) :
_adapter(adapter),
+ _logger(adapter->getCommunicator()->getLogger()),
+ _traceLevel(adapter->getCommunicator()->getProperties()->getPropertyAsInt("IcePatch.Trace.Files")),
_busyTimeout(IceUtil::Time::seconds(adapter->getCommunicator()->getProperties()->
getPropertyAsIntWithDefault("IcePatch.BusyTimeout", 10)))
{
}
-Long
-IcePatch::InfoI::getStamp(const Current& current) const
+ByteSeq
+IcePatch::FileI::readMD5(const Current& current) const
{
- //
- // ".icepatch" is our reserved name for the IcePatch info object,
- // as well as for the directory that contains IcePatch info.
- //
- assert(current.id.name == ".icepatch");
+ string path = identityToPath(current.id);
+ if(path == ".")
+ {
+ //
+ // We cannot create an MD5 file for the current directory.
+ //
+ return ByteSeq();
+ }
+
try
{
IceUtil::RWRecMutex::TryRLock sync(globalMutex, _busyTimeout);
- return readStamp();
+
+ FileInfo info = getFileInfo(path, true);
+ 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)
+ {
+ createMD5(path);
+
+ if(_traceLevel > 0)
+ {
+ Trace out(_logger, "IcePatch");
+ out << "created MD5 file for `" << path << "'";
+ }
+ }
+ }
+
+ return getMD5(path);
}
catch(const IceUtil::LockedException&)
{
@@ -44,15 +72,6 @@ IcePatch::InfoI::getStamp(const Current& current) const
}
}
-IcePatch::FileI::FileI(const ObjectAdapterPtr& adapter) :
- _adapter(adapter),
- _logger(adapter->getCommunicator()->getLogger()),
- _traceLevel(adapter->getCommunicator()->getProperties()->getPropertyAsInt("IcePatch.Trace.Files")),
- _busyTimeout(IceUtil::Time::seconds(adapter->getCommunicator()->getProperties()->
- getPropertyAsIntWithDefault("IcePatch.BusyTimeout", 10)))
-{
-}
-
IcePatch::DirectoryI::DirectoryI(const ObjectAdapterPtr& adapter) :
FileI(adapter)
{
@@ -63,6 +82,7 @@ IcePatch::DirectoryI::describe(const Current& current) const
{
// No mutex lock necessary.
DirectoryDescPtr desc = new DirectoryDesc;
+ desc->md5 = readMD5(current);
desc->directory = DirectoryPrx::uncheckedCast(_adapter->createProxy(current.id));
return desc;
}
@@ -79,7 +99,6 @@ IcePatch::DirectoryI::getContents(const Current& current) const
bool syncUpgraded = false;
string path = identityToPath(current.id);
StringSeq paths = readDirectory(path);
- paths.erase(remove(paths.begin(), paths.end(), ".icepatch"), paths.end());
filteredPaths.reserve(paths.size() / 3);
for(StringSeq::const_iterator p = paths.begin(); p != paths.end(); ++p)
{
@@ -95,7 +114,6 @@ IcePatch::DirectoryI::getContents(const Current& current) const
syncUpgraded = true;
}
StringSeq paths2 = readDirectory(path);
- paths2.erase(remove(paths2.begin(), paths2.end(), ".icepatch"), paths2.end());
pair<StringSeq::const_iterator, StringSeq::const_iterator> r2 =
equal_range(paths2.begin(), paths2.end(), removeSuffix(*p));
if(r2.first == r2.second)
@@ -153,42 +171,11 @@ IcePatch::RegularI::RegularI(const ObjectAdapterPtr& adapter) :
FileDescPtr
IcePatch::RegularI::describe(const Current& current) const
{
- 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)
- {
- createMD5(path);
- writeStamp(readStamp() + 1);
-
- if(_traceLevel > 0)
- {
- Trace out(_logger, "IcePatch");
- out << "created MD5 file for file `" << path << "'";
- }
- }
- }
-
- RegularDescPtr desc = new RegularDesc;
- desc->md5 = getMD5(path);
- desc->regular = RegularPrx::uncheckedCast(_adapter->createProxy(current.id));
- return desc;
- }
- catch(const IceUtil::LockedException&)
- {
- throw BusyException();
- }
+ // No mutex lock necessary.
+ RegularDescPtr desc = new RegularDesc;
+ desc->md5 = readMD5(current);
+ desc->regular = RegularPrx::uncheckedCast(_adapter->createProxy(current.id));
+ return desc;
}
Int
@@ -199,15 +186,17 @@ IcePatch::RegularI::getBZ2Size(const Current& current) const
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)
{
createBZ2(path);
@@ -243,15 +232,17 @@ IcePatch::RegularI::getBZ2(Int pos, Int num, const Current& current) const
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)
{
createBZ2(path);
@@ -259,7 +250,7 @@ IcePatch::RegularI::getBZ2(Int pos, Int num, const Current& current) const
if(_traceLevel > 0)
{
Trace out(_logger, "IcePatch");
- out << "created .bz2 file for `" << path << "'";
+ out << "created BZ2 file for `" << path << "'";
}
}
}
@@ -280,15 +271,17 @@ IcePatch::RegularI::getBZ2MD5(Int size, const Current& current) const
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)
{
createBZ2(path);
@@ -296,7 +289,7 @@ IcePatch::RegularI::getBZ2MD5(Int size, const Current& current) const
if(_traceLevel > 0)
{
Trace out(_logger, "IcePatch");
- out << "created .bz2 file for `" << path << "'";
+ out << "created BZ2 file for `" << path << "'";
}
}
}