From: Stephen Seo Date: Sat, 21 Sep 2024 05:41:02 +0000 (+0900) Subject: Use volatile for global variables X-Git-Tag: 1.0~31 X-Git-Url: https://git.seodisparate.com/stephenseo/img/favicon.ico?a=commitdiff_plain;h=1416a47e875a8e68b9d9da7e2314129bbd1cbf69;p=c_simple_http 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 --- 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