From 4976ce2f311889a86e0b3a7ff187473757d1a4b7 Mon Sep 17 00:00:00 2001 From: "Dmitry V. Levin" Date: Fri, 23 Mar 2018 00:20:33 +0000 Subject: [PATCH] strace: do not call sigsetjmp without a delay timer As sigsetjmp costs a syscall, do not call it unless a delay timer is already created and its signal handler is going to be unblocked. * strace.c (next_event): Move sigsetjmp invocation under is_delay_timer_created() condition. Optimizes: v4.21-108-gba8e768 ("Implement delay injection") --- strace.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/strace.c b/strace.c index 397f5d51..173fdab7 100644 --- a/strace.c +++ b/strace.c @@ -2238,14 +2238,6 @@ next_event(int *pstatus, siginfo_t *si) return TE_BREAK; } - if (sigsetjmp(timer_jmp_buf, 1)) { - /* - * restart_delayed_tcbs() forwarded an error - * from dispatch_event(). - */ - return TE_BREAK; - } - /* * The window of opportunity to handle expirations * of the delay timer opens here. @@ -2253,8 +2245,16 @@ next_event(int *pstatus, siginfo_t *si) * Unblock the signal handler for the delay timer * iff the delay timer is already created. */ - if (is_delay_timer_created()) + if (is_delay_timer_created()) { + if (sigsetjmp(timer_jmp_buf, 1)) { + /* + * restart_delayed_tcbs() forwarded an error + * from dispatch_event(). + */ + return TE_BREAK; + } sigprocmask(SIG_UNBLOCK, &timer_set, NULL); + } /* * If the delay timer has expired, then its expiration -- 2.40.0