[Python-checkins] cpython (merge default -> default): merge heads

georg.brandl python-checkins at python.org
Sun Mar 6 10:36:14 CET 2011


http://hg.python.org/cpython/rev/f271c94eb186
changeset:   68279:f271c94eb186
parent:      68278:0e7e3b1621da
parent:      68273:6ba9ba58499e
user:        Georg Brandl <georg at python.org>
date:        Sun Mar 06 10:36:06 2011 +0100
summary:
  merge heads

files:
  

diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -55,6 +55,9 @@
 Library
 -------
 
+- Issue #11408: In threading.Lock.acquire(), only call gettimeofday() when
+  really necessary.  Patch by Charles-François Natali.
+
 - Issue #11391: Writing to a mmap object created with
   ``mmap.PROT_READ|mmap.PROT_EXEC`` would segfault instead of raising a
   TypeError.  Patch by Charles-François Natali.
diff --git a/Modules/_threadmodule.c b/Modules/_threadmodule.c
--- a/Modules/_threadmodule.c
+++ b/Modules/_threadmodule.c
@@ -54,8 +54,8 @@
     _PyTime_timeval endtime;
 
 
-    _PyTime_gettimeofday(&endtime);
     if (microseconds > 0) {
+        _PyTime_gettimeofday(&endtime);
         endtime.tv_sec += microseconds / (1000 * 1000);
         endtime.tv_usec += microseconds % (1000 * 1000);
     }
@@ -76,7 +76,7 @@
 
             /* If we're using a timeout, recompute the timeout after processing
              * signals, since those can take time.  */
-            if (microseconds >= 0) {
+            if (microseconds > 0) {
                 _PyTime_gettimeofday(&curtime);
                 microseconds = ((endtime.tv_sec - curtime.tv_sec) * 1000000 +
                                 (endtime.tv_usec - curtime.tv_usec));

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list