summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2010-10-23 16:19:24 -0700
committerZac Medico <zmedico@gentoo.org>2010-10-27 07:35:46 -0700
commit0f16c786181e9cc963669496b9dc9d448ad552b1 (patch)
treef5894364ac42b115e85b1c3c0fb3571713cdbdac
parent1383371aa816f96f930b52e3685e0afe5f0e566f (diff)
downloadportage-0f16c786181e9cc963669496b9dc9d448ad552b1.tar.gz
portage-0f16c786181e9cc963669496b9dc9d448ad552b1.tar.bz2
portage-0f16c786181e9cc963669496b9dc9d448ad552b1.zip
Add sanity checks for system clock changes.
-rw-r--r--pym/_emerge/PollScheduler.py8
-rw-r--r--pym/_emerge/QueueScheduler.py16
2 files changed, 21 insertions, 3 deletions
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