8000 gh-120321: Lock gen_send by Fidget-Spinner · Pull Request #120327 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-120321: Lock gen_send #120327

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 6 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
8000
Diff view
Diff view
Next Next commit
Lock gen_send
  • Loading branch information
Fidget-Spinner committed Jun 10, 2024
commit 4f083224b54db75b4afd33ee7647bd81d17e1db6
14 changes: 13 additions & 1 deletion Objects/genobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "pycore_pyatomic_ft_wrappers.h" // FT_ATOMIC_*
#include "pycore_pyerrors.h" // _PyErr_ClearExcState()
#include "pycore_pystate.h" // _PyThreadState_GET()
#include "pycore_critical_section.h"

#include "pystats.h"

Expand Down Expand Up @@ -159,7 +160,7 @@ gen_dealloc(PyGenObject *gen)
}

static PySendResult
gen_send_ex2(PyGenObject *gen, PyObject *arg, PyObject **presult,
gen_send_ex2_unlocked(PyGenObject *gen, PyObject *arg, PyObject **presult,
int exc, int closing)
{
PyThreadState *tstate = _PyThreadState_GET();
Expand Down Expand Up @@ -257,6 +258,17 @@ gen_send_ex2(PyGenObject *gen, PyObject *arg, PyObject **presult,
return result ? PYGEN_RETURN : PYGEN_ERROR;
}

static PySendResult
gen_send_ex2(PyGenObject *gen, PyObject *arg, PyObject **presult,
int exc, int closing)
{
PySendResult res;
Py_BEGIN_CRITICAL_SECTION(gen);
res = gen_send_ex2_unlocked(gen, arg, presult, exc, closing);
Py_END_CRITICAL_SECTION();
return res;
}

static PySendResult
PyGen_am_send(PyGenObject *gen, PyObject *arg, PyObject **result)
{
Expand Down
0