[ntp:bk-ntp-dev-send] BitKeeper diffs

stenn at whimsy.udel.edu stenn at whimsy.udel.edu
Sun Jul 21 06:46:05 UTC 2013


#### ChangeSet ####
2013-07-20 10:59:15+00:00, kardel at pogo.udel.edu
  ntp_io.c:
    add missing static

==== ntpd/ntp_io.c ====
2013-07-20 10:49:31+00:00, kardel at pogo.udel.edu +1 -1
  add missing static

--- 1.378/ntpd/ntp_io.c	2013-07-20 06:46:11 -04:00
+++ 1.379/ntpd/ntp_io.c	2013-07-20 06:49:31 -04:00
@@ -447,7 +447,7 @@ init_io(void)
 }
 
 
-void
+static void
 ntpd_addremove_io_fd(
 	int	fd,
 	int	is_pipe,

#### ChangeSet ####
2013-07-20 10:48:50+00:00, kardel at pogo.udel.edu
  ntp_io.c, work_thread.c:
    [Bug 2425] keep init_socket_sig() within ntp_io.c to avoid interference with sntp's way of doing i/o

==== libntp/work_thread.c ====
2013-07-20 10:48:05+00:00, kardel at pogo.udel.edu +0 -4
  [Bug 2425] keep init_socket_sig() within ntp_io.c to avoid interference with sntp's way of doing things

--- 1.15/libntp/work_thread.c	2013-07-20 04:23:41 -04:00
+++ 1.16/libntp/work_thread.c	2013-07-20 06:48:05 -04:00
@@ -13,7 +13,6 @@
 #include <pthread.h>
 #endif
 
-#include "iosignal.h"
 #include "ntp_stdlib.h"
 #include "ntp_malloc.h"
 #include "ntp_syslog.h"
@@ -450,9 +449,6 @@ start_blocking_thread_internal(
 			"start_blocking_thread: fcntl(F_SETFL, O_NONBLOCK) %m");
 		exit(1);
 	}
-#if HAVE_SIGNALED_IO
-	init_socket_sig(c->resp_read_pipe);
-#endif
 	(*addremove_io_fd)(c->resp_read_pipe, c->ispipe, FALSE);
 	pthread_attr_init(&thr_attr);
 	pthread_attr_setdetachstate(&thr_attr, PTHREAD_CREATE_DETACHED);

==== ntpd/ntp_io.c ====
2013-07-20 10:46:11+00:00, kardel at pogo.udel.edu +6 -1
  [Bug 2425] keep init_socket_sig() within ntp_io.c to avoid interference with sntp's way of doing things

