From: Zac Medico Date: Sat, 23 Oct 2010 23:19:24 +0000 (-0700) Subject: Add sanity checks for system clock changes. X-Git-Tag: v2.2.0_alpha2~18 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=12b0f1432ae538738a81aa35458b491b4f6eff80;p=portage.git Add sanity checks for system clock changes. --- diff --git a/pym/_emerge/PollScheduler.py b/pym/_emerge/PollScheduler.py index 68826e28e..e71350e5b 100644 --- a/pym/_emerge/PollScheduler.py +++ b/pym/_emerge/PollScheduler.py @@ -235,7 +235,13 @@ class PollScheduler(object): break if timeout is not None: elapsed_time = time.time() - start_time - remaining_timeout = (timeout - 1000 * elapsed_time) + if elapsed_time < 0: + # The system clock has changed such that start_time + # is now in the future, so just assume that the + # timeout has already elapsed. + timed_out = True + break + remaining_timeout = timeout - 1000 * elapsed_time if remaining_timeout <= 0: timed_out = True break diff --git a/pym/_emerge/QueueScheduler.py b/pym/_emerge/QueueScheduler.py index 1379ffc6f..8a7ea300a 100644 --- a/pym/_emerge/QueueScheduler.py +++ b/pym/_emerge/QueueScheduler.py @@ -46,7 +46,13 @@ class QueueScheduler(PollScheduler): self._schedule_wait(timeout=remaining_timeout) if timeout is not None: elapsed_time = time.time() - start_time - remaining_timeout = (timeout - 1000 * elapsed_time) + if elapsed_time < 0: + # The system clock has changed such that start_time + # is now in the future, so just assume that the + # timeout has already elapsed. + timed_out = True + break + remaining_timeout = timeout - 1000 * elapsed_time if remaining_timeout <= 0: timed_out = True break @@ -56,7 +62,13 @@ class QueueScheduler(PollScheduler): self._schedule_wait(timeout=remaining_timeout) if timeout is not None: elapsed_time = time.time() - start_time - remaining_timeout = (timeout - 1000 * elapsed_time) + if elapsed_time < 0: + # The system clock has changed such that start_time + # is now in the future, so just assume that the + # timeout has already elapsed. + timed_out = True + break + remaining_timeout = timeout - 1000 * elapsed_time if remaining_timeout <= 0: timed_out = True break