Skip to content

Commit dc32d18

Browse files
committed
Issue #15038 : Fixing the condition broadcast and docs.
1 parent f47e77f commit dc32d18

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

Python/condvar.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -163,10 +163,9 @@ PyCOND_TIMEDWAIT(PyCOND_T *cond, PyMUTEX_T *mut, long us)
163163
164164
Generic emulations of the pthread_cond_* API using
165165
earlier Win32 functions can be found on the Web.
166-
The following read can be edificating (or not):
166+
The following read can be give background information to these issues,
167+
but the implementations are all broken in some way.
167168
http://www.cse.wustl.edu/~schmidt/win32-cv-1.html
168-
169-
See also
170169
*/
171170

172171
typedef CRITICAL_SECTION PyMUTEX_T;
@@ -297,9 +296,10 @@ PyCOND_SIGNAL(PyCOND_T *cv)
297296
Py_LOCAL_INLINE(int)
298297
PyCOND_BROADCAST(PyCOND_T *cv)
299298
{
300-
if (cv->waiting > 0) {
301-
return ReleaseSemaphore(cv->sem, cv->waiting, NULL) ? 0 : -1;
302-
cv->waiting = 0;
299+
int waiting = cv->waiting;
300+
if (waiting > 0) {
301+
cv->waiting = 0;
302+
return ReleaseSemaphore(cv->sem, waiting, NULL) ? 0 : -1;
303303
}
304304
return 0;
305305
}

0 commit comments

Comments
 (0)