From bac89be769c824c61aa44ad4bcd8f5c4fb1cff8e Mon Sep 17 00:00:00 2001 From: Rom Walton Date: Thu, 10 Apr 2014 12:12:33 -0400 Subject: [PATCH] VBOX: Only increment the elapsed time is both boinc_status.suspended is false and vm.suspended is false. VBOX: Only change the elapsed time is the stop watch elapsed time is a positive value. This is just weird (http://lhcathome2.cern.ch/test4theory/result.php?resultid=4289098): 2014-04-08 15:52:43 (6732): Status Report: Job Duration: '86400.000000' 2014-04-08 15:52:43 (6732): Status Report: Elapsed Time: '54506.443735' 2014-04-08 16:06:16 (6732): Status Report: Job Duration: '86400.000000' 2014-04-08 16:06:16 (6732): Status Report: Elapsed Time: '450358026.129327' --- samples/vboxwrapper/vboxwrapper.cpp | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/samples/vboxwrapper/vboxwrapper.cpp b/samples/vboxwrapper/vboxwrapper.cpp index 4c2f07f3d0..d44f096c86 100644 --- a/samples/vboxwrapper/vboxwrapper.cpp +++ b/samples/vboxwrapper/vboxwrapper.cpp @@ -379,14 +379,16 @@ int main(int argc, char** argv) { double checkpoint_cpu_time = 0; double last_status_report_time = 0; double last_trickle_report_time = 0; - double stopwatch_time = 0; + double stopwatch_starttime = 0; double stopwatch_endtime = 0; + double stopwatch_elapsedtime = 0; double sleep_time = 0; double bytes_sent = 0; double bytes_received = 0; double ncpus = 0; double timeout = 0.0; bool report_net_usage = false; + double net_usage_timer = 600; int vm_image = 0; unsigned long vm_exit_code = 0; string message; @@ -895,7 +897,7 @@ int main(int argc, char** argv) { while (1) { // Begin stopwatch timer - stopwatch_time = dtime(); + stopwatch_starttime = dtime(); // Discover the VM's current state vm.poll(); @@ -1154,7 +1156,6 @@ int main(int argc, char** argv) { // report network usage every 10 min so the client can enforce quota // - static double net_usage_timer=600; if (aid.global_prefs.daily_xfer_limit_mb && vm.enable_network && !vm.suspended @@ -1191,20 +1192,25 @@ int main(int argc, char** argv) { } stopwatch_endtime = dtime(); + stopwatch_elapsedtime = stopwatch_endtime - stopwatch_starttime; // Sleep for the remainder of the polling period - sleep_time = POLL_PERIOD - (stopwatch_endtime - stopwatch_time); + sleep_time = POLL_PERIOD - stopwatch_elapsedtime; if (sleep_time > 0) { boinc_sleep(sleep_time); } // Calculate the elapsed time after all potiential commands have been executed - // and base it off of wall clock time instead of a fixed interval. - if (!boinc_status.suspended) { + // and base it off of wall clock time instead of a fixed interval unless we had + // to sleep. + if (!boinc_status.suspended && !vm.suspended) { if (sleep_time > 0) { elapsed_time += POLL_PERIOD; } else { - elapsed_time += stopwatch_endtime - stopwatch_time; + if (stopwatch_elapsedtime > 0) + { + elapsed_time += stopwatch_elapsedtime; + } } } }