connectors/pec_listener: Make exit_flag volatile
PATCH 1/1 connectors/pec_listener: Make exit_flag volatile
There are two ways in which the main loop of pec_listener can stop:
- syscall gets interrupted by signal and its error handler code breaks the loop
- or exit_flag get set to 1
The exit flag is only changed in signal handler so it needs to be volatile, otherwise the compiler will optimize it out of the main program loop. If an incoming signal doesn't interrupt a syscall, pec_listener will get stuck in the loop forever. It's a rare situation but it does happen once in a while.
Signed-off-by Martin Doucha <[email protected]>
--- testcases/kernel/connectors/pec/pec_listener.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
testcases/kernel/connectors/pec/pec_listener.c +1 -1
@@ -50,7 +50,7 @@ int main(void)static __u32 seq; -static int exit_flag; +static volatile int exit_flag;static struct sigaction sigint_action;struct nlmsghdr *nlhdr;
Signature · 1 line
2.32.0
PATCH 1/1 connectors/pec_listener: Make exit_flag volatile
Hi!
Good catch, applied, thanks.
Signature · 2 lines
Cyril Hrubis [email protected]