mirror of
https://github.com/janet-lang/janet
synced 2024-11-24 17:27:18 +00:00
Address #1405 - don't try and resume fibers that can't be resumed.
FOr fibers that _can_ be resumed and then get cancelled, the sched_id will be incremented later prevent the spurious wake ups.
This commit is contained in:
parent
e66dc14b3a
commit
c9897f99c3
@ -1166,6 +1166,7 @@ JANET_CORE_FN(cfun_channel_close,
|
|||||||
msg.argj = janet_wrap_nil();
|
msg.argj = janet_wrap_nil();
|
||||||
janet_ev_post_event(vm, janet_thread_chan_cb, msg);
|
janet_ev_post_event(vm, janet_thread_chan_cb, msg);
|
||||||
} else {
|
} else {
|
||||||
|
if (janet_fiber_can_resume(writer.fiber)) {
|
||||||
if (writer.mode == JANET_CP_MODE_CHOICE_WRITE) {
|
if (writer.mode == JANET_CP_MODE_CHOICE_WRITE) {
|
||||||
janet_schedule(writer.fiber, make_close_result(channel));
|
janet_schedule(writer.fiber, make_close_result(channel));
|
||||||
} else {
|
} else {
|
||||||
@ -1173,6 +1174,7 @@ JANET_CORE_FN(cfun_channel_close,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
JanetChannelPending reader;
|
JanetChannelPending reader;
|
||||||
while (!janet_q_pop(&channel->read_pending, &reader, sizeof(reader))) {
|
while (!janet_q_pop(&channel->read_pending, &reader, sizeof(reader))) {
|
||||||
if (reader.thread != &janet_vm) {
|
if (reader.thread != &janet_vm) {
|
||||||
@ -1185,6 +1187,7 @@ JANET_CORE_FN(cfun_channel_close,
|
|||||||
msg.argj = janet_wrap_nil();
|
msg.argj = janet_wrap_nil();
|
||||||
janet_ev_post_event(vm, janet_thread_chan_cb, msg);
|
janet_ev_post_event(vm, janet_thread_chan_cb, msg);
|
||||||
} else {
|
} else {
|
||||||
|
if (janet_fiber_can_resume(reader.fiber)) {
|
||||||
if (reader.mode == JANET_CP_MODE_CHOICE_READ) {
|
if (reader.mode == JANET_CP_MODE_CHOICE_READ) {
|
||||||
janet_schedule(reader.fiber, make_close_result(channel));
|
janet_schedule(reader.fiber, make_close_result(channel));
|
||||||
} else {
|
} else {
|
||||||
@ -1193,6 +1196,7 @@ JANET_CORE_FN(cfun_channel_close,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
janet_chan_unlock(channel);
|
janet_chan_unlock(channel);
|
||||||
return argv[0];
|
return argv[0];
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user