diff --git a/checkin_notes b/checkin_notes index e4068eb9e7..b13a10d7cd 100644 --- a/checkin_notes +++ b/checkin_notes @@ -4703,3 +4703,19 @@ Charlie 3 July 2012 mac_build/ boinc.xcodeproj/ project.pbxproj + +David 3 July 2012 + - Client (Win): in file_size(), use _stat64() instead of stat(). + Otherwise it doesn't work for files >= 2GB + - Client: TIME_STATS::trim_stats_log() wasn't working because + it's called in the constructor of TIME_STATS, + which is called before we've done a chdir() to the data dir. + + Note: for this reason, no disk access should be done in constructors + of global objects. A quick scan found no instances of this. + + client/ + client_state.cpp + time_stats.cpp,h + lib/ + filesys.cpp diff --git a/client/client_state.cpp b/client/client_state.cpp index 4f84d12d09..cdb34f746b 100644 --- a/client/client_state.cpp +++ b/client/client_state.cpp @@ -304,6 +304,7 @@ int CLIENT_STATE::init() { notices.init(); daily_xfer_history.init(); + time_stats.init(); detect_platforms(); time_stats.start(); diff --git a/client/time_stats.cpp b/client/time_stats.cpp index 94d910c0e9..9ccf8cff15 100644 --- a/client/time_stats.cpp +++ b/client/time_stats.cpp @@ -76,7 +76,7 @@ int get_connected_state() { const float ALPHA = (SECONDS_PER_DAY*10); //const float ALPHA = 60; // for testing -TIME_STATS::TIME_STATS() { +void TIME_STATS::init() { last_update = 0; first = true; on_frac = 1; diff --git a/client/time_stats.h b/client/time_stats.h index 4e21058998..9abc4d3bbe 100644 --- a/client/time_stats.h +++ b/client/time_stats.h @@ -21,10 +21,10 @@ #include "miofile.h" #include -class TIME_STATS { +struct TIME_STATS { bool first; int previous_connected_state; -public: + double last_update; // we maintain an exponentially weighted average of these quantities: double on_frac; @@ -50,7 +50,7 @@ public: void update(int suspend_reason, int gpu_suspend_reason); - TIME_STATS(); + void init(); int write(MIOFILE&, bool to_server); int parse(XML_PARSER&); diff --git a/lib/filesys.cpp b/lib/filesys.cpp index d9686ce691..a27c20793c 100644 --- a/lib/filesys.cpp +++ b/lib/filesys.cpp @@ -324,10 +324,15 @@ int boinc_delete_file(const char* path) { // get file size // int file_size(const char* path, double& size) { - struct stat sbuf; int retval; +#if defined(_WIN32) && !defined(__CYGWIN32__) + struct __stat64 sbuf; + retval = _stat64(path, &sbuf); +#else + struct stat sbuf; retval = stat(path, &sbuf); +#endif if (retval) return ERR_NOT_FOUND; size = (double)sbuf.st_size; return 0; @@ -335,7 +340,7 @@ int file_size(const char* path, double& size) { int boinc_truncate(const char* path, double size) { int retval; -#if defined(_WIN32) && !defined(__CYGWIN32__) +#if defined(_WIN32) && !defined(__CYGWIN32__) // the usual Windows nightmare. // There's another function, SetEndOfFile(), // that supposedly works with files over 2GB,