diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c index d36c382d3e23..7a99de63c655 100644 --- a/sys/kern/kern_sig.c +++ b/sys/kern/kern_sig.c @@ -3976,6 +3976,22 @@ sigfastblock_fetch_sig(struct thread *td, bool sendsig, uint32_t *valp) return (true); } +static void +sigfastblock_resched(struct thread *td, bool resched) +{ + struct proc *p; + + if (resched) { + p = td->td_proc; + PROC_LOCK(p); + reschedule_signals(p, td->td_sigmask, 0); + PROC_UNLOCK(p); + } + thread_lock(td); + td->td_flags |= TDF_ASTPENDING | TDF_NEEDSIGCHK; + thread_unlock(td); +} + int sys_sigfastblock(struct thread *td, struct sigfastblock_args *uap) { @@ -4046,11 +4062,8 @@ sys_sigfastblock(struct thread *td, struct sigfastblock_args *uap) * signals to current thread. But notify others about * fake unblock. */ - if (error == 0 && p->p_numthreads != 1) { - PROC_LOCK(p); - reschedule_signals(p, td->td_sigmask, 0); - PROC_UNLOCK(p); - } + sigfastblock_resched(td, error == 0 && p->p_numthreads != 1); + break; case SIGFASTBLOCK_UNSETPTR: @@ -4079,7 +4092,6 @@ sys_sigfastblock(struct thread *td, struct sigfastblock_args *uap) void sigfastblock_clear(struct thread *td) { - struct proc *p; bool resched; if ((td->td_pflags & TDP_SIGFASTBLOCK) == 0) @@ -4088,12 +4100,7 @@ sigfastblock_clear(struct thread *td) resched = (td->td_pflags & TDP_SIGFASTPENDING) != 0 || SIGPENDING(td); td->td_pflags &= ~(TDP_SIGFASTBLOCK | TDP_SIGFASTPENDING); - if (resched) { - p = td->td_proc; - PROC_LOCK(p); - reschedule_signals(p, td->td_sigmask, 0); - PROC_UNLOCK(p); - } + sigfastblock_resched(td, resched); } void