mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
bpo-43962: Fix _PyInterpreterState_IDIncref() (GH-25683)
_PyInterpreterState_IDIncref() now calls _PyInterpreterState_IDInitref() and always increments id_refcount.
This commit is contained in:
parent
21b02b5f40
commit
32c5a17444
4 changed files with 22 additions and 10 deletions
|
@ -538,24 +538,25 @@ _PyInterpreterState_IDInitref(PyInterpreterState *interp)
|
|||
}
|
||||
|
||||
|
||||
void
|
||||
int
|
||||
_PyInterpreterState_IDIncref(PyInterpreterState *interp)
|
||||
{
|
||||
if (interp->id_mutex == NULL) {
|
||||
return;
|
||||
if (_PyInterpreterState_IDInitref(interp) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
PyThread_acquire_lock(interp->id_mutex, WAIT_LOCK);
|
||||
interp->id_refcount += 1;
|
||||
PyThread_release_lock(interp->id_mutex);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
_PyInterpreterState_IDDecref(PyInterpreterState *interp)
|
||||
{
|
||||
if (interp->id_mutex == NULL) {
|
||||
return;
|
||||
}
|
||||
assert(interp->id_mutex != NULL);
|
||||
|
||||
struct _gilstate_runtime_state *gilstate = &_PyRuntime.gilstate;
|
||||
PyThread_acquire_lock(interp->id_mutex, WAIT_LOCK);
|
||||
assert(interp->id_refcount != 0);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue