Skip to content

Commit bf03c44

Browse files
authored
code polish (#401)
2 parents 35884fa + 66a06b6 commit bf03c44

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

core/src/coroutine/mod.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,14 @@ impl<'c, Param, Yield, Return> Coroutine<'c, Param, Yield, Return> {
147147
.is_ok()
148148
{
149149
extern "C" fn sigvtalrm_handler<Param, Yield>(_: libc::c_int) {
150-
if let Some(suspender) = suspender::Suspender::<Param, Yield>::current() {
151-
suspender.cancel();
150+
if let Ok(mut set) = SigSet::thread_get_mask() {
151+
//删除对SIGVTALRM信号的屏蔽,使信号处理函数即使在处理中,也可以再次进入信号处理函数
152+
set.remove(Signal::SIGVTALRM);
153+
set.thread_set_mask()
154+
.expect("Failed to remove SIGVTALRM signal mask!");
155+
if let Some(suspender) = suspender::Suspender::<Param, Yield>::current() {
156+
suspender.cancel();
157+
}
152158
}
153159
}
154160
// install SIGVTALRM signal handler

open-coroutine/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ mod tests {
377377
_ = any_join!(task!(|_| 1, ()), task!(|_| 2, ()), task!(|_| 3, ()));
378378
task!(
379379
|_| {
380-
println!("Try cancel!");
380+
unreachable!("Try cancel!");
381381
},
382382
(),
383383
)

0 commit comments

Comments
 (0)