rpms/ntp/devel ntp-4.2.4p0-sleep.patch, NONE, 1.1 ntp.spec, 1.65, 1.66 ntp-4.2.4-sleep.patch, 1.1, NONE

Miroslav Lichvar (mlichvar) fedora-extras-commits at redhat.com
Wed May 9 16:45:36 UTC 2007


Author: mlichvar

Update of /cvs/pkgs/rpms/ntp/devel
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv20513

Modified Files:
	ntp.spec 
Added Files:
	ntp-4.2.4p0-sleep.patch 
Removed Files:
	ntp-4.2.4-sleep.patch 
Log Message:
- compile with crypto support on 64bit architectures (#239576)
- update sleep patch
Resolves: #239576


ntp-4.2.4p0-sleep.patch:

--- NEW FILE ntp-4.2.4p0-sleep.patch ---
--- ntp-4.2.4p0/include/ntp_stdlib.h.sleep	2006-12-28 13:03:05.000000000 +0100
+++ ntp-4.2.4p0/include/ntp_stdlib.h	2007-03-26 17:53:15.000000000 +0200
@@ -101,6 +101,7 @@
 extern	void	signal_no_reset P((int, RETSIGTYPE (*func)(int)));
 
 extern	void	getauthkeys 	P((const char *));
+extern	int	auth_agekeys_is_needed P((void));
 extern	void	auth_agekeys	P((void));
 extern	void	rereadkeys	P((void));
 
--- ntp-4.2.4p0/include/ntpd.h.sleep	2006-12-28 13:03:06.000000000 +0100
+++ ntp-4.2.4p0/include/ntpd.h	2007-03-26 17:53:15.000000000 +0200
@@ -118,8 +118,10 @@
 /* ntp_loopfilter.c */
 extern	void	init_loopfilter P((void));
 extern	int 	local_clock P((struct peer *, double));
-extern	void	adj_host_clock	P((void));
+extern	int	adj_host_clock_is_needed P((void));
+extern	void	adj_host_clock	P((int));
 extern	void	loop_config P((int, double));
+extern	int	huffpuff_enabled P((void));
 extern	void	huffpuff	P((void));
 extern	u_long	sys_clocktime;
 extern	u_long	sys_tai;
@@ -219,7 +221,8 @@
 /* ntp_timer.c */
 extern	void	init_timer	P((void));
 extern	void	reinit_timer	P((void));
-extern	void	timer		P((void));
+extern	int	when_next_event	P((void));
+extern	void	timer		P((int));
 extern	void	timer_clr_stats P((void));
 extern  void    timer_interfacetimeout P((u_long));
 extern  volatile int interface_interval;
--- ntp-4.2.4p0/libntp/authkeys.c.sleep	2004-02-25 06:58:03.000000000 +0100
+++ ntp-4.2.4p0/libntp/authkeys.c	2007-03-26 17:53:15.000000000 +0200
@@ -394,6 +394,24 @@
 	}
 }
 
+int auth_agekeys_is_needed() {
+	struct savekey *sk;
+	int i;
+
+	if (authnumkeys > 20)
+		return 1;
+
+	for (i = 0; i < HASHSIZE; i++) {
+		sk = key_hash[i];
+		while (sk != 0) {
+			if (sk->lifetime > 0)
+				return 1;
+			sk = sk->next;
+		}
+	}
+	return 0;
+}
+
 /*
  * auth_agekeys - delete keys whose lifetimes have expired
  */
--- ntp-4.2.4p0/ntpd/ntp_loopfilter.c.sleep	2007-03-26 17:53:15.000000000 +0200
+++ ntp-4.2.4p0/ntpd/ntp_loopfilter.c	2007-03-26 17:53:15.000000000 +0200
@@ -757,6 +757,10 @@
 #endif /* LOCKCLOCK */
 }
 
