Flush ProgressFile updates added.

This new feature prevents from losing progress data from an unexpected reboot.


svn path=/trunk/boinc/; revision=23642
This commit is contained in:
Daniel Lombraña González 2011-06-06 10:55:01 +00:00
parent 7932dde4d7
commit 4d74982131
1 changed files with 12 additions and 0 deletions

View File

@ -737,6 +737,18 @@ void write_progress(time_t secs)
{ {
FILE* f = fopen(PROGRESS_FN, "w"); FILE* f = fopen(PROGRESS_FN, "w");
fprintf(f,"%ld\n", secs); fprintf(f,"%ld\n", secs);
//Flushing progress file after 5 minutes for not losing work
if ((int)boinc_elapsed_time() % (5*60) == 0)
{
#ifdef _WIN32
fprintf(stderr,"INFO: Flushing buffers after 5 minutes!\n");
fflush(f);
_commit(_fileno(f));
#else
fprintf(stderr,"INFO: Flushing buffers after 5 minutes!\n");
fsync(fileno(f));
#endif
}
fclose(f); fclose(f);
} }