Author: philip
Date: Tue Mar 25 12:39:00 2014
New Revision: 1581305
URL: http://svn.apache.org/r1581305
Log:
Fix a but that lead to text modifications immediately after update
not always being detected. Sleeping for 1ms is not sufficient for
some Linux filesystems that appear to have high resolution timestamps.
* subversion/libsvn_subr/io.c
(svn_io_sleep_for_timestamps): Refactor to call sleep at the
same place for all filesystems, increase sleep to 10ms for
hi-res filesystems.
Modified:
subversion/trunk/subversion/libsvn_subr/io.c
Modified: subversion/trunk/subversion/libsvn_subr/io.c
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/io.c?rev=1581305&r1=1581304&r2=1581305&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/io.c (original)
+++ subversion/trunk/subversion/libsvn_subr/io.c Tue Mar 25 12:39:00 2014
@@ -1301,32 +1301,44 @@ svn_io_sleep_for_timestamps(const char *
{
/* Very simplistic but safe approach:
If the filesystem has < sec mtime we can be reasonably sure
- that the filesystem has <= millisecond precision.
+ that the filesystem has some sub-second resolution. On Windows
+ it is likely to be sub-millisecond; on Linux systems it depends
+ on the filesystem, ext4 is typically 1ms, 4ms or 10ms resolution.
## Perhaps find a better algorithm here. This will fail once
- in every 1000 cases on a millisecond precision filesystem.
+ in every 1000 cases on a millisecond precision filesystem
+ if the mtime happens to be an exact second.
But better to fail once in every thousand cases than every
time, like we did before.
- (All tested filesystems I know have at least microsecond
precision.)
Note for further research on algorithm:
- FAT32 has < 1 sec precision on ctime, but 2 sec on mtime */
+ FAT32 has < 1 sec precision on ctime, but 2 sec on mtime.
- /* Sleep for at least 1 millisecond.
- (t < 1000 will be round to 0 in apr) */
- apr_sleep(1000);
+ Linux/ext4 with CONFIG_HZ=250 has high resolution
+ apr_time_now and although the filesystem timestamps
+ have similar high precision they are only updated with
+ a coarser 4ms resolution. */
- return;
+ /* 10 milliseconds after now. */
+#ifndef SVN_HI_RES_SLEEP_MS
+#define SVN_HI_RES_SLEEP_MS 10
+#endif
+ then = now + apr_time_from_msec(SVN_HI_RES_SLEEP_MS);
}
- now = apr_time_now(); /* Extract the time used for the path stat */
-
- if (now >= then)
- return; /* Passing negative values may suspend indefinitely (Windows)
*/
+ /* Remove time taken to do stat() from sleep. */
+ now = apr_time_now();
}
- apr_sleep(then - now);
+ if (now >= then)
+ return; /* Passing negative values may suspend indefinitely (Windows) */
+
+ /* (t < 1000 will be round to 0 in apr) */
+ if (then - now < 1000)
+ apr_sleep(1000);
+ else
+ apr_sleep(then - now);
}