diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2011-03-06 07:40:35 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2011-03-06 07:40:35 (GMT) |
commit | 125d5c877056db5d6487f21124064bc85283843a (patch) | |
tree | 43a6e3b6088dbd18daea21eeeef60dc68b6a68cc /Modules/_threadmodule.c | |
parent | f874debbf37636b0f2f46f8db06be50c20b670a8 (diff) | |
download | cpython-125d5c877056db5d6487f21124064bc85283843a.zip cpython-125d5c877056db5d6487f21124064bc85283843a.tar.gz cpython-125d5c877056db5d6487f21124064bc85283843a.tar.bz2 |
Issue #11408: In threading.Lock.acquire(), only call gettimeofday() when
really necessary. Patch by Charles-François Natali.
Diffstat (limited to 'Modules/_threadmodule.c')
-rw-r--r-- | Modules/_threadmodule.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/Modules/_threadmodule.c b/Modules/_threadmodule.c index 14ed55e..57d08d3 100644 --- a/Modules/_threadmodule.c +++ b/Modules/_threadmodule.c @@ -54,8 +54,8 @@ acquire_timed(PyThread_type_lock lock, PY_TIMEOUT_T microseconds) _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 @@ acquire_timed(PyThread_type_lock lock, PY_TIMEOUT_T microseconds) /* 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)); |