[Box Backup-commit] COMMIT r2085 - box/trunk/lib/raidfile

boxbackup-dev at fluffy.co.uk boxbackup-dev at fluffy.co.uk
Thu Jan 31 23:57:15 GMT 2008


Author: chris
Date: 2008-01-31 23:57:14 +0000 (Thu, 31 Jan 2008)
New Revision: 2085

Modified:
   box/trunk/lib/raidfile/RaidFileUtil.cpp
Log:
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.


Modified: box/trunk/lib/raidfile/RaidFileUtil.cpp
===================================================================
--- box/trunk/lib/raidfile/RaidFileUtil.cpp	2008-01-31 23:55:37 UTC (rev 2084)
+++ box/trunk/lib/raidfile/RaidFileUtil.cpp	2008-01-31 23:57:14 UTC (rev 2085)
@@ -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 @@
 			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 @@
 	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 @@
 			{
 				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
 	}




More information about the Boxbackup-commit mailing list