[Git][NTPsec/ntpsec][deglobal] Changed signal indicator bools from globals to struct members.
Ian Bruene
gitlab at mg.gitlab.com
Sun May 13 15:58:10 UTC 2018
Ian Bruene pushed to branch deglobal at NTPsec / ntpsec
Commits:
1acddc55 by Ian Bruene at 2018-05-13T15:57:30Z
Changed signal indicator bools from globals to struct members.
- - - - -
4 changed files:
- include/ntpd.h
- ntpd/ntp_io.c
- ntpd/ntp_timer.c
- ntpd/ntpd.c
Changes:
=====================================
include/ntpd.h
=====================================
--- a/include/ntpd.h
+++ b/include/ntpd.h
@@ -349,10 +349,14 @@ extern uint64_t sys_kodsent; /* KoD sent */
extern uptime_t use_stattime; /* time since usestats reset */
/* Signalling: Set by signal handlers */
-extern volatile bool sawALRM;
-extern volatile bool sawHUP;
-extern volatile bool sawDNS;
-extern volatile bool sawQuit; /* SIGQUIT, SIGINT, SIGTERM */
+struct signals_detected {
+ bool sawALRM;
+ bool sawHUP;
+ bool sawDNS;
+ bool sawQuit; /* SIGQUIT, SIGINT, SIGTERM */
+};
+extern volatile struct signals_detected sig_flags;
+
/* ntp_restrict.c */
extern restrict_u * restrictlist4; /* IPv4 restriction list */
=====================================
ntpd/ntp_io.c
=====================================
--- a/ntpd/ntp_io.c
+++ b/ntpd/ntp_io.c
@@ -278,14 +278,12 @@ static int read_refclock_packet (SOCKET, struct refclockio *, l_fp);
/*
* Flags from signal handlers
*/
-volatile bool sawALRM = false;
-volatile bool sawHUP = false;
-#ifdef ENABLE_DNS_LOOKUP
-volatile bool sawDNS = false;
-#else
-# define sawDNS false
-#endif
-volatile bool sawQuit = false; /* SIGQUIT, SIGINT, SIGTERM */
+volatile struct signals_detected sig_flags = {
+ .sawALRM = false,
+ .sawHUP = false,
+ .sawDNS = false,
+ .sawQuit = false /* SIGQUIT, SIGINT, SIGTERM */
+};
static sigset_t blockMask;
void
@@ -2412,7 +2410,8 @@ io_handler(void)
* reception of input.
*/
pthread_sigmask(SIG_BLOCK, &blockMask, &runMask);
- flag = sawALRM || sawQuit || sawHUP || sawDNS;
+ flag = sig_flags.sawALRM || sig_flags.sawQuit || sig_flags.sawHUP || \
+ sig_flags.sawDNS;
if (!flag) {
rdfdes = activefds;
nfound = pselect(maxactivefd+1, &rdfdes, NULL, NULL, NULL, &runMask);
=====================================
ntpd/ntp_timer.c
=====================================
--- a/ntpd/ntp_timer.c
+++ b/ntpd/ntp_timer.c
@@ -137,7 +137,7 @@ init_timer(void)
/*
* Initialize...
*/
- sawALRM = false;
+ sig_flags.sawALRM = false;
alarm_overflow = 0;
adjust_timer = 1;
stats_timer = SECSPERHR;
@@ -309,13 +309,13 @@ catchALRM(
# ifdef DEBUG
const char *msg = NULL;
# endif
- if (sawALRM) {
+ if (sig_flags.sawALRM) {
alarm_overflow++;
# ifdef DEBUG
msg = "catchALRM: overflow\n";
# endif
} else {
- sawALRM = true;
+ sig_flags.sawALRM = true;
# ifdef DEBUG
msg = "catchALRM: normal\n";
# endif
=====================================
ntpd/ntpd.c
=====================================
--- a/ntpd/ntpd.c
+++ b/ntpd/ntpd.c
@@ -918,28 +918,28 @@ static void mainloop(void)
init_timer();
for (;;) {
- if (sawQuit)
+ if (sig_flags.sawQuit)
finish_safe(signo);
- if (!sawALRM && !has_full_recv_buffer()) {
+ if (!sig_flags.sawALRM && !has_full_recv_buffer()) {
/*
* Nothing to do. Wait for something.
*/
io_handler();
}
- if (sawALRM) {
+ if (sig_flags.sawALRM) {
/*
* Out here, signals are unblocked. Call timer routine
* to process expiry.
*/
- sawALRM = false;
+ sig_flags.sawALRM = false;
timer();
}
#ifdef ENABLE_DNS_LOOKUP
- if (sawDNS) {
- sawDNS = false;
+ if (sig_flags.sawDNS) {
+ sig_flags.sawDNS = false;
dns_check();
}
#endif
@@ -956,10 +956,10 @@ static void mainloop(void)
rbuf = get_full_recv_buffer();
while (rbuf != NULL) {
- if (sawALRM) {
+ if (sig_flags.sawALRM) {
/* avoid timer starvation during lengthy I/O handling */
timer();
- sawALRM = false;
+ sig_flags.sawALRM = false;
}
/*
@@ -997,8 +997,8 @@ static void mainloop(void)
/*
* Check files
*/
- if (sawHUP) {
- sawHUP = false;
+ if (sig_flags.sawHUP) {
+ sig_flags.sawHUP = false;
msyslog(LOG_INFO, "LOG: Saw SIGHUP");
reopen_logfile();
@@ -1065,7 +1065,7 @@ catchQuit(
int sig
)
{
- sawQuit = true;
+ sig_flags.sawQuit = true;
signo = sig;
}
@@ -1075,7 +1075,7 @@ catchQuit(
static void catchHUP(int sig)
{
UNUSED_ARG(sig);
- sawHUP = true;
+ sig_flags.sawHUP = true;
}
#ifdef ENABLE_DNS_LOOKUP
@@ -1085,7 +1085,7 @@ static void catchHUP(int sig)
static void catchDNS(int sig)
{
UNUSED_ARG(sig);
- sawDNS = true;
+ sig_flags.sawDNS = true;
}
#endif
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/1acddc55a938784440184fea912db51f38963f15
--
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/1acddc55a938784440184fea912db51f38963f15
You're receiving this email because of your account on gitlab.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20180513/91938379/attachment.html>
More information about the vc
mailing list