]> git.seodisparate.com - c_simple_http/commitdiff
Use volatile for global variables
authorStephen Seo <seo.disparate@gmail.com>
Sat, 21 Sep 2024 05:41:02 +0000 (14:41 +0900)
committerStephen Seo <seo.disparate@gmail.com>
Sat, 21 Sep 2024 05:41:02 +0000 (14:41 +0900)
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
src/globals.h

index 393a4e2166c31321bd6621434886d0540f53c6c6..536d67e84516dd0cf23de4b3a11889d0ed59b554 100644 (file)
@@ -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
index cd8e5d9853d48fdd775be4ae84fcea369cf5f306..70886d661a0d5f9ffc8ee75dc709122f0daddc8a 100644 (file)
@@ -20,8 +20,8 @@
 // Standard library includes.
 #include <stdint.h>
 
-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