Skip to content

Commit 5dd3cf3

Browse files
committed
review comments
1 parent b61696e commit 5dd3cf3

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

Include/internal/pycore_critical_section.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -196,10 +196,9 @@ _PyCriticalSection2_Begin(PyThreadState *tstate, PyCriticalSection2 *c, PyObject
196196
static inline void
197197
_PyCriticalSection2_End(PyThreadState *tstate, PyCriticalSection2 *c)
198198
{
199-
// if mutex1 is NULL, we used the fast path in
200-
// _PyCriticalSection_BeginSlow for mutexes that are already held,
201-
// which should only happen when mutex1 and mutex2 were the same mutex,
202-
// and mutex2 should also be NULL.
199+
// if mutex1 is NULL, we used the fast path in either
200+
// _PyCriticalSection_BeginSlow or _PyCriticalSection2_BeginSlow for mutexes
201+
// that are already held, and mutex2 should also be NULL.
203202
if (c->_cs_base._cs_mutex == NULL) {
204203
assert(c->_cs_mutex2 == NULL);
205204
return;

Python/critical_section.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,9 @@ _PyCriticalSection2_BeginSlow(PyThreadState *tstate, PyCriticalSection2 *c, PyMu
7878
tstate->critical_section & _Py_CRITICAL_SECTION_TWO_MUTEXES) {
7979
PyCriticalSection2 *prev2 = (PyCriticalSection2 *)
8080
untag_critical_section(tstate->critical_section);
81-
assert(m1 < m2);
82-
assert(prev2->_cs_base._cs_mutex < prev2->_cs_mutex2);
81+
assert((uintptr_t)m1 < (uintptr_t)m2);
82+
assert((uintptr_t)prev2->_cs_base._cs_mutex <
83+
(uintptr_t)prev2->_cs_mutex2);
8384
if (prev2->_cs_base._cs_mutex == m1 && prev2->_cs_mutex2 == m2) {
8485
c->_cs_base._cs_mutex = NULL;
8586
c->_cs_mutex2 = NULL;

0 commit comments

Comments
 (0)