[Git][NTPsec/ntpsec][master] Cleanup intercept_pselect

Hal Murray gitlab at mg.gitlab.com
Wed Sep 28 18:00:20 UTC 2016


Hal Murray pushed to branch master at NTPsec / ntpsec


Commits:
7457eba1 by Hal Murray at 2016-09-28T10:59:41-07:00
Cleanup intercept_pselect

- - - - -


3 changed files:

- ntpd/ntp_intercept.c
- ntpd/ntp_intercept.h
- ntpd/ntp_io.c


Changes:

=====================================
ntpd/ntp_intercept.c
=====================================
--- a/ntpd/ntp_intercept.c
+++ b/ntpd/ntp_intercept.c
@@ -682,7 +682,7 @@ void intercept_sendpkt(const char *legend,
 }
 
 
-int intercept_select(int nfds, fd_set *readfds)
+int intercept_pselect(int nfds, fd_set *readfds, const sigset_t *runMask)
 {
     char pkt_dump[BUFSIZ];
     int nfound;
@@ -724,18 +724,8 @@ int intercept_select(int nfds, fd_set *readfds)
 	    return nfound;
 	}
     } else {
-	bool flag;
-	sigset_t runMask;
 
-	pthread_sigmask(SIG_BLOCK, &blockMask, &runMask);
-	flag = sawALRM || sawQuit || sawHUP;
-	if (!flag) {
-	  nfound = pselect(nfds + 1, readfds, NULL, NULL, NULL, &runMask);
-	} else {
-	  nfound = -1;
-	  errno = EINTR;
-	}
-	pthread_sigmask(SIG_SETMASK, &runMask, NULL);
+	nfound = pselect(nfds + 1, readfds, NULL, NULL, NULL, runMask);
 
 	if (mode == capture)
 	{


=====================================
ntpd/ntp_intercept.h
=====================================
--- a/ntpd/ntp_intercept.h
+++ b/ntpd/ntp_intercept.h
@@ -23,7 +23,7 @@ void intercept_get_systime(const char *, l_fp *);
 long intercept_ntp_random(const char *);
 void intercept_sendpkt(const char *,
 		       sockaddr_u *, struct interface *, int, void *, int);
-int intercept_select(int nfds, fd_set *);
+int intercept_pselect(int nfds, fd_set *readfds, const sigset_t *runMask);
 ssize_t intercept_recvfrom(int, void *,
 			   size_t, int, struct sockaddr *, socklen_t *);
 ssize_t intercept_recvmsg(int sockfd, struct msghdr *msg, int flags);


=====================================
ntpd/ntp_io.c
=====================================
--- a/ntpd/ntp_io.c
+++ b/ntpd/ntp_io.c
@@ -3426,6 +3426,8 @@ read_network_packet(
 void
 io_handler(void)
 {
+	bool flag;
+	sigset_t runMask;
 	fd_set rdfdes;
 	int nfound;
 
@@ -3434,8 +3436,17 @@ io_handler(void)
 	 * time.  select() will terminate on SIGALARM or on the
 	 * reception of input.
 	 */
-	rdfdes = activefds;
-	nfound = intercept_select(maxactivefd, &rdfdes);
+	pthread_sigmask(SIG_BLOCK, &blockMask, &runMask);
+	flag = sawALRM || sawQuit || sawHUP;
+	if (!flag) {
+	  rdfdes = activefds;
+	  nfound = intercept_pselect(maxactivefd, &rdfdes, &runMask);
+	} else {
+	  nfound = -1;
+	  errno = EINTR;
+	}
+	pthread_sigmask(SIG_SETMASK, &runMask, NULL);
+
 	if (nfound > 0) {
 		l_fp ts;
 



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/7457eba1aa1e61917cdb11d4283e803a7bb4603b
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ntpsec.org/pipermail/vc/attachments/20160928/21ad6d1f/attachment.html>


More information about the vc mailing list