From aa3da7d73f9ba94626814ecdeb7c05108a2a5145 Mon Sep 17 00:00:00 2001 From: tezc Date: Wed, 20 Jan 2021 06:53:13 +0300 Subject: [PATCH] fix global variables for signal. --- signal/sc_signal.c | 19 ++++++++++++++++++- signal/sc_signal.h | 8 ++++---- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/signal/sc_signal.c b/signal/sc_signal.c index ce2fc55..e511291 100644 --- a/signal/sc_signal.c +++ b/signal/sc_signal.c @@ -33,6 +33,24 @@ #include #include +#if defined(_WIN32) +#include +volatile SOCKET sc_signal_shutdown_fd; +#else +volatile sig_atomic_t sc_signal_shutdown_fd; +#endif + +/** + * Set log file fd here, logging will be redirected to this fd, otherwise + * STDERR_FILENO or STDOUT_FILENO will be used. + */ +volatile sig_atomic_t sc_signal_log_fd; + +/** + * Internal variable to handle twice shutdown signal. + */ +volatile sig_atomic_t sc_signal_will_shutdown; + #define get_uint(va, size) \ (size) == 3 ? va_arg(va, unsigned long long) : \ (size) == 2 ? va_arg(va, unsigned long) : \ @@ -482,4 +500,3 @@ void sc_signal_log(int fd, char *buf, size_t len, char *fmt, ...) (void) write(fd, buf, written); } - diff --git a/signal/sc_signal.h b/signal/sc_signal.h index a08f2fe..6e8c155 100644 --- a/signal/sc_signal.h +++ b/signal/sc_signal.h @@ -37,21 +37,21 @@ */ #if defined(_WIN32) #include -volatile SOCKET sc_signal_shutdown_fd; +extern volatile SOCKET sc_signal_shutdown_fd; #else -volatile sig_atomic_t sc_signal_shutdown_fd; +extern volatile sig_atomic_t sc_signal_shutdown_fd; #endif /** * Set log file fd here, logging will be redirected to this fd, otherwise * STDERR_FILENO or STDOUT_FILENO will be used. */ -volatile sig_atomic_t sc_signal_log_fd; +extern volatile sig_atomic_t sc_signal_log_fd; /** * Internal variable to handle twice shutdown signal. */ -volatile sig_atomic_t sc_signal_will_shutdown; +extern volatile sig_atomic_t sc_signal_will_shutdown; /** * Init signal handler, hooks for shutdown signals and some fatal signals.