From 1416a47e875a8e68b9d9da7e2314129bbd1cbf69 Mon Sep 17 00:00:00 2001 From: Stephen Seo Date: Sat, 21 Sep 2024 14:41:02 +0900 Subject: [PATCH] Use volatile for global variables These globals are accessed in signal handling, so they need to be volatile. Resolves https://git.seodisparate.com/stephenseo/c_simple_http/issues/4 --- src/globals.c | 4 ++-- src/globals.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/globals.c b/src/globals.c index 393a4e2..536d67e 100644 --- a/src/globals.c +++ b/src/globals.c @@ -16,7 +16,7 @@ #include "globals.h" -int_fast8_t C_SIMPLE_HTTP_KEEP_RUNNING = 1; -int_fast8_t C_SIMPLE_HTTP_SIGUSR1_SET = 0; +volatile int_fast8_t C_SIMPLE_HTTP_KEEP_RUNNING = 1; +volatile int_fast8_t C_SIMPLE_HTTP_SIGUSR1_SET = 0; // vim: et ts=2 sts=2 sw=2 diff --git a/src/globals.h b/src/globals.h index cd8e5d9..70886d6 100644 --- a/src/globals.h +++ b/src/globals.h @@ -20,8 +20,8 @@ // Standard library includes. #include -extern int_fast8_t C_SIMPLE_HTTP_KEEP_RUNNING; -extern int_fast8_t C_SIMPLE_HTTP_SIGUSR1_SET; +extern volatile int_fast8_t C_SIMPLE_HTTP_KEEP_RUNNING; +extern volatile int_fast8_t C_SIMPLE_HTTP_SIGUSR1_SET; #endif