save/restore coro_running in pygather_op_dealloc().

This commit is contained in:
Joris Vink 2018-10-30 12:37:30 +01:00
parent 062c80c1ac
commit 5456f2e1d5
1 changed files with 11 additions and 0 deletions

View File

@ -2402,9 +2402,18 @@ pygather_reap_coro(struct pygather_op *op, struct python_coro *reap)
static void
pygather_op_dealloc(struct pygather_op *op)
{
struct python_coro *old;
struct pygather_coro *coro, *next;
struct pygather_result *res, *rnext;
/*
* Since we are calling kore_python_coro_delete() on all the
* remaining coroutines in this gather op we must remember the
* original coroutine that is running as the removal will end
* up setting coro_running to NULL.
*/
old = coro_running;
for (coro = TAILQ_FIRST(&op->coroutines); coro != NULL; coro = next) {
next = TAILQ_NEXT(coro, list);
TAILQ_REMOVE(&op->coroutines, coro, list);
@ -2416,6 +2425,8 @@ pygather_op_dealloc(struct pygather_op *op)
kore_pool_put(&gather_coro_pool, coro);
}
coro_running = old;
for (res = TAILQ_FIRST(&op->results); res != NULL; res = rnext) {
rnext = TAILQ_NEXT(res, list);
TAILQ_REMOVE(&op->results, res, list);