From 6940b244de7c5048c55fc57ada93501c1be5ab20 Mon Sep 17 00:00:00 2001 From: "Luke T. Shumaker" Date: Sun, 29 Sep 2024 12:04:57 -0600 Subject: fixes --- libcr/coroutine.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'libcr') diff --git a/libcr/coroutine.c b/libcr/coroutine.c index 79ba894..25e3e4f 100644 --- a/libcr/coroutine.c +++ b/libcr/coroutine.c @@ -421,7 +421,7 @@ static inline void _cr_transition(enum coroutine_state state) { next = next_coroutine(); if (next) break; - if (state == CR_RUNNABLE) { + if (coroutine_table[coroutine_running-1].state == CR_RUNNABLE) { debugf("cid=%zu: no other runnable coroutines, not yielding\n", coroutine_running); coroutine_table[coroutine_running-1].state = CR_RUNNING; return; @@ -473,10 +473,13 @@ void cr_unpause_from_sighandler(cid_t cid) { switch (coroutine_table[cid-1].state) { case CR_RUNNING: + debugf("... raced, deferring unpause\n"); coroutine_table[cid-1].sig_unpause = true; break; case CR_PAUSED: - coroutine_table[cid-1].state = CR_RUNNABLE; + debugf("... actual unpause\n"); + coroutine_table[cid-1].sig_unpause = false; + coroutine_table[cid-1].state = CR_RUNNABLE; break; default: assertf(false, "cid=%zu state=%s\n", -- cgit v1.2.3-2-g168b