summaryrefslogtreecommitdiff
path: root/libcr
diff options
context:
space:
mode:
authorLuke T. Shumaker <lukeshu@lukeshu.com>2024-09-29 12:04:57 -0600
committerLuke T. Shumaker <lukeshu@lukeshu.com>2024-09-29 12:04:57 -0600
commit6940b244de7c5048c55fc57ada93501c1be5ab20 (patch)
tree42734faad626d97f45fce0725031896824924701 /libcr
parent7b34cb7741c683dc623ece652032f1bf09d34140 (diff)
fixes
Diffstat (limited to 'libcr')
-rw-r--r--libcr/coroutine.c7
1 files changed, 5 insertions, 2 deletions
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",