mirror of
https://github.com/python/cpython.git
synced 2025-08-10 03:49:18 +00:00
[3.12] gh-109593: Fix reentrancy issue in multiprocessing resource_tracker (GH-109629) (#109898)
gh-109593: Fix reentrancy issue in multiprocessing resource_tracker (GH-109629)
---------
(cherry picked from commit 0eb98837b6
)
Co-authored-by: Antoine Pitrou <antoine@python.org>
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
This commit is contained in:
parent
84f9da9ab5
commit
b723b8a13d
7 changed files with 95 additions and 2 deletions
|
@ -486,6 +486,18 @@ PyDoc_STRVAR(rlock_release_save_doc,
|
|||
\n\
|
||||
For internal use by `threading.Condition`.");
|
||||
|
||||
static PyObject *
|
||||
rlock_recursion_count(rlockobject *self, PyObject *Py_UNUSED(ignored))
|
||||
{
|
||||
unsigned long tid = PyThread_get_thread_ident();
|
||||
return PyLong_FromUnsignedLong(
|
||||
self->rlock_owner == tid ? self->rlock_count : 0UL);
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(rlock_recursion_count_doc,
|
||||
"_recursion_count() -> int\n\
|
||||
\n\
|
||||
For internal use by reentrancy checks.");
|
||||
|
||||
static PyObject *
|
||||
rlock_is_owned(rlockobject *self, PyObject *Py_UNUSED(ignored))
|
||||
|
@ -561,6 +573,8 @@ static PyMethodDef rlock_methods[] = {
|
|||
METH_VARARGS, rlock_acquire_restore_doc},
|
||||
{"_release_save", (PyCFunction)rlock_release_save,
|
||||
METH_NOARGS, rlock_release_save_doc},
|
||||
{"_recursion_count", (PyCFunction)rlock_recursion_count,
|
||||
METH_NOARGS, rlock_recursion_count_doc},
|
||||
{"__enter__", _PyCFunction_CAST(rlock_acquire),
|
||||
METH_VARARGS | METH_KEYWORDS, rlock_acquire_doc},
|
||||
{"__exit__", (PyCFunction)rlock_release,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue