summaryrefslogtreecommitdiffstats
path: root/Python/thread_nt.h
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2022-05-10 00:00:38 (GMT)
committerGitHub <noreply@github.com>2022-05-10 00:00:38 (GMT)
commitcb35402c1867b48704c2de1d1efd465ca738f374 (patch)
treeb1fa60fb79ec9fdea111a938a15f3066d3853a94 /Python/thread_nt.h
parent6ed7c353b8ded48a9128413f35921ddc4e5b1065 (diff)
downloadcpython-cb35402c1867b48704c2de1d1efd465ca738f374.zip
cpython-cb35402c1867b48704c2de1d1efd465ca738f374.tar.gz
cpython-cb35402c1867b48704c2de1d1efd465ca738f374.tar.bz2
gh-88750: On Windows, PyThread_acquire_lock() no longer checks for NULL (#92586)
On Windows, PyThread_acquire_lock(), PyThread_acquire_lock_timed() and PyThread_release_lock() no longer check at runtime if the lock is not NULL.
Diffstat (limited to 'Python/thread_nt.h')
-rw-r--r--Python/thread_nt.h20
1 files changed, 12 insertions, 8 deletions
diff --git a/Python/thread_nt.h b/Python/thread_nt.h
index b1defad..d1f1323 100644
--- a/Python/thread_nt.h
+++ b/Python/thread_nt.h
@@ -264,14 +264,17 @@ PyThread_exit_thread(void)
PyThread_type_lock
PyThread_allocate_lock(void)
{
- PNRMUTEX aLock;
+ PNRMUTEX mutex;
if (!initialized)
PyThread_init_thread();
- aLock = AllocNonRecursiveMutex() ;
+ mutex = AllocNonRecursiveMutex() ;
- return (PyThread_type_lock) aLock;
+ PyThread_type_lock aLock = (PyThread_type_lock) mutex;
+ assert(aLock);
+
+ return aLock;
}
void
@@ -295,6 +298,8 @@ PyLockStatus
PyThread_acquire_lock_timed(PyThread_type_lock aLock,
PY_TIMEOUT_T microseconds, int intr_flag)
{
+ assert(aLock);
+
/* Fow now, intr_flag does nothing on Windows, and lock acquires are
* uninterruptible. */
PyLockStatus success;
@@ -321,8 +326,8 @@ PyThread_acquire_lock_timed(PyThread_type_lock aLock,
milliseconds = INFINITE;
}
- if (aLock && EnterNonRecursiveMutex((PNRMUTEX)aLock,
- (DWORD)milliseconds) == WAIT_OBJECT_0) {
+ if (EnterNonRecursiveMutex((PNRMUTEX)aLock,
+ (DWORD)milliseconds) == WAIT_OBJECT_0) {
success = PY_LOCK_ACQUIRED;
}
else {
@@ -340,9 +345,8 @@ PyThread_acquire_lock(PyThread_type_lock aLock, int waitflag)
void
PyThread_release_lock(PyThread_type_lock aLock)
{
- if (aLock) {
- (void)LeaveNonRecursiveMutex((PNRMUTEX) aLock);
- }
+ assert(aLock);
+ (void)LeaveNonRecursiveMutex((PNRMUTEX) aLock);
}
/* minimum/maximum thread stack sizes supported */