[Box Backup-commit] COMMIT r2656 - box/RELEASE/0.11rc7/lib/common

subversion at boxbackup.org subversion at boxbackup.org
Mon Mar 8 21:24:07 GMT 2010


Author: chris
Date: 2010-03-08 21:24:07 +0000 (Mon, 08 Mar 2010)
New Revision: 2656

Modified:
   box/RELEASE/0.11rc7/lib/common/Test.cpp
Log:
Merge [2648] and [2651] into 0.11rc7, obsoletes [2649] and [2650].


Modified: box/RELEASE/0.11rc7/lib/common/Test.cpp
===================================================================
--- box/RELEASE/0.11rc7/lib/common/Test.cpp	2010-03-08 21:22:42 UTC (rev 2655)
+++ box/RELEASE/0.11rc7/lib/common/Test.cpp	2010-03-08 21:24:07 UTC (rev 2656)
@@ -462,10 +462,24 @@
 	ts.tv_nsec = 0;
 	while (nanosleep(&ts, &ts) == -1 && errno == EINTR)
 	{
-		BOX_TRACE("safe_sleep interrupted with " <<
-			ts.tv_sec << "." << ts.tv_nsec <<
-			" secs remaining, sleeping again");
-		/* sleep again */
+		// FIXME evil hack for OSX, where ts.tv_sec contains
+		// a negative number interpreted as unsigned 32-bit
+		// when nanosleep() returns later than expected.
+
+		int32_t secs = (int32_t) ts.tv_sec;
+		int64_t remain_ns = (secs * 1000000000) + ts.tv_nsec;
+
+		if (remain_ns < 0)
+		{
+			BOX_WARNING("nanosleep interrupted " <<
+				((float)(0 - remain_ns) / 1000000000) <<
+				" secs late");
+			return;
+		}
+
+		BOX_TRACE("nanosleep interrupted with " <<
+			(remain_ns / 1000000000) << " secs remaining, "
+			"sleeping again");
 	}
 #endif
 }




More information about the Boxbackup-commit mailing list