[Git][NTPsec/ntpsec][master] 2 commits: Change gmtime to gmtime_r (last 2)

Hal Murray gitlab at mg.gitlab.com
Fri Jan 15 23:06:00 UTC 2016


Hal Murray pushed to branch master at NTPsec / ntpsec


Commits:
137a3db6 by Hal Murray at 2016-01-15T14:36:28-08:00
Change gmtime to gmtime_r (last 2)

- - - - -
5c551aa1 by Hal Murray at 2016-01-15T15:03:30-08:00
Remove HAVE_PTHREAD_ATTR_*ETSTACKSIZE

Also fix bug in error handling.

- - - - -


4 changed files:

- libntp/work_thread.c
- ntpd/refclock_arc.c
- ntpd/refclock_dumbclock.c
- pylib/configure.py


Changes:

=====================================
libntp/work_thread.c
=====================================
--- a/libntp/work_thread.c
+++ b/libntp/work_thread.c
@@ -453,24 +453,21 @@ start_blocking_thread_internal(
 	(*addremove_io_fd)(c->resp_read_pipe, c->ispipe, false);
 	pthread_attr_init(&thr_attr);
 	pthread_attr_setdetachstate(&thr_attr, PTHREAD_CREATE_DETACHED);
-#if defined(HAVE_PTHREAD_ATTR_GETSTACKSIZE) && \
-    defined(HAVE_PTHREAD_ATTR_SETSTACKSIZE)
 	rc = pthread_attr_getstacksize(&thr_attr, &stacksize);
-	if (-1 == rc) {
+	if (0 != rc) {
+		errno = rc;
 		msyslog(LOG_ERR,
 			"start_blocking_thread: pthread_attr_getstacksize %m");
 	} else if (stacksize < THREAD_MINSTACKSIZE) {
 		rc = pthread_attr_setstacksize(&thr_attr,
 					       THREAD_MINSTACKSIZE);
-		if (-1 == rc)
+		if (0 != rc)
+			errno = rc;
 			msyslog(LOG_ERR,
 				"start_blocking_thread: pthread_attr_setstacksize(0x%lx -> 0x%lx) %m",
 				(u_long)stacksize,
 				(u_long)THREAD_MINSTACKSIZE);
 	}
-#else
-	UNUSED_ARG(stacksize);
-#endif
 	pthread_attr_setscope(&thr_attr, PTHREAD_SCOPE_SYSTEM);
 	c->thread_ref = emalloc_zero(sizeof(*c->thread_ref));
 	block_thread_signals(&saved_sig_mask);


=====================================
ntpd/refclock_arc.c
=====================================
--- a/ntpd/refclock_arc.c
+++ b/ntpd/refclock_arc.c
@@ -1250,7 +1250,7 @@ arc_receive(
 	if(peer->ttl > 0) {
 		if(pp->sloppyclockflag & CLK_FLAG1) {
 			struct tm  local;
-			struct tm *gmtp;
+			struct tm *gmtp, mygm;
 			time_t	   unixtime;
 
 			/*
@@ -1317,7 +1317,7 @@ arc_receive(
 				break;
 			}
 			unixtime = mktime (&local);
-			if ((gmtp = gmtime (&unixtime)) == NULL)
+			if ((gmtp = gmtime_r (&unixtime, &mygm)) == NULL)
 			{
 				pp->lencode = 0;
 				refclock_report (peer, CEVNT_FAULT);


=====================================
ntpd/refclock_dumbclock.c
=====================================
--- a/ntpd/refclock_dumbclock.c
+++ b/ntpd/refclock_dumbclock.c
@@ -235,7 +235,7 @@ dumbclock_receive(
 	if (sscanf(pp->a_lastcode,"%02d:%02d:%02d",
 		   &hours,&minutes,&seconds) == 3)
 	{
-	    struct tm *gmtp;
+	    struct tm *gmtp, mygm;
 	    struct tm *lt_p;
 	    struct tm tmbuf;
 	    time_t     asserted_time;	     /* the SPM time based on the composite time+date */
@@ -289,7 +289,7 @@ dumbclock_receive(
 		return;
 	    }
 
-	    if ((gmtp = gmtime (&asserted_time)) == NULL)
+	    if ((gmtp = gmtime_r (&asserted_time, &mygm)) == NULL)
 	    {
 		refclock_report (peer, CEVNT_FAULT);
 		return;


=====================================
pylib/configure.py
=====================================
--- a/pylib/configure.py
+++ b/pylib/configure.py
@@ -244,8 +244,6 @@ def cmd_configure(ctx):
 		('MD5Init', ["md5.h"], "CRYPTO"),
 		('ntp_adjtime', ["sys/time.h", "sys/timex.h"]),		# BSD
 		('ntp_gettime', ["sys/time.h", "sys/timex.h"]),		# BSD
-		('pthread_attr_getstacksize', ["pthread.h"], "PTHREAD"),
-		('pthread_attr_setstacksize', ["pthread.h"], "PTHREAD"),
 		('res_init', ["resolv.h"]),
 		("rtprio", ["sys/rtprio.h"]),		# Sun/BSD
 		('sched_setscheduler', ["sched.h"]),



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/62dd53daa07bc8f83d3f38be796c7bd32e0c4871...5c551aa16d53f2cb6a6cab8c25df3dced7c3ca51
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ntpsec.org/pipermail/vc/attachments/20160115/01a9600e/attachment.html>


More information about the vc mailing list