Adds a two second wait to workaround the FAT limitation of two second resololution of mtime.

This commit is contained in:
Andrea Mazzoleni 2012-07-14 16:26:21 +02:00
parent 04c277f925
commit 795df4a260
3 changed files with 21 additions and 0 deletions

View file

@ -694,5 +694,10 @@ const char* windows_stat_desc(struct stat* st)
return st->st_desc;
}
void windows_sleep(unsigned seconds)
{
Sleep(seconds * 1000);
}
#endif

View file

@ -54,6 +54,7 @@
#define O_NOFOLLOW 0
#define stat_hidden windows_stat_hidden
#define stat_desc windows_stat_desc
#define sleep windows_sleep
/* In Windows symbolic links are not supported */
#define S_ISLNK(mode) 0
#define readlink(a,b,c) -1
@ -213,6 +214,11 @@ int windows_stat_hidden(struct dirent* dd, struct windows_stat* st);
*/
const char* windows_stat_desc(struct stat* st);
/**
* Like sleep().
*/
void windows_sleep(unsigned seconds);
#endif
#endif

View file

@ -307,6 +307,16 @@ int main(int argc, char* argv[])
if (state.need_write)
state_write(&state);
/* waits some time to ensure that any concurrent modification done at the files, */
/* using the same mtime read by the scan process, will be read by sync. */
/* Note that any later modification done, potentially not read by sync, will have */
/* a different mtime, and it will be syncronized at the next sync. */
/* The worst case is the FAT filesystem with a two seconds resolution for mtime. */
/* If you don't use FAT, the wait is not needed, because most filesystems have now */
/* at least microseconds resolution, but better to be safe. */
if (!test_skip_self)
sleep(2);
ret = state_sync(&state, blockstart, blockcount);
/* save the new state if required */