[Git][NTPsec/ntpsec][deglobal] 2 commits: Changed fast_xmit to use recv_buf->pkt structure.
Ian Bruene
gitlab at mg.gitlab.com
Sun May 13 15:57:22 UTC 2018
Ian Bruene pushed to branch deglobal at NTPsec / ntpsec
Commits:
1925aa36 by Ian Bruene at 2018-05-08T17:03:13Z
Changed fast_xmit to use recv_buf->pkt structure.
- - - - -
cd2fa655 by Ian Bruene at 2018-05-13T15:57:07Z
Changed signal indicator bools from globals to struct members.
- - - - -
5 changed files:
- include/ntpd.h
- ntpd/ntp_io.c
- ntpd/ntp_proto.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_proto.c
=====================================
--- a/ntpd/ntp_proto.c
+++ b/ntpd/ntp_proto.c
@@ -2211,8 +2211,6 @@ fast_xmit(
)
{
struct pkt xpkt; /* transmit packet structure */
- struct pkt *rpkt; /* receive packet structure */
- struct pkt pkt_core; /* recieve packet copy target */
l_fp xmt_tx, xmt_ty;
size_t sendlen;
@@ -2224,8 +2222,6 @@ fast_xmit(
* control and not strictly specification compliant, but doesn't
* break anything.
*/
- unmarshall_pkt(&pkt_core, rbufp);
- rpkt = &pkt_core;
/*
* If this is a kiss-o'-death (KoD) packet, show leap
@@ -2237,17 +2233,21 @@ fast_xmit(
if (flags & RES_KOD) {
sys_kodsent++;
xpkt.li_vn_mode = PKT_LI_VN_MODE(LEAP_NOTINSYNC,
- PKT_VERSION(rpkt->li_vn_mode), xmode);
+ PKT_VERSION(rbufp->pkt.li_vn_mode), xmode);
xpkt.stratum = STRATUM_PKT_UNSPEC;
- xpkt.ppoll = max(rpkt->ppoll, ntp_minpoll);
- xpkt.precision = rpkt->precision;
+ xpkt.ppoll = max(rbufp->pkt.ppoll, ntp_minpoll);
+ xpkt.precision = rbufp->pkt.precision;
memcpy(&xpkt.refid, "RATE", REFIDLEN);
- xpkt.rootdelay = rpkt->rootdelay;
- xpkt.rootdisp = rpkt->rootdisp;
- xpkt.reftime = rpkt->reftime;
- xpkt.org = rpkt->xmt;
- xpkt.rec = rpkt->xmt;
- xpkt.xmt = rpkt->xmt;
+ xpkt.rootdelay = htonl(rbufp->pkt.rootdelay);
+ xpkt.rootdisp = htonl(rbufp->pkt.rootdisp);
+ xpkt.reftime.l_ui = htonl(rbufp->pkt.reftime >> 32);
+ xpkt.reftime.l_uf = htonl(rbufp->pkt.reftime & 0xFFFFFFFF);
+ xpkt.org.l_ui = htonl(rbufp->pkt.xmt >> 32);
+ xpkt.org.l_uf = htonl(rbufp->pkt.xmt & 0xFFFFFFFF);
+ xpkt.rec.l_ui = htonl(rbufp->pkt.xmt >> 32);
+ xpkt.rec.l_uf = htonl(rbufp->pkt.xmt & 0xFFFFFFFF);
+ xpkt.xmt.l_ui = htonl(rbufp->pkt.xmt >> 32);
+ xpkt.xmt.l_uf = htonl(rbufp->pkt.xmt & 0xFFFFFFFF);
/*
* This is a normal packet. Use the system variables.
@@ -2269,9 +2269,9 @@ fast_xmit(
* the transmit/receive times.
*/
xpkt.li_vn_mode = PKT_LI_VN_MODE(sys_leap,
- PKT_VERSION(rpkt->li_vn_mode), xmode);
+ PKT_VERSION(rbufp->pkt.li_vn_mode), xmode);
xpkt.stratum = STRATUM_TO_PKT(sys_stratum);
- xpkt.ppoll = max(rpkt->ppoll, ntp_minpoll);
+ xpkt.ppoll = max(rbufp->pkt.ppoll, ntp_minpoll);
xpkt.precision = sys_precision;
xpkt.refid = sys_refid;
xpkt.rootdelay = HTONS_FP(DTOUFP(sys_rootdelay));
@@ -2292,7 +2292,8 @@ fast_xmit(
xpkt.reftime = htonl_fp(sys_reftime);
#endif
- xpkt.org = rpkt->xmt;
+ xpkt.org.l_ui = htonl(rbufp->pkt.xmt >> 32);
+ xpkt.org.l_uf = htonl(rbufp->pkt.xmt & 0xFFFFFFFF);
#ifdef ENABLE_LEAP_SMEAR
this_recv_time = rbufp->recv_time;
=====================================
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/compare/6f3804ba84302940de5dbf9e1834bbe0f34cec69...cd2fa6552e5994e88ef26b8ad5f5916f3991c58b
--
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/6f3804ba84302940de5dbf9e1834bbe0f34cec69...cd2fa6552e5994e88ef26b8ad5f5916f3991c58b
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/8b7c7676/attachment.html>
More information about the vc
mailing list