kore

Kore is a web application platform for writing scalable, concurrent web based processes in C or Python.
Commits | Files | Refs | README | LICENSE | git clone https://git.kore.io/kore.git

commit 68d078766e1d4981c9e566ee73459d91cd9b47ad
parent 08d66e39267527671e07423fb3cef4305aafa207
Author: Joris Vink <joris@coders.se>
Date:   Mon, 10 Aug 2020 12:19:42 +0200

Clear lockop before removing a reference from the coroutine.

Diffstat:
src/python.c | 12++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/src/python.c b/src/python.c @@ -417,8 +417,6 @@ kore_python_coro_delete(void *obj) python_coro_trace(coro->killed ? "killed" : "deleted", coro); coro_running = coro; - Py_DECREF(coro->obj); - coro_running = NULL; if (coro->lockop != NULL) { coro->lockop->active = 0; @@ -427,6 +425,9 @@ kore_python_coro_delete(void *obj) coro->lockop = NULL; } + Py_DECREF(coro->obj); + coro_running = NULL; + if (coro->state == CORO_STATE_RUNNABLE) TAILQ_REMOVE(&coro_runnable, coro, list); else @@ -1809,6 +1810,12 @@ python_kore_task_kill(PyObject *self, PyObject *args) if (!PyArg_ParseTuple(args, "I", &id)) return (NULL); + if (coro_running->id == id) { + PyErr_SetString(PyExc_RuntimeError, + "refusing to kill active coroutine"); + return (NULL); + } + /* Remember active coro, as delete sets coro_running to NULL. */ active = coro_running; @@ -3762,6 +3769,7 @@ pylock_op_iternext(struct pylock_op *op) */ if (op->active == 0) { op->active = 1; + op->coro->lockop = op; TAILQ_INSERT_HEAD(&op->lock->ops, op, list); Py_INCREF((PyObject *)op); }