[Git][NTPsec/ntpsec][master] 2 commits: Drop use of pthread_addr

Hal Murray gitlab at mg.gitlab.com
Thu Nov 9 06:55:30 UTC 2017


Hal Murray pushed to branch master at NTPsec / ntpsec


Commits:
d6657525 by Hal Murray at 2017-11-08T22:17:39-08:00
Drop use of pthread_addr

NULL works as default to pthread_create

- - - - -
7fe01921 by Hal Murray at 2017-11-08T22:17:39-08:00
Nuke ifdefs for O_NONBLOCK and O_NOCTTY

They are part of POSIX

- - - - -


3 changed files:

- libntp/ntp_dns.c
- ntpd/ntp_refclock.c
- ntpd/refclock_nmea.c


Changes:

=====================================
libntp/ntp_dns.c
=====================================
--- a/libntp/ntp_dns.c
+++ b/libntp/ntp_dns.c
@@ -51,7 +51,6 @@ static void* dns_lookup(void* arg);
 bool dns_probe(struct peer* pp)
 {
 	int rc;
-        pthread_attr_t  thr_attr;
         sigset_t        block_mask, saved_sig_mask;
 	const char	* busy = "";
 
@@ -63,18 +62,15 @@ bool dns_probe(struct peer* pp)
 		return false;
 	active = pp;
 
-        pthread_attr_init(&thr_attr);
-	/* might want to set stack size */
         sigfillset(&block_mask);
         pthread_sigmask(SIG_BLOCK, &block_mask, &saved_sig_mask);
-	rc = pthread_create(&worker, &thr_attr, dns_lookup, pp);
+	rc = pthread_create(&worker, NULL, dns_lookup, pp);
         if (rc) {
 		errno = rc;
 		msyslog(LOG_ERR, "DNS: dns_probe: error from pthread_create: %s, %m", pp->hostname);
 		return true;  /* don't try again */
 	}
         pthread_sigmask(SIG_SETMASK, &saved_sig_mask, NULL);
-        pthread_attr_destroy(&thr_attr);
 
 	return true;
 };


=====================================
ntpd/ntp_refclock.c
=====================================
--- a/ntpd/ntp_refclock.c
+++ b/ntpd/ntp_refclock.c
@@ -691,23 +691,13 @@ refclock_open(
 	)
 {
 	int	fd;
-	int	omode;
-#ifdef O_NONBLOCK
 	char	trash[128];	/* litter bin for old input data */
-#endif
 
 	/*
 	 * Open serial port and set default options
 	 */
-	omode = O_RDWR;
-#ifdef O_NONBLOCK
-	omode |= O_NONBLOCK;
-#endif
-#ifdef O_NOCTTY
-	omode |= O_NOCTTY;
-#endif
-
-	fd = open(dev, omode, 0777);
+
+	fd = open(dev, O_RDWR | O_NONBLOCK | O_NOCTTY, 0777);
 	/* refclock_open() long returned 0 on failure, avoid it. */
 	if (0 == fd) {
 		fd = dup(0);
@@ -721,7 +711,6 @@ refclock_open(
 		close(fd);
 		return -1;
 	}
-#ifdef O_NONBLOCK
 	/*
 	 * We want to make sure there is no pending trash in the input
 	 * buffer. Since we have non-blocking IO available, this is a
@@ -730,7 +719,6 @@ refclock_open(
 	 */
 	while (read(fd, trash, sizeof(trash)) > 0 || errno == EINTR)
 		/*NOP*/;
-#endif
 	return fd;
 }
 


=====================================
ntpd/refclock_nmea.c
=====================================
--- a/ntpd/refclock_nmea.c
+++ b/ntpd/refclock_nmea.c
@@ -142,17 +142,6 @@
 #ifdef HAVE_PPSAPI
 # define	PPSDEV		"/dev/gpspps%d"	/* PPSAPI device override */
 # define	PPS_PRECISION	(-20)		/* precision assumed (~ 1 us) */
-# ifndef O_NOCTTY
-#  define M_NOCTTY	0
-# else
-#  define M_NOCTTY	O_NOCTTY
-# endif
-# ifndef O_NONBLOCK
-#  define M_NONBLOCK	0
-# else
-#  define M_NONBLOCK	O_NONBLOCK
-# endif
-# define PPSOPENMODE	(O_RDWR | M_NOCTTY | M_NONBLOCK)
 #endif
 #ifdef ENABLE_CLASSIC_MODE
 #define	SPEED232	B4800		/* uart speed (4800 bps) */
@@ -588,7 +577,7 @@ nmea_control(
 		}
 		if ( peer->cfg.ppspath ) {
 		    up->ppsapi_fd = open(peer->cfg.ppspath,
-					 PPSOPENMODE, S_IRUSR | S_IWUSR);
+			O_RDWR | O_NOCTTY | O_NONBLOCK, S_IRUSR | S_IWUSR);
 		} else {
 		    up->ppsapi_fd = -1;
 		}



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/23a716dc1761578be2bcc901e70eac8b1198ab83...7fe0192173d02f5f47ae81be2d11520e0b1e7e37

---
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/23a716dc1761578be2bcc901e70eac8b1198ab83...7fe0192173d02f5f47ae81be2d11520e0b1e7e37
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/20171109/7c6ce09c/attachment.html>


More information about the vc mailing list