[Git][NTPsec/ntpsec][master] 3 commits: struct timeval elimination.

Eric S. Raymond gitlab at mg.gitlab.com
Sun Oct 2 15:26:22 UTC 2016


Eric S. Raymond pushed to branch master at NTPsec / ntpsec


Commits:
e1779caf by Eric S. Raymond at 2016-10-02T11:23:01-04:00
struct timeval elimination.

- - - - -
233016cd by Eric S. Raymond at 2016-10-02T11:23:20-04:00
More struct timeval elimination.

- - - - -
16cc136a by Eric S. Raymond at 2016-10-02T11:24:22-04:00
struct timeval elimnination (from GPSD refclock driver).

- - - - -


3 changed files:

- ntpd/refclock_gpsd.c
- ntpd/refclock_oncore.c
- ntpq/ntpq.c


Changes:

=====================================
ntpd/refclock_gpsd.c
=====================================
--- a/ntpd/refclock_gpsd.c
+++ b/ntpd/refclock_gpsd.c
@@ -1950,13 +1950,13 @@ gpsd_test_socket(
 		    up->logname, up->fdt));
 
 	{
-		struct timeval tout;
+		struct timespec tout;
 		fd_set         wset;
 
 		memset(&tout, 0, sizeof(tout));
 		FD_ZERO(&wset);
 		FD_SET(up->fdt, &wset);
-		rc = select(up->fdt+1, NULL, &wset, NULL, &tout);
+		rc = pselect(up->fdt+1, NULL, &wset, NULL, &tout, NULL);
 		if (0 == rc || !(FD_ISSET(up->fdt, &wset)))
 			return;
 	}


=====================================
ntpd/refclock_oncore.c
=====================================
--- a/ntpd/refclock_oncore.c
+++ b/ntpd/refclock_oncore.c
@@ -1894,15 +1894,12 @@ oncore_msg_any(
 	char *q;
 	char *qlim;
 	struct timespec ts;
-	struct timeval tv;
 	char	Msg[120], Msg2[10];
 
 	if (debug > 3) {
 		(void) clock_gettime(CLOCK_REALTIME, &ts);
-		tv.tv_sec = ts.tv_sec;
-		tv.tv_usec = ts.tv_nsec / 1000;
-		oncore_log(instance, LOG_DEBUG, "%ld.%06ld",
-			   (long)tv.tv_sec, (long)tv.tv_usec);
+		oncore_log(instance, LOG_DEBUG, "%ld.%09ld",
+			   (long)tv.tv_sec, (long)tv.tv_nsec);
 
 		if (!*fmt) {
 			snprintf(Msg, sizeof(Msg), ">>@@%c%c ", buf[2],


=====================================
ntpq/ntpq.c
=====================================
--- a/ntpq/ntpq.c
+++ b/ntpq/ntpq.c
@@ -288,8 +288,8 @@ struct xcmd builtins[] = {
 /*
  * Some variables used and manipulated locally
  */
-struct timeval tvout = { DEFTIMEOUT, 0 };	/* time out for reads */
-struct timeval tvsout = { DEFSTIMEOUT, 0 };/* secondary time out */
+struct timespec tsout = { DEFTIMEOUT, 0 };	/* time out for reads */
+struct timespec tssout = { DEFSTIMEOUT, 0 };	/* secondary time out */
 l_fp delay_time;				/* delay time */
 char currenthost[NI_MAXHOST];			/* current host name */
 bool currenthostisnum;				/* is prior text from IP? */
@@ -848,7 +848,7 @@ getresponse(
 	)
 {
 	struct ntp_control rpkt;
-	struct timeval tvo;
+	struct timespec tso;
 	u_short offsets[MAXFRAGS+1];
 	u_short counts[MAXFRAGS+1];
 	u_short offset;
@@ -895,12 +895,12 @@ getresponse(
                 }
 
 		if (numfrags == 0)
-			tvo = tvout;
+			tso = tsout;
 		else
-			tvo = tvsout;
+			tso = tssout;
 
 		FD_SET(sockfd, &fds);
-		n = select(sockfd + 1, &fds, NULL, NULL, &tvo);
+		n = pselect(sockfd + 1, &fds, NULL, NULL, &tso, NULL);
 
 		if (n == -1) {
 			warning("select fails");
@@ -2174,12 +2174,12 @@ timeout(
 	int val;
 
 	if (pcmd->nargs == 0) {
-		val = (int)tvout.tv_sec * 1000 + tvout.tv_usec / 1000;
+		val = (int)tsout.tv_sec * 1000 + tsout.tv_nsec / 1000000;
 		(void) fprintf(fp, "primary timeout %d ms\n", val);
 	} else {
-		tvout.tv_sec = pcmd->argval[0].uval / 1000;
-		tvout.tv_usec = (pcmd->argval[0].uval - ((long)tvout.tv_sec * 1000))
-			* 1000;
+		tsout.tv_sec = pcmd->argval[0].uval / 1000;
+		tsout.tv_nsec = (pcmd->argval[0].uval - ((long)tsout.tv_sec * 1000))
+			* 1000000;
 	}
 }
 



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/3cdd4571232f53ca26c9a24a00da8d4ce691bfe4...16cc136aadcae131d85df3b36e39d0b0031ca0a4
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ntpsec.org/pipermail/vc/attachments/20161002/6c2a1be2/attachment.html>


More information about the vc mailing list