mirror of https://github.com/BOINC/boinc.git
state file atomicity
svn path=/trunk/boinc/; revision=9116
This commit is contained in:
parent
ba23e3be09
commit
8b78163335
|
@ -132,11 +132,13 @@ int MFILE::close() {
|
||||||
int MFILE::flush() {
|
int MFILE::flush() {
|
||||||
int n, old_len = len;
|
int n, old_len = len;
|
||||||
|
|
||||||
n = fwrite(buf, 1, len, f);
|
n = (int)fwrite(buf, 1, len, f);
|
||||||
len = 0;
|
len = 0;
|
||||||
if (n != old_len) return ERR_FWRITE;
|
if (n != old_len) return ERR_FWRITE;
|
||||||
if (fflush(f)) return ERR_FFLUSH;
|
if (fflush(f)) return ERR_FFLUSH;
|
||||||
|
#ifndef _WIN32
|
||||||
if (fsync(fileno(f)) < 0) return ERR_FSYNC;
|
if (fsync(fileno(f)) < 0) return ERR_FSYNC;
|
||||||
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue