[Git][NTPsec/ntpsec][master] 3 commits: Remove unneeded check/indentation on for loop

Hal Murray gitlab at mg.gitlab.com
Tue Sep 25 08:17:13 UTC 2018


Hal Murray pushed to branch master at NTPsec / ntpsec


Commits:
6b780e1b by Hal Murray at 2018-09-24T08:24:18Z
Remove unneeded check/indentation on for loop

- - - - -
c194b9cc by Hal Murray at 2018-09-24T08:24:18Z
Remove unused SETSOCKOPT_ARG_CAST

- - - - -
4631705f by Hal Murray at 2018-09-24T08:24:18Z
Remove network_packet flag from recvbuf

It was only used in receive() in ntp_proto.c
but that code is only called for network packets
(as compared to refclock messages)

- - - - -


4 changed files:

- devel/ifdex-ignores
- include/recvbuff.h
- ntpd/ntp_io.c
- ntpd/ntp_proto.c


Changes:

=====================================
devel/ifdex-ignores
=====================================
@@ -122,7 +122,6 @@ NOTUSED
 ONCORE_VERBOSE_.*	# Debugging symbols internal to the OnCore refclock
 PI			# Math constant used by the sim code
 RUN_TEST		# Internal to Unity
-SETSOCKOPT_ARG_CAST	# Can probably go away when the Windows port is cleaned up.
 THREAD_MINSTACKSIZE
 UINTPTR_MAX		# Unity
 UINTPTR_MAX0		# Unity


=====================================
include/recvbuff.h
=====================================
@@ -52,7 +52,6 @@ struct recvbuf {
 	keyid_t keyid;
 	int mac_len;
 #ifdef REFCLOCK
-	bool network_packet;
 	struct peer *	recv_peer;
 #endif /* REFCLOCK */
 };


=====================================
ntpd/ntp_io.c
=====================================
@@ -38,17 +38,6 @@
 #define IFS_CREATED     2       /* was just created */
 #define IFS_DELETED     3       /* was just delete */
 
-/*
- * setsockopt does not always have the same arg declaration
- * across all platforms. If it's not defined we make it empty
- * UNUSED
- *
- * #ifndef SETSOCKOPT_ARG_CAST
- * #define SETSOCKOPT_ARG_CAST
- * #endif
- */
-
-
 #ifndef IPTOS_DSCP_EF
 #define IPTOS_DSCP_EF 0xb8
 #endif
@@ -2113,7 +2102,6 @@ read_refclock_packet(
 	rb->dstadr = 0;
 	rb->fd = fd;
 	rb->recv_time = ts;
-	rb->network_packet = false;
 
 	consumed = indicate_refclock_packet(rp, rb);
 	if (!consumed) {
@@ -2244,9 +2232,6 @@ read_network_packet(
 	rb->dstadr = itf;
 	rb->fd = fd;
 	rb->recv_time = fetch_packetstamp(&msghdr);
-#ifdef REFCLOCK
-	rb->network_packet = true;
-#endif /* REFCLOCK */
 
 	receive(rb);
 	freerecvbuf(rb);
@@ -2335,39 +2320,37 @@ input_handler(
 	 * Check out the reference clocks first, if any
 	 */
 
-	if (refio != NULL) {
-		for (rp = refio; rp != NULL; rp = rp->next) {
-			fd = rp->fd;
+	for (rp = refio; rp != NULL; rp = rp->next) {
+		fd = rp->fd;
 
-			if (!FD_ISSET(fd, fds))
-				continue;
-			++select_count;
-			buflen = read_refclock_packet(fd, rp);
-			/*
-			 * The first read must succeed after select()
-			 * indicates readability, or we've reached
-			 * a permanent EOF.  http://bugs.ntp.org/1732
-			 * reported ntpd munching CPU after a USB GPS
-			 * was unplugged because select was indicating
-			 * EOF but ntpd didn't remove the descriptor
-			 * from the activefds set.
-			 */
-			if (buflen < 0 && EAGAIN != errno) {
-				saved_errno = errno;
-				clk = refclock_name(rp->srcclock);
-				errno = saved_errno;
-				msyslog(LOG_ERR, "IO: %s read: %m", clk);
-				maintain_activefds(fd, true);
-			} else if (0 == buflen) {
-				clk = refclock_name(rp->srcclock);
-				msyslog(LOG_ERR, "IO: %s read EOF", clk);
-				maintain_activefds(fd, true);
-			} else {
-				/* drain any remaining refclock input */
-				do {
-					buflen = read_refclock_packet(fd, rp);
-				} while (buflen > 0);
-			}
+		if (!FD_ISSET(fd, fds))
+			continue;
+		++select_count;
+		buflen = read_refclock_packet(fd, rp);
+		/*
+		 * The first read must succeed after select()
+		 * indicates readability, or we've reached
+		 * a permanent EOF.  http://bugs.ntp.org/1732
+		 * reported ntpd munching CPU after a USB GPS
+		 * was unplugged because select was indicating
+		 * EOF but ntpd didn't remove the descriptor
+		 * from the activefds set.
+		 */
+		if (buflen < 0 && EAGAIN != errno) {
+			saved_errno = errno;
+			clk = refclock_name(rp->srcclock);
+			errno = saved_errno;
+			msyslog(LOG_ERR, "IO: %s read: %m", clk);
+			maintain_activefds(fd, true);
+		} else if (0 == buflen) {
+			clk = refclock_name(rp->srcclock);
+			msyslog(LOG_ERR, "IO: %s read EOF", clk);
+			maintain_activefds(fd, true);
+		} else {
+			/* drain any remaining refclock input */
+			do {
+				buflen = read_refclock_packet(fd, rp);
+			} while (buflen > 0);
 		}
 	}
 #endif /* REFCLOCK */


=====================================
ntpd/ntp_proto.c
=====================================
@@ -653,13 +653,7 @@ receive(
 
 /* FIXME: This is lots more cleanup to do in this area. */
 
-#ifdef REFCLOCK
-	restrict_mask = rbufp->network_packet ?
-	    restrictions(&rbufp->recv_srcadr) :
-	    0;
-#else
 	restrict_mask = restrictions(&rbufp->recv_srcadr);
-#endif
 
 	if(check_early_restrictions(rbufp, restrict_mask)) {
 		stat_count.sys_restricted++;



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/1de0c95180c0c3e4a3af45a4a2a819dcfe6a8148...4631705fb180cea0e16d8bf0717021a2b9587f8c

-- 
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/1de0c95180c0c3e4a3af45a4a2a819dcfe6a8148...4631705fb180cea0e16d8bf0717021a2b9587f8c
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/20180925/c8ac338b/attachment-0001.html>


More information about the vc mailing list