From 20ebd2d0f9216dcea4019dd85ceb107d5d80be01 Mon Sep 17 00:00:00 2001 From: Brett Simmers Date: Tue, 19 Mar 2024 14:16:55 -0700 Subject: [PATCH] Modify `_pending_calls.calls_to_do` with atomic operations --- Python/ceval_gil.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Python/ceval_gil.c b/Python/ceval_gil.c index d2cd35dfa86833e..78c13d619e6ee05 100644 --- a/Python/ceval_gil.c +++ b/Python/ceval_gil.c @@ -671,7 +671,7 @@ _push_pending_call(struct _pending_calls *pending, pending->calls[i].flags = flags; pending->last = j; assert(pending->calls_to_do < NPENDINGCALLS); - pending->calls_to_do++; + _Py_atomic_add_int32(&pending->calls_to_do, 1); return 0; } @@ -701,7 +701,7 @@ _pop_pending_call(struct _pending_calls *pending, pending->calls[i] = (struct _pending_call){0}; pending->first = (i + 1) % NPENDINGCALLS; assert(pending->calls_to_do > 0); - pending->calls_to_do--; + _Py_atomic_add_int32(&pending->calls_to_do, -1); } }