--- 1.377/ntpd/ntp_io.c	2013-07-20 04:24:00 -04:00
+++ 1.378/ntpd/ntp_io.c	2013-07-20 06:46:11 -04:00
@@ -317,7 +317,7 @@ static int		cmp_addr_distance(const sock
  */
 #if !defined(HAVE_IO_COMPLETION_PORT)
 static inline int	read_network_packet	(SOCKET, struct interface *, l_fp);
-void			ntpd_addremove_io_fd	(int, int, int);
+static void		ntpd_addremove_io_fd	(int, int, int);
 #ifdef REFCLOCK
 static inline int	read_refclock_packet	(SOCKET, struct refclockio *, l_fp);
 #endif
@@ -455,6 +455,11 @@ ntpd_addremove_io_fd(
 	)
 {
 	UNUSED_ARG(is_pipe);
+
+#ifdef HAVE_SIGNALED_IO
+	init_socket_sig(fd);
+#endif /* not HAVE_SIGNALED_IO */
+
 	maintain_activefds(fd, remove_it);
 }
 

#### ChangeSet ####
2013-07-20 08:25:40+00:00, kardel at pogo.udel.edu
  work_thread.c, ntpd.h, ntpd.c, ntp_io.c, ChangeLog, iosignal.h, iosignal.c:
    [Bug 2425] fix async io setup for worker thread

==== ChangeLog ====
2013-07-20 08:20:17+00:00, kardel at pogo.udel.edu +2 -0
  [Bug 2425] fix async io setup for worker thread

--- 1.1311/ChangeLog	2013-07-20 00:32:58 -04:00
+++ 1.1312/ChangeLog	2013-07-20 04:20:17 -04:00
@@ -1,3 +1,5 @@
+* [Bug 2425] setup SIGIO/SIGPOLL for asyncio on the read side
+of a socketpair for the worker thread.
 * [Bug 2427] configure fails to detect recvmsg() on Solaris.
 (4.2.7p372) 2013/07/17 Released by Harlan Stenn <stenn at ntp.org>
 * [Bug 1466] Oncore should set FLAG_PPS.

==== include/iosignal.h ====
2013-07-20 08:23:03+00:00, kardel at pogo.udel.edu +4 -2
  [Bug 2425] fix async io setup for worker thread

--- 1.6/include/iosignal.h	2012-04-18 07:46:25 -04:00
+++ 1.7/include/iosignal.h	2013-07-20 04:23:03 -04:00
@@ -37,12 +37,14 @@
 
 extern int		using_sigio;
 
+typedef void (input_handler_t)(l_fp *);
+extern	input_handler_t	input_handler;
+
 extern void		block_sigio	(void);
 extern void		unblock_sigio	(void);
 extern int		init_clock_sig	(struct refclockio *);
 extern void		init_socket_sig	(int);
-extern void		set_signal	(void);
-RETSIGTYPE		sigio_handler	(int);
+extern void		set_signal	(input_handler_t *);
 
 # define BLOCKIO()	block_sigio()
 # define UNBLOCKIO()	unblock_sigio()

==== include/ntpd.h ====
2013-07-20 08:23:14+00:00, kardel at pogo.udel.edu +0 -1
  [Bug 2425] fix async io setup for worker thread

--- 1.174/include/ntpd.h	2013-03-02 22:41:02 -05:00
+++ 1.175/include/ntpd.h	2013-07-20 04:23:14 -04:00
@@ -120,7 +120,6 @@ extern	void	interface_update	(interface_
 
 extern	void	init_io 	(void);
 extern	void	io_open_sockets	(void);
-extern	void	input_handler	(l_fp *);
 extern	void	io_clr_stats	(void);
 extern	void	io_setbclient	(void);
 extern	void	io_unsetbclient	(void);

==== libntp/iosignal.c ====
2013-07-20 08:23:34+00:00, kardel at pogo.udel.edu +30 -15
  [Bug 2425] fix async io setup for worker thread

--- 1.16/libntp/iosignal.c	2012-04-18 07:46:25 -04:00
+++ 1.17/libntp/iosignal.c	2013-07-20 04:23:34 -04:00
@@ -45,7 +45,14 @@
 #include "iosignal.h"
 
 #if defined(HAVE_SIGNALED_IO)
+static RETSIGTYPE sigio_handler	(int);
+
+/* consistency safegurad to catch BLOCK/UNBLOCK oversights */
 static int sigio_block_count = 0;
+
+/* main inputhandler to be called on SIGIO */
+static input_handler_t *input_handler_callback = NULL;
+
 # if defined(HAVE_SIGACTION)
 /*
  * If sigaction() is used for signal handling and a signal is
@@ -59,7 +66,6 @@ static int sigio_block_count = 0;
  */
 static int sigio_handler_active = 0;
 # endif
-extern	void	input_handler	(l_fp *);
 
 /*
  * SIGPOLL and SIGIO ROUTINES.
@@ -100,7 +106,7 @@ init_clock_sig(
 		pgrp = getpid();
 		if (ioctl(rio->fd, FIOSSAIOOWN, (char *)&pgrp) == -1)
 		{
-			msyslog(LOG_ERR, "ioctl(FIOSSAIOOWN) fails for clock I/O: %m");
+			msyslog(LOG_ERR, "ioctl(FIOSSAIOOWN) fails for clock I/O: %m - EXITING");
 			exit(1);
 			/*NOTREACHED*/
 		}
@@ -110,14 +116,14 @@ init_clock_sig(
 		 */
 		if (ioctl(rio->fd, FIOSNBIO, (char *)&on) == -1)
 		{
-			msyslog(LOG_ERR, "ioctl(FIOSNBIO) fails for clock I/O: %m");
+			msyslog(LOG_ERR, "ioctl(FIOSNBIO) fails for clock I/O: %m - EXITING");
 			exit(1);
 			/*NOTREACHED*/
 		}
 
 		if (ioctl(rio->fd, FIOSSAIOSTAT, (char *)&on) == -1)
 		{
-			msyslog(LOG_ERR, "ioctl(FIOSSAIOSTAT) fails for clock I/O: %m");
+			msyslog(LOG_ERR, "ioctl(FIOSSAIOSTAT) fails for clock I/O: %m - EXITING");
 			exit(1);
 			/*NOTREACHED*/
 		}
@@ -204,7 +210,7 @@ init_socket_sig(
 		if (ioctl(fd, I_SETSIG, S_INPUT) < 0)
 		{
 			msyslog(LOG_ERR,
-				"init_socket_sig: ioctl(I_SETSIG, S_INPUT) failed: %m");
+				"init_socket_sig: ioctl(I_SETSIG, S_INPUT) failed: %m - EXITING");
 			exit(1);
 		}
 	}
@@ -218,7 +224,7 @@ init_socket_sig(
 #  if defined(FIOASYNC)
 		if (ioctl(fd, FIOASYNC, (char *)&on) == -1)
 		{
-			msyslog(LOG_ERR, "ioctl(FIOASYNC) fails: %m");
+			msyslog(LOG_ERR, "ioctl(FIOASYNC) fails: %m - EXITING");
 			exit(1);
 			/*NOTREACHED*/
 		}
@@ -228,13 +234,13 @@ init_socket_sig(
 
 			if ((flags = fcntl(fd, F_GETFL, 0)) == -1)
 			{
-				msyslog(LOG_ERR, "fcntl(F_GETFL) fails: %m");
+				msyslog(LOG_ERR, "fcntl(F_GETFL) fails: %m - EXITING");
 				exit(1);
 				/*NOTREACHED*/
 			}
 			if (fcntl(fd, F_SETFL, flags|FASYNC) < 0)
 			{
-				msyslog(LOG_ERR, "fcntl(...|FASYNC) fails: %m");
+				msyslog(LOG_ERR, "fcntl(...|FASYNC) fails: %m - EXITING");
 				exit(1);
 				/*NOTREACHED*/
 			}
@@ -252,21 +258,21 @@ init_socket_sig(
 #  if defined(SIOCSPGRP)
 		if (ioctl(fd, SIOCSPGRP, (char *)&pgrp) == -1)
 		{
-			msyslog(LOG_ERR, "ioctl(SIOCSPGRP) fails: %m");
+			msyslog(LOG_ERR, "ioctl(SIOCSPGRP) fails: %m - EXITING");
 			exit(1);
 			/*NOTREACHED*/
 		}
 #  elif defined(FIOSETOWN)
 		if (ioctl(fd, FIOSETOWN, (char*)&pgrp) == -1)
 		{
-			msyslog(LOG_ERR, "ioctl(FIOSETOWN) fails: %m");
+			msyslog(LOG_ERR, "ioctl(FIOSETOWN) fails: %m - EXITING");
 			exit(1);
 			/*NOTREACHED*/
 		}
 #  elif defined(F_SETOWN)
 		if (fcntl(fd, F_SETOWN, pgrp) == -1)
 		{
-			msyslog(LOG_ERR, "fcntl(F_SETOWN) fails: %m");
+			msyslog(LOG_ERR, "fcntl(F_SETOWN) fails: %m - EXITING");
 			exit(1);
 			/*NOTREACHED*/
 		}
@@ -277,7 +283,7 @@ init_socket_sig(
 # endif /* USE_UDP_SIGPOLL */
 }
 
-RETSIGTYPE
+static RETSIGTYPE
 sigio_handler(
 	int sig
 	)
@@ -293,7 +299,8 @@ sigio_handler(
 	    msyslog(LOG_ERR, "sigio_handler: sigio_handler_active != 1");
 # endif
 
-	(void)input_handler(&ts);
+	INSIST(input_handler_callback != NULL);
+	(*input_handler_callback)(&ts);
 
 # if defined(HAVE_SIGACTION)
 	sigio_handler_active--;
@@ -309,8 +316,12 @@ sigio_handler(
  */
 # ifdef HAVE_SIGACTION
 void
-set_signal(void)
+set_signal(input_handler_t *input)
 {
+	INSIST(input != NULL);
+	
+	input_handler_callback = input;
+
 	using_sigio = TRUE;
 #  ifdef USE_SIGIO
 	(void) signal_no_reset(SIGIO, sigio_handler);
@@ -480,8 +491,12 @@ block_sigio(void)
 }
 
 void
-set_signal(void)
+set_signal(input_handler_t *input)
 {
+	INSIST(input != NULL);
+
+	input_handler_callback = input;
+
 	using_sigio = TRUE;
 	(void) signal_no_reset(SIGIO, sigio_handler);
 }

==== libntp/work_thread.c ====
2013-07-20 08:23:41+00:00, kardel at pogo.udel.edu +4 -0
  [Bug 2425] fix async io setup for worker thread.

--- 1.14/libntp/work_thread.c	2013-07-07 01:03:19 -04:00
+++ 1.15/libntp/work_thread.c	2013-07-20 04:23:41 -04:00
@@ -13,6 +13,7 @@
 #include <pthread.h>
 #endif
 
+#include "iosignal.h"
 #include "ntp_stdlib.h"
 #include "ntp_malloc.h"
 #include "ntp_syslog.h"
@@ -449,6 +450,9 @@ start_blocking_thread_internal(
 			"start_blocking_thread: fcntl(F_SETFL, O_NONBLOCK) %m");
 		exit(1);
 	}
+#if HAVE_SIGNALED_IO
+	init_socket_sig(c->resp_read_pipe);
+#endif
 	(*addremove_io_fd)(c->resp_read_pipe, c->ispipe, FALSE);
 	pthread_attr_init(&thr_attr);
 	pthread_attr_setdetachstate(&thr_attr, PTHREAD_CREATE_DETACHED);

==== ntpd/ntp_io.c ====
2013-07-20 08:24:00+00:00, kardel at pogo.udel.edu +1 -1
  [Bug 2425] fix async io setup for worker thread

--- 1.376/ntpd/ntp_io.c	2013-02-09 19:54:55 -05:00
+++ 1.377/ntpd/ntp_io.c	2013-07-20 04:24:00 -04:00
@@ -442,7 +442,7 @@ init_io(void)
 #endif
 
 #if defined(HAVE_SIGNALED_IO)
-	(void) set_signal();
+	(void) set_signal(input_handler);
 #endif
 }
 

==== ntpd/ntpd.c ====
2013-07-20 08:24:06+00:00, kardel at pogo.udel.edu +1 -0
  [Bug 2425] fix async io setup for worker thread

--- 1.143/ntpd/ntpd.c	2013-07-17 05:18:36 -04:00
+++ 1.144/ntpd/ntpd.c	2013-07-20 04:24:06 -04:00
@@ -18,6 +18,7 @@
 #include "isc/error.h"
 #include "isc/strerror.h"
 #include "isc/formatcheck.h"
+#include "iosignal.h"
 
 #ifdef SIM
 # include "ntpsim.h"


More information about the bk-ntp-dev-send mailing list