+int adj_host_clock_is_needed() {
+	return !(!ntp_enable || mode_ntpdate || (pll_control &&
+	    kern_enable));
+}
 
 /*
  * adj_host_clock - Called once every second to update the local clock.
@@ -766,7 +770,7 @@
  */
 void
 adj_host_clock(
-	void
+	int time_elapsed
 	)
 {
 	double	adjustment;
@@ -781,7 +785,8 @@
 	 * maximum error and the local clock driver will pick it up and
 	 * pass to the common refclock routines. Very elegant.
 	 */
-	sys_rootdispersion += clock_phi;
+	sys_rootdispersion += clock_phi * time_elapsed;
+	DPRINTF(2, ("loopfilter: %d\n", time_elapsed));
 
 #ifndef LOCKCLOCK
 	/*
@@ -841,6 +846,11 @@
 }
 
 
+int huffpuff_enabled()
+{
+	return sys_huffpuff != NULL;
+}
+
 /*
  * huff-n'-puff filter
  */
--- ntp-4.2.4p0/ntpd/ntpd.c.sleep	2007-03-26 17:53:15.000000000 +0200
+++ ntp-4.2.4p0/ntpd/ntpd.c	2007-03-26 18:06:34.000000000 +0200
@@ -188,8 +188,6 @@
 
 char const *progname;
 
-int was_alarmed;
-
 #ifdef DECL_SYSCALL
 /*
  * We put this here, since the argument profile is syscall-specific
@@ -443,6 +441,7 @@
 		msyslog(LOG_ERR, "set_process_priority: No way found to improve our priority");
 }
 
+#define TS_LAST_SIZE 2
 
 /*
  * Main program.  Initialize us, disconnect us from the tty if necessary,
@@ -455,6 +454,9 @@
 	)
 {
 	l_fp now;
+	l_fp ts_last[TS_LAST_SIZE];
+	unsigned int ts_last_index;
+	int time_elapsed;
 	struct recvbuf *rbuf;
 #ifdef _AIX			/* HMS: ifdef SIGDANGER? */
 	struct sigaction sa;
@@ -1014,7 +1016,11 @@
 #else /* normal I/O */
 
 	BLOCK_IO_AND_ALARM();
-	was_alarmed = 0;
+
+	for (ts_last_index = 0; ts_last_index < TS_LAST_SIZE; ts_last_index++)
+		L_CLR(&ts_last[ts_last_index]);
+	time_elapsed = 0;
+
 	for (;;)
 	{
 # if !defined(HAVE_SIGNALED_IO) 
@@ -1025,39 +1031,58 @@
 		int nfound;
 # endif
 
-		if (alarm_flag) 	/* alarmed? */
-		{
-			was_alarmed = 1;
-			alarm_flag = 0;
-		}
-
-		if (!was_alarmed && has_full_recv_buffer() == ISC_FALSE)
+		if (has_full_recv_buffer() == ISC_FALSE)
 		{
 			/*
 			 * Nothing to do.  Wait for something.
 			 */
 # ifndef HAVE_SIGNALED_IO
+			extern l_fp timer_base;
+			l_fp ts, ts2, ts3;
+			double d;
+
 			rdfdes = activefds;
-#  if defined(VMS) || defined(SYS_VXWORKS)
-			/* make select() wake up after one second */
-			{
+			ts2 = timer_base;
+			get_systime(&ts);
+			ts3 = ts;
+			L_SUB(&ts3, &ts_last[ts_last_index]);
+
+			/* don't call when_next_event() too often */
+			if (ts3.l_ui)
+				ts2.l_ui += when_next_event();
+			else
+				ts2.l_ui += 1;
+
+			L_SUB(&ts2, &ts);
+			LFPTOD(&ts2, d);
+			DPRINTF(2, ("next in %f\n", d));
+			if (d >= 0.0) {
 				struct timeval t1;
 
-				t1.tv_sec = 1; t1.tv_usec = 0;
+				/* shoot 1ms over */
+				d += 0.001;
+				t1.tv_sec = floor(d);
+				t1.tv_usec = (d - t1.tv_sec) * 1000000;
 				nfound = select(maxactivefd+1, &rdfdes, (fd_set *)0,
 						(fd_set *)0, &t1);
-			}
-#  else
-			nfound = select(maxactivefd+1, &rdfdes, (fd_set *)0,
-					(fd_set *)0, (struct timeval *)0);
-#  endif /* VMS */
-			if (nfound > 0)
-			{
-				l_fp ts;
-
 				get_systime(&ts);
+			} else
+				nfound = 0;
+
+			ts2 = ts;
+			L_SUB(&ts2, &timer_base);
+			time_elapsed += ts2.l_ui;
+			timer_base.l_ui += ts2.l_ui;
+#ifdef DEBUG 
+			LFPTOD(&ts2, d);
+			DPRINTF(2, ("elapsed %f\n", d));
+#endif
 
+			if (nfound > 0)
+			{
 				(void)input_handler(&ts);
+				ts_last[ts_last_index] = ts;
+				ts_last_index = (ts_last_index + 1) % TS_LAST_SIZE;
 			}
 			else if (nfound == -1 && errno != EINTR)
 				netsyslog(LOG_ERR, "select() error: %m");
@@ -1069,22 +1094,17 @@
                         
 			wait_for_signal();
 # endif /* HAVE_SIGNALED_IO */
-			if (alarm_flag) 	/* alarmed? */
-			{
-				was_alarmed = 1;
-				alarm_flag = 0;
-			}
 		}
 
-		if (was_alarmed)
+		if (time_elapsed)
 		{
 			UNBLOCK_IO_AND_ALARM();
 			/*
 			 * Out here, signals are unblocked.  Call timer routine
 			 * to process expiry.
 			 */
-			timer();
-			was_alarmed = 0;
+			timer(time_elapsed);
+			time_elapsed = 0;
                         BLOCK_IO_AND_ALARM();
 		}
 
--- ntp-4.2.4p0/ntpd/ntp_timer.c.sleep	2006-12-28 13:03:34.000000000 +0100
+++ ntp-4.2.4p0/ntpd/ntp_timer.c	2007-03-26 17:53:15.000000000 +0200
@@ -63,6 +63,7 @@
 #define HOUR	(60*60)
 
 u_long current_time;
+l_fp timer_base;
 
 /*
  * Stats.  Number of overflows and number of calls to transmit().
@@ -116,6 +117,8 @@
 	itimer.it_interval.tv_nsec = 0;
 	timer_settime(ntpd_timerid, 0 /*!TIMER_ABSTIME*/, &itimer, NULL);
 #  else
+	get_systime(&timer_base);
+	return;
 	getitimer(ITIMER_REAL, &itimer);
 	if (itimer.it_value.tv_sec < 0 || itimer.it_value.tv_sec > (1<<EVENT_TIMEOUT)) {
 		itimer.it_value.tv_sec = (1<<EVENT_TIMEOUT);
@@ -160,6 +163,8 @@
 	timer_timereset = 0;
 
 #if !defined(SYS_WINNT)
+	get_systime(&timer_base);
+	return;
 	/*
 	 * Set up the alarm interrupt.	The first comes 2**EVENT_TIMEOUT
 	 * seconds from now and they continue on every 2**EVENT_TIMEOUT
@@ -252,11 +257,51 @@
 }
 #endif
 
+int when_next_event() {
+	register struct peer *peer, *next_peer;
+	u_int n;
+	int next = current_time + HOUR;
+
+	if (adj_host_clock_is_needed())
+		return 1;
+	for (n = 0; n < NTP_HASH_SIZE; n++) {
+		for (peer = peer_hash[n]; peer != 0; peer = next_peer) {
+			next_peer = peer->next;
+#ifdef REFCLOCK
+			if (peer->flags & FLAG_REFCLOCK)
+				return 1;
+#endif /* REFCLOCK */
+			if (peer->action && peer->nextaction < next)
+				next = peer->nextaction;
+			if (peer->nextdate < next)
+				next = peer->nextdate;
+		}
+	}
+
+	if (auth_agekeys_is_needed() && keys_timer < next)
+		next = keys_timer;
+	if (huffpuff_enabled() && huffpuff_timer < next)
+		next = huffpuff_timer;
+#ifdef OPENSSL
+	if (revoke_timer < next)
+		next = revoke_timer;
+#endif /* OPENSSL */
+	if (interface_interval && interface_timer < next)
+		next = interface_timer;
+	if (stats_timer < next)
+		next = stats_timer;
+
+	next -= current_time;
+	if (next <= 0)
+		next = 1;
+	return next;
+}
+
 /*
  * timer - dispatch anyone who needs to be
  */
 void
-timer(void)
+timer(int time_elapsed)
 {
 	register struct peer *peer, *next_peer;
 #ifdef OPENSSL
@@ -264,14 +309,14 @@
 #endif /* OPENSSL */
 	u_int n;
 
-	current_time += (1<<EVENT_TIMEOUT);
+	current_time += time_elapsed;
 
 	/*
 	 * Adjustment timeout first.
 	 */
 	if (adjust_timer <= current_time) {
-		adjust_timer += 1;
-		adj_host_clock();
+		adj_host_clock(current_time - adjust_timer + 1);
+		adjust_timer = current_time + 1;
 		kod_proto();
 #ifdef REFCLOCK
 		for (n = 0; n < NTP_HASH_SIZE; n++) {


Index: ntp.spec
===================================================================
RCS file: /cvs/pkgs/rpms/ntp/devel/ntp.spec,v
retrieving revision 1.65
retrieving revision 1.66
diff -u -r1.65 -r1.66
--- ntp.spec	7 Mar 2007 18:35:41 -0000	1.65
+++ ntp.spec	9 May 2007 16:45:01 -0000	1.66
@@ -3,7 +3,7 @@
 Summary: Synchronizes system time using the Network Time Protocol (NTP)
 Name: ntp
 Version: 4.2.4p0
-Release: 1%{?dist}
+Release: 2%{?dist}
 License: distributable
 Group: System Environment/Daemons
 Source0: http://www.eecis.udel.edu/~ntp/ntp_spool/ntp4/ntp-4.2/ntp-%{version}.tar.gz
@@ -28,7 +28,7 @@
 Patch12: ntp-4.2.4-sprintf.patch
 Patch13: ntp-4.2.4-autoopts.patch
 Patch14: ntp-4.2.4p0-mlock.patch
-Patch17: ntp-4.2.4-sleep.patch
+Patch17: ntp-4.2.4p0-sleep.patch
 
 URL: http://www.ntp.org
 Requires(pre): shadow-utils 
@@ -77,6 +77,7 @@
 fi
 %configure \
 	--sysconfdir=%{_sysconfdir}/ntp \
+	--with-openssl-libdir=%{_libdir} \
 	--enable-all-clocks --enable-parse-clocks \
 	--enable-linuxcaps
 make
@@ -175,6 +176,10 @@
 
 
 %changelog
+* Wed May 09 2007 Miroslav Lichvar <mlichvar at redhat.com> 4.2.4p0-2
+- compile with crypto support on 64bit architectures (#239576)
+- update sleep patch
+
 * Wed Mar 07 2007 Miroslav Lichvar <mlichvar at redhat.com> 4.2.4p0-1
 - update to 4.2.4p0
 - fix init script


--- ntp-4.2.4-sleep.patch DELETED ---




More information about the fedora-extras-commits mailing list