diff --git a/checkin_notes b/checkin_notes index c6eb650583..aaaeb36072 100644 --- a/checkin_notes +++ b/checkin_notes @@ -4478,3 +4478,20 @@ Rom May 28 2008 (HEAD) configure.ac version.h +David May 28 2008 + - client: on startup, detect when the system clock has been set backwards, + and clear all timeout variables. + This should fix the situation where, say: + 1) the user sets the system clock forward by a year; + 2) all projects get their min_rpc_time set; + 3) the user sets the system clock back to the correct time. + Previously, BOINC would not do anything for a year. + + Note: a restart of BOINC is required to fix things. + It would be harder to do this on the fly. + + client/ + client_state.C,h + client_types.h + pers_file_xfer.h + time_stats.h diff --git a/client/client_state.C b/client/client_state.C index fcf84196e1..2fb57295a9 100644 --- a/client/client_state.C +++ b/client/client_state.C @@ -245,6 +245,8 @@ int CLIENT_STATE::init() { set_ncpus(); show_host_info(); + check_clock_reset(); + coprocs.get(); #if 0 fake_cuda(coprocs); @@ -1573,4 +1575,38 @@ double calculate_exponential_backoff( int n, double MIN, double MAX) { return rand_range(MIN, rmax); } +// See if a timestamp in the client state file +// is later than the current time. +// If so, the user must have decremented the system clock. +// Clear all timeout variables. +// +void CLIENT_STATE::check_clock_reset() { + now = time(0); + if (!time_stats.last_update) return; + if (time_stats.last_update <= now) return; + + msg_printf(NULL, MSG_INFO, + "System clock was turned backwards; clearing timeouts" + ); + new_version_check_time = now; + all_projects_list_check_time = now; + + unsigned int i; + for (i=0; imin_rpc_time = 0; + if (p->next_rpc_time) { + p->next_rpc_time = now; + } + p->next_file_xfer_up = 0; + p->next_file_xfer_down = 0; + } + for (i=0; ipers_file_xfers.size(); i++) { + PERS_FILE_XFER* pfx = pers_file_xfers->pers_file_xfers[i]; + pfx->next_request_time = 0; + } + + // RESULT: could change report_deadline, but not clear how +} + const char *BOINC_RCSID_e836980ee1 = "$Id$"; diff --git a/client/client_state.h b/client/client_state.h index dc707d1c0c..81daaa680f 100644 --- a/client/client_state.h +++ b/client/client_state.h @@ -241,6 +241,7 @@ private: bool garbage_collect_always(); bool update_results(); int nresults_for_project(PROJECT*); + void check_clock_reset(); // --------------- cpu_sched.C: private: diff --git a/client/client_types.h b/client/client_types.h index 1a4b551786..aa8cd88554 100644 --- a/client/client_types.h +++ b/client/client_types.h @@ -408,13 +408,11 @@ public: // Also, none of this is used right now (commented out) // #define FILE_XFER_FAILURE_LIMIT 3 -private: int file_xfer_failures_up; int file_xfer_failures_down; double next_file_xfer_up; double next_file_xfer_down; -public: double next_file_xfer_time(const bool); void file_xfer_failed(const bool); void file_xfer_succeeded(const bool); diff --git a/client/pers_file_xfer.h b/client/pers_file_xfer.h index 62d872d430..7526db6343 100644 --- a/client/pers_file_xfer.h +++ b/client/pers_file_xfer.h @@ -116,8 +116,8 @@ public: }; class PERS_FILE_XFER_SET { - FILE_XFER_SET* file_xfers; public: + FILE_XFER_SET* file_xfers; std::vectorpers_file_xfers; PERS_FILE_XFER_SET(FILE_XFER_SET*); diff --git a/client/time_stats.h b/client/time_stats.h index 06f49c6747..74a2cc81c7 100644 --- a/client/time_stats.h +++ b/client/time_stats.h @@ -24,10 +24,10 @@ #include class TIME_STATS { - double last_update; bool first; int previous_connected_state; public: + double last_update; // we maintain an exponentially weighted average of these quantities: double on_frac; // the fraction of total time this host runs the core client