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

Harlan Stenn stenn at whimsy.udel.edu
Wed Jun 27 04:19:35 UTC 2007


#### ChangeSet ####
2007-06-23 08:47:07-04:00, mayer at pogo.udel.edu 
  Added Bug #863

==== ChangeLog ====
2007-06-23 08:46:51-04:00, mayer at pogo.udel.edu +2 -0
  Added Bug #863

--- 1.20/ChangeLog	2007-06-20 04:07:25 -04:00
+++ 1.21/ChangeLog	2007-06-23 08:46:51 -04:00
@@ -1,3 +1,5 @@
+* {Bug 863] unable to stop ntpd on Windows as the handle reference for events
+	    changed
 (4.2.4p2) Released by Harlan Stenn <stenn at ntp.org>
 * [Bug 854] Broadcast address was not correctly set for interface addresses
 * [Bug 829] reduce syslog noise, while there fix Enabled/Disable logging

#### ChangeSet ####
2007-06-23 08:42:58-04:00, mayer at pogo.udel.edu 
  Bug #863 Unable to stop ntpd because the handle index changed

==== ports/winnt/include/ntp_iocompletionport.h ====
2007-06-23 08:42:41-04:00, mayer at pogo.udel.edu +3 -0
  Bug #863 Unable to stop ntpd because the handle index changed

--- 1.12/ports/winnt/include/ntp_iocompletionport.h	2006-01-06 16:47:39 -05:00
+++ 1.13/ports/winnt/include/ntp_iocompletionport.h	2007-06-23 08:42:41 -04:00
@@ -1,6 +1,7 @@
 #if !defined __ntp_iocompletionport_h
 # define __ntp_iocompletionport_h
 
+#include "ntp_fp.h"
 #include "ntp.h"
 
 # if defined(HAVE_IO_COMPLETION_PORT)
@@ -18,6 +19,8 @@ extern	int	io_completion_port_add_socket
 extern	DWORD	io_completion_port_sendto (struct interface *, struct pkt *, int, struct sockaddr_storage*);
 
 extern	HANDLE get_io_event (void);
+
+extern HANDLE get_exit_event(void);		/* Handle of the exit event */
 
 int GetReceivedBuffers(void);
 

==== ports/winnt/ntpd/ntp_iocompletionport.c ====
2007-06-23 08:42:41-04:00, mayer at pogo.udel.edu +15 -1
  Bug #863 Unable to stop ntpd because the handle index changed

--- 1.22/ports/winnt/ntpd/ntp_iocompletionport.c	2007-05-24 08:08:03 -04:00
+++ 1.23/ports/winnt/ntpd/ntp_iocompletionport.c	2007-06-23 08:42:41 -04:00
@@ -57,6 +57,7 @@ static HANDLE hHeapHandle = NULL;
 static HANDLE hIoCompletionPort = NULL;
 
 static HANDLE WaitableIoEventHandle = NULL;
+static HANDLE WaitableExitEventHandle = NULL;
 
 #define MAXHANDLES 3
 HANDLE WaitHandles[MAXHANDLES] = { NULL, NULL, NULL };
@@ -120,6 +121,11 @@ get_io_event()
 {
 	return( WaitableIoEventHandle );
 }
+HANDLE
+get_exit_event()
+{
+	return( WaitableExitEventHandle );
+}
 
 /*  This function will add an entry to the I/O completion port
  *  that will signal the I/O thread to exit (gracefully)
@@ -242,6 +248,14 @@ init_io_completion_port(
 		"Can't create I/O event handle: %m - another process may be running - EXITING");
 		exit(1);
 	}
+	/* Create the event used to signal an exit event
+	 */
+	WaitableExitEventHandle = CreateEvent(NULL, FALSE, FALSE, "WaitableExitEventHandle");
+	if (WaitableExitEventHandle == NULL) {
+		msyslog(LOG_ERR,
+		"Can't create exit event handle: %m - another process may be running - EXITING");
+		exit(1);
+	}
 
 	/* Create the IO completion port
 	 */
@@ -255,7 +269,7 @@ init_io_completion_port(
 	 * Initialize the Wait Handles
 	 */
 	WaitHandles[0] = get_io_event();
-	WaitHandles[1] = CreateEvent(NULL, FALSE, FALSE, "WaitHandles0"); /* exit request */
+	WaitHandles[1] = get_exit_event(); /* exit request */
 	WaitHandles[2] = get_timer_handle();
 
 	/* Have one thread servicing I/O - there were 4, but this would 

==== ports/winnt/ntpd/ntservice.c ====
2007-06-23 08:42:41-04:00, mayer at pogo.udel.edu +9 -5
  Bug #863 Unable to stop ntpd because the handle index changed

--- 1.8/ports/winnt/ntpd/ntservice.c	2006-08-15 13:29:47 -04:00
+++ 1.9/ports/winnt/ntpd/ntservice.c	2007-06-23 08:42:41 -04:00
@@ -25,6 +25,7 @@
 #include "syslog.h"
 #include "ntservice.h"
 #include "clockstuff.h"
+#include "ntp_iocompletionport.h"
 #ifdef DEBUG
 #include <crtdbg.h>
 #endif
@@ -36,7 +37,6 @@ static char ConsoleTitle[128];
 static int glb_argc;
 static char **glb_argv;
 HANDLE hServDoneEvent = NULL;
-extern HANDLE WaitHandles[3];
 extern volatile int debug;
 extern char *progname;
 
@@ -172,13 +172,15 @@ ntservice_exit( void )
 void
 ServiceControl(DWORD dwCtrlCode) {
 	/* Handle the requested control code */
+	HANDLE exitEvent = get_exit_event();
+
 	switch(dwCtrlCode) {
 
 	case SERVICE_CONTROL_SHUTDOWN:
 	case SERVICE_CONTROL_STOP:
 		UpdateSCM(SERVICE_STOP_PENDING);
-		if (WaitHandles[0] != NULL) {
-			SetEvent(WaitHandles[0]);
+		if (exitEvent != NULL) {
+			SetEvent(exitEvent);
 			Sleep( 100 );  //##++
 		}
 		return;
@@ -225,6 +227,8 @@ OnConsoleEvent(  
 	DWORD dwCtrlType
 	)
 {
+	HANDLE exitEvent = get_exit_event();
+
 	switch (dwCtrlType) {
 #ifdef DEBUG
 		case CTRL_BREAK_EVENT :
@@ -244,8 +248,8 @@ OnConsoleEvent(  
 		case CTRL_C_EVENT  :
 		case CTRL_CLOSE_EVENT :
 		case CTRL_SHUTDOWN_EVENT :
-			if (WaitHandles[0] != NULL) {
-				SetEvent(WaitHandles[0]);
+			if (exitEvent != NULL) {
+				SetEvent(exitEvent);
 				Sleep( 100 );  //##++
 			}
 		break;


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