summaryrefslogtreecommitdiffstats
path: root/Python/thread_nt.h
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2010-12-15 22:59:16 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2010-12-15 22:59:16 (GMT)
commit810023db3e91c18f428e27378d00c3a5a56330c6 (patch)
tree98b7710d8855ccbed5d84e6d64ff617fe7e53570 /Python/thread_nt.h
parent119cda0fd25561c2a21212c80f211af966104297 (diff)
downloadcpython-810023db3e91c18f428e27378d00c3a5a56330c6.zip
cpython-810023db3e91c18f428e27378d00c3a5a56330c6.tar.gz
cpython-810023db3e91c18f428e27378d00c3a5a56330c6.tar.bz2
Issue #8844: Regular and recursive lock acquisitions can now be interrupted
by signals on platforms using pthreads. Patch by Reid Kleckner.
Diffstat (limited to 'Python/thread_nt.h')
-rw-r--r--Python/thread_nt.h19
1 files changed, 14 insertions, 5 deletions
diff --git a/Python/thread_nt.h b/Python/thread_nt.h
index 9de9e0d..684b545 100644
--- a/Python/thread_nt.h
+++ b/Python/thread_nt.h
@@ -238,10 +238,13 @@ PyThread_free_lock(PyThread_type_lock aLock)
* and 0 if the lock was not acquired. This means a 0 is returned
* if the lock has already been acquired by this thread!
*/
-int
-PyThread_acquire_lock_timed(PyThread_type_lock aLock, PY_TIMEOUT_T microseconds)
+PyLockStatus
+PyThread_acquire_lock_timed(PyThread_type_lock aLock,
+ PY_TIMEOUT_T microseconds, int intr_flag)
{
- int success ;
+ /* Fow now, intr_flag does nothing on Windows, and lock acquires are
+ * uninterruptible. */
+ PyLockStatus success;
PY_TIMEOUT_T milliseconds;
if (microseconds >= 0) {
@@ -258,7 +261,13 @@ PyThread_acquire_lock_timed(PyThread_type_lock aLock, PY_TIMEOUT_T microseconds)
dprintf(("%ld: PyThread_acquire_lock_timed(%p, %lld) called\n",
PyThread_get_thread_ident(), aLock, microseconds));
- success = aLock && EnterNonRecursiveMutex((PNRMUTEX) aLock, (DWORD) milliseconds) == WAIT_OBJECT_0 ;
+ if (aLock && EnterNonRecursiveMutex((PNRMUTEX)aLock,
+ (DWORD)milliseconds) == WAIT_OBJECT_0) {
+ success = PY_LOCK_ACQUIRED;
+ }
+ else {
+ success = PY_LOCK_FAILURE;
+ }
dprintf(("%ld: PyThread_acquire_lock(%p, %lld) -> %d\n",
PyThread_get_thread_ident(), aLock, microseconds, success));
@@ -268,7 +277,7 @@ PyThread_acquire_lock_timed(PyThread_type_lock aLock, PY_TIMEOUT_T microseconds)
int
PyThread_acquire_lock(PyThread_type_lock aLock, int waitflag)
{
- return PyThread_acquire_lock_timed(aLock, waitflag ? -1 : 0);
+ return PyThread_acquire_lock_timed(aLock, waitflag ? -1 : 0, 0);
}
void