From 413b747225f15fe8574d07ba696435d25767d603 Mon Sep 17 00:00:00 2001
From: Michael Hanselmann <hansmi@google.com>
Date: Wed, 10 Feb 2010 13:45:52 +0100
Subject: [PATCH] Fix locking bug causing high CPU usage

Iustin Pop noticed unusually high CPU usage with 2.1's master
daemon, even with very simple opcodes like OP_TEST_DELAY. As
it turns out, we inadvertently passed seconds as milliseconds
to a call to poll(2). Due to the way the loop around the call
works it didn't break competely, but caused higher CPU usage
by the poll(2) call returning too early.

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>
---
 lib/locking.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lib/locking.py b/lib/locking.py
index f30e8b703..3f30c06b9 100644
--- a/lib/locking.py
+++ b/lib/locking.py
@@ -145,7 +145,8 @@ class _SingleNotifyPipeConditionWaiter(object):
         break
 
       try:
-        result = self._poller.poll(remaining_time)
+        # Our calculation uses seconds, poll() wants milliseconds
+        result = self._poller.poll(1000 * remaining_time)
       except EnvironmentError, err:
         if err.errno != errno.EINTR:
           raise
-- 
GitLab