]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-33316: PyThread_release_lock always fails (GH-6541)
authornative-api <ivan_pozdeev@mail.ru>
Sat, 2 Feb 2019 16:22:55 +0000 (19:22 +0300)
committerSteve Dower <steve.dower@microsoft.com>
Sat, 2 Feb 2019 16:22:55 +0000 (08:22 -0800)
Use correct interpretation of return value from APIs.

Misc/NEWS.d/next/Windows/2018-04-20-03-24-07.bpo-33316.9IiJ8J.rst [new file with mode: 0644]
Python/thread_nt.h

diff --git a/Misc/NEWS.d/next/Windows/2018-04-20-03-24-07.bpo-33316.9IiJ8J.rst b/Misc/NEWS.d/next/Windows/2018-04-20-03-24-07.bpo-33316.9IiJ8J.rst
new file mode 100644 (file)
index 0000000..5517679
--- /dev/null
@@ -0,0 +1 @@
+PyThread_release_lock always fails
index 21ef5556a6bc535f13c2b796d277bf4909b944e4..fdb192b7d77a1604677219a911534cfbbaf598e8 100644 (file)
@@ -104,8 +104,9 @@ LeaveNonRecursiveMutex(PNRMUTEX mutex)
     if (PyMUTEX_LOCK(&mutex->cs))
         return FALSE;
     mutex->locked = 0;
-    result = PyCOND_SIGNAL(&mutex->cv);
-    result &= PyMUTEX_UNLOCK(&mutex->cs);
+    /* condvar APIs return 0 on success. We need to return TRUE on success. */
+    result = !PyCOND_SIGNAL(&mutex->cv);
+    PyMUTEX_UNLOCK(&mutex->cs);
     return result;
 }