mirror of
https://github.com/jorisvink/kore
synced 2025-03-09 20:49:01 -04:00
Make sure we wakeup the coroutine that called proc.reap().
We actually woke up the coroutine that originally spawned the process when we reap it, but another coroutine may have taken over the object. This mimics how we do things for the pysock_op things.
This commit is contained in:
parent
ebee0f3752
commit
7b5046873a
@ -518,6 +518,7 @@ struct pyproc {
|
||||
pid_t apid;
|
||||
int reaped;
|
||||
int status;
|
||||
struct pyproc_op *op;
|
||||
struct pysocket *in;
|
||||
struct pysocket *out;
|
||||
struct python_coro *coro;
|
||||
@ -563,6 +564,7 @@ static PyTypeObject pyproc_type = {
|
||||
struct pyproc_op {
|
||||
PyObject_HEAD
|
||||
struct pyproc *proc;
|
||||
struct python_coro *coro;
|
||||
};
|
||||
|
||||
static void pyproc_op_dealloc(struct pyproc_op *);
|
||||
|
27
src/python.c
27
src/python.c
@ -472,6 +472,7 @@ void
|
||||
kore_python_proc_reap(void)
|
||||
{
|
||||
struct pyproc *proc;
|
||||
struct python_coro *coro;
|
||||
pid_t child;
|
||||
int status;
|
||||
|
||||
@ -507,10 +508,20 @@ kore_python_proc_reap(void)
|
||||
proc->timer = NULL;
|
||||
}
|
||||
|
||||
if (proc->coro->request != NULL)
|
||||
http_request_wakeup(proc->coro->request);
|
||||
/*
|
||||
* If someone is waiting on proc.reap() then wakeup that
|
||||
* coroutine, otherwise wakeup the coroutine that created
|
||||
* the process.
|
||||
*/
|
||||
if (proc->op != NULL)
|
||||
coro = proc->op->coro;
|
||||
else
|
||||
python_coro_wakeup(proc->coro);
|
||||
coro = proc->coro;
|
||||
|
||||
if (coro->request != NULL)
|
||||
http_request_wakeup(coro->request);
|
||||
else
|
||||
python_coro_wakeup(coro);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2289,6 +2300,7 @@ python_kore_proc(PyObject *self, PyObject *args)
|
||||
}
|
||||
|
||||
proc->pid = -1;
|
||||
proc->op = NULL;
|
||||
proc->apid = -1;
|
||||
proc->reaped = 0;
|
||||
proc->status = 0;
|
||||
@ -3721,6 +3733,12 @@ pyproc_reap(struct pyproc *proc, PyObject *args)
|
||||
{
|
||||
struct pyproc_op *op;
|
||||
|
||||
if (proc->op != NULL) {
|
||||
PyErr_Format(PyExc_RuntimeError,
|
||||
"process %d already being reaped", proc->apid);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
if (proc->timer != NULL) {
|
||||
kore_timer_remove(proc->timer);
|
||||
proc->timer = NULL;
|
||||
@ -3730,6 +3748,9 @@ pyproc_reap(struct pyproc *proc, PyObject *args)
|
||||
return (NULL);
|
||||
|
||||
op->proc = proc;
|
||||
op->coro = coro_running;
|
||||
|
||||
proc->op = op;
|
||||
|
||||
Py_INCREF((PyObject *)proc);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user