Remove slow sync() call for NFS flushing.

This commit is contained in:
Wilson Snyder
2013-02-04 21:21:55 -05:00
parent 936855c81c
commit 238fc24684
3 changed files with 15 additions and 3 deletions
+12
View File
@@ -28,6 +28,7 @@
#include <cctype>
#include <dirent.h>
#include <unistd.h>
#include <fcntl.h>
#include <set>
#include <list>
#include <map>
@@ -277,6 +278,17 @@ bool V3Options::fileStatNormal(const string& filename) {
return true;
}
void V3Options::fileNfsFlush(const string& filename) {
// NFS caches stat() calls so to get up-to-date information must
// do a open or opendir on the filename.
// Faster to just try both rather than check if a file is a dir.
if (DIR* dirp = opendir(filename.c_str())) {
closedir(dirp);
} else if (int fd = ::open(filename.c_str(), O_RDONLY)) {
if (fd>0) ::close(fd);
}
}
string V3Options::fileExists (const string& filename) {
// Surprisingly, for VCS and other simulators, this process
// is quite slow; presumably because of re-reading each directory