From 4d7498213197c95be4f02bb7d75bdc3b0929e9e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Lombra=C3=B1a=20Gonz=C3=A1lez?= Date: Mon, 6 Jun 2011 10:55:01 +0000 Subject: [PATCH] Flush ProgressFile updates added. This new feature prevents from losing progress data from an unexpected reboot. svn path=/trunk/boinc/; revision=23642 --- samples/vboxwrapper/cernvm/cernvmwrapper.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/samples/vboxwrapper/cernvm/cernvmwrapper.cpp b/samples/vboxwrapper/cernvm/cernvmwrapper.cpp index 303dbdb991..859170f18f 100644 --- a/samples/vboxwrapper/cernvm/cernvmwrapper.cpp +++ b/samples/vboxwrapper/cernvm/cernvmwrapper.cpp @@ -737,6 +737,18 @@ void write_progress(time_t secs) { FILE* f = fopen(PROGRESS_FN, "w"); 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); }