diff --git a/checkin_notes b/checkin_notes index 9cc9f78f1e..3966f6765f 100644 --- a/checkin_notes +++ b/checkin_notes @@ -3844,3 +3844,11 @@ David 29 Jun 2011 client/ client_state.h sysmon_win.cpp + +David 30 Jun 2011 + - client (Win) add some bulletproofing in case Windows sends us a + "suspending" event but not a resume event. + + client/ + client_state.cpp,h + sysmon_win.cpp diff --git a/client/client_state.cpp b/client/client_state.cpp index c744d64830..f7ae378413 100644 --- a/client/client_state.cpp +++ b/client/client_state.cpp @@ -108,6 +108,7 @@ CLIENT_STATE::CLIENT_STATE() started_by_screensaver = false; requested_exit = false; os_requested_suspend = false; + os_requested_suspend_time = 0; cleanup_completed = false; in_abort_sequence = false; master_fetch_period = MASTER_FETCH_PERIOD; @@ -264,6 +265,32 @@ double calculate_exponential_backoff(int n, double MIN, double MAX) { #ifndef SIM +void CLIENT_STATE::set_now() { + double x = dtime(); + + // if time went backward significantly, clear delays + // + if (x < (now-60)) { + clear_absolute_times(); + } + +#ifdef _WIN32 + // On Win, check for evidence that we're awake after a suspension + // (in case we missed the event announcing this) + // + if (os_requested_suspend) { + if (x > now+10) { + msg_printf(0, MSG_NORMAL, "Resuming after OS suspension"); + os_requested_suspend = false; + } else if (x > os_requested_suspend_time + 300) { + msg_printf(0, MSG_NORMAL, "Resuming after OS suspension"); + os_requested_suspend = false; + } + } +#endif + now = x; +} + int CLIENT_STATE::init() { int retval; unsigned int i; diff --git a/client/client_state.h b/client/client_state.h index cb4579a5c8..8675383441 100644 --- a/client/client_state.h +++ b/client/client_state.h @@ -121,6 +121,7 @@ struct CLIENT_STATE { // we should suspend for OS reasonts (used on Win only). // Set when // - got BATTERY_LOW, SUSPEND, SERVICE_CONTROL_PAUSE + double os_requested_suspend_time; bool cleanup_completed; bool in_abort_sequence; // Determine when it is safe to leave the quit_client() handler @@ -262,15 +263,7 @@ struct CLIENT_STATE { int nresults_for_project(PROJECT*); void check_clock_reset(); void clear_absolute_times(); - inline void set_now() { - double x = dtime(); - if (x < (now-60)) { - // if time went backward significantly, clear delays - // - clear_absolute_times(); - } - now = x; - } + void set_now(); // --------------- cpu_sched.cpp: double total_resource_share(); diff --git a/client/sysmon_win.cpp b/client/sysmon_win.cpp index 2019efe3e4..16c666ba11 100644 --- a/client/sysmon_win.cpp +++ b/client/sysmon_win.cpp @@ -59,6 +59,7 @@ static void quit_client() { // Suspend client operations static void suspend_client() { gstate.os_requested_suspend = true; + gstate.os_requested_suspend_time = dtime(); } // Resume client operations