Skip to contentSkip to conversation

connectors/pec_listener: Make exit_flag volatile

PATCH New Martin Doucha 2 participants 2 messages Aug 9, 2021

lore
Share & tools
lore
#0 lore raw

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.

---
 testcases/kernel/connectors/pec/pec_listener.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
testcases/kernel/connectors/pec/pec_listener.c +1 -1
index 7844dc905..2707ea8fb 100644
@@ -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