Skip to content

Commit d36d080

Browse files
fix: put preempted Syscall(Executing) coroutines back in ready queue instead of syscall map
When SIGURG preempts a coroutine in Syscall(Executing) state (due to a race between the monitor sending SIGURG and MonitorListener removing the notify node), the scheduler was putting it in the syscall map without a syscall_suspend entry. This caused the coroutine to get stuck forever — no mechanism moves Syscall(Executing) coroutines from the syscall map back to the ready queue. Fix: detect Syscall(Executing) yields as preemption events and push the coroutine back to the ready queue. resume_with() already accepts Syscall(Executing) → Running transitions, so the coroutine resumes correctly from inside the signal handler. Agent-Logs-Url: https://github.com/acl-dev/open-coroutine/sessions/2b3f1622-04e3-4f08-945a-e1e391d32eb0 Co-authored-by: loongs-zhang <38336731+loongs-zhang@users.noreply.github.com>
1 parent 0db4bb2 commit d36d080

1 file changed

Lines changed: 11 additions & 6 deletions

File tree

core/src/scheduler.rs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -311,12 +311,17 @@ impl<'s> Scheduler<'s> {
311311
_ = RUNNING_COROUTINES.remove(&co_id);
312312
})? {
313313
CoroutineState::Syscall((), _, state) => {
314-
//挂起协程到系统调用表
315-
//如果已包含,说明当前系统调用还有上层父系统调用,因此直接忽略插入结果
316-
_ = self.syscall.insert(co_id, coroutine);
317-
if let SyscallState::Suspend(timestamp) = state {
318-
self.syscall_suspend
319-
.push(SyscallSuspendItem { timestamp, co_id });
314+
if let SyscallState::Executing = state {
315+
//协程在系统调用执行期间被信号抢占,放回就绪队列以恢复执行
316+
self.ready.push(coroutine);
317+
} else {
318+
//挂起协程到系统调用表
319+
//如果已包含,说明当前系统调用还有上层父系统调用,因此直接忽略插入结果
320+
_ = self.syscall.insert(co_id, coroutine);
321+
if let SyscallState::Suspend(timestamp) = state {
322+
self.syscall_suspend
323+
.push(SyscallSuspendItem { timestamp, co_id });
324+
}
320325
}
321326
}
322327
CoroutineState::Suspend((), timestamp) => {

0 commit comments

Comments
 (0)