summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorChris Wilson <chris+github@qwirx.com>2008-01-31 23:57:14 +0000
committerChris Wilson <chris+github@qwirx.com>2008-01-31 23:57:14 +0000
commitcf1eb0bed54d859b647cafae613e25022a3928d0 (patch)
treea6486ea88b40c46f52a6d8a660d3406b9bd9974e /lib
parent49796c8f1f8079aadf50d3d7095e88ed4db17e3a (diff)
Always add file size to timestamp in release mode, to help caching work
better on machines which claim to support high-res timestamps but actually don't (e.g. Linux, MacOS X). Never do so in debug mode, to help catch problems with the tests failing to sleep long enough between operations on different connections that can break caching subtly and randomly.
Diffstat (limited to 'lib')
-rw-r--r--lib/raidfile/RaidFileUtil.cpp32
1 files changed, 21 insertions, 11 deletions
diff --git a/lib/raidfile/RaidFileUtil.cpp b/lib/raidfile/RaidFileUtil.cpp
index da23cef5..583b71f2 100644
--- a/lib/raidfile/RaidFileUtil.cpp
+++ b/lib/raidfile/RaidFileUtil.cpp
@@ -22,9 +22,11 @@
// --------------------------------------------------------------------------
//
// Function
-// Name: RaidFileUtil::RaidFileExists(RaidFileDiscSet &, const std::string &)
-// Purpose: Check to see the state of a RaidFile on disc (doesn't look at contents,
-// just at existense of files)
+// Name: RaidFileUtil::RaidFileExists(RaidFileDiscSet &,
+// const std::string &, int *, int *, int64_t *)
+// Purpose: Check to see the state of a RaidFile on disc
+// (doesn't look at contents, just at existence of
+// files)
// Created: 2003/07/11
//
// --------------------------------------------------------------------------
@@ -54,10 +56,14 @@ RaidFileUtil::ExistType RaidFileUtil::RaidFileExists(RaidFileDiscSet &rDiscSet,
if(pRevisionID != 0)
{
(*pRevisionID) = FileModificationTime(st);
-#ifndef HAVE_STRUCT_STAT_ST_MTIMESPEC
- // On linux, the time resolution is very low for modification times.
- // So add the size to it to give a bit more chance of it changing.
+#ifdef NDEBUG
+ // The resolution of timestamps may be very
+ // low, e.g. 1 second. So add the size to it
+ // to give a bit more chance of it changing.
// TODO: Make this better.
+ // Disabled in debug mode, to simulate
+ // filesystem with 1-second timestamp
+ // resolution, e.g. MacOS X HFS, Linux.
(*pRevisionID) += st.st_size;
#endif
}
@@ -71,10 +77,10 @@ RaidFileUtil::ExistType RaidFileUtil::RaidFileExists(RaidFileDiscSet &rDiscSet,
int64_t revisionID = 0;
int setSize = rDiscSet.size();
int rfCount = 0;
-#ifndef HAVE_STRUCT_STAT_ST_MTIMESPEC
+
// TODO: replace this with better linux revision ID detection
int64_t revisionIDplus = 0;
-#endif
+
for(int f = 0; f < setSize; ++f)
{
std::string componentFile(RaidFileUtil::MakeRaidComponentName(rDiscSet, rFilename, (f + startDisc) % setSize));
@@ -92,16 +98,20 @@ RaidFileUtil::ExistType RaidFileUtil::RaidFileExists(RaidFileDiscSet &rDiscSet,
{
int64_t rid = FileModificationTime(st);
if(rid > revisionID) revisionID = rid;
-#ifndef HAVE_STRUCT_STAT_ST_MTIMESPEC
revisionIDplus += st.st_size;
-#endif
}
}
}
if(pRevisionID != 0)
{
(*pRevisionID) = revisionID;
-#ifndef HAVE_STRUCT_STAT_ST_MTIMESPEC
+#ifdef NDEBUG
+ // The resolution of timestamps may be very low, e.g.
+ // 1 second. So add the size to it to give a bit more
+ // chance of it changing.
+ // TODO: Make this better.
+ // Disabled in debug mode, to simulate filesystem with
+ // 1-second timestamp resolution, e.g. MacOS X HFS, Linux.
(*pRevisionID) += revisionIDplus;
#endif
}