Deleted Added
full compact
ntpd.c (82498) ntpd.c (106163)
1/*
2 * ntpd.c - main program for the fixed point NTP daemon
3 */
4
5#ifdef HAVE_CONFIG_H
6# include <config.h>
7#endif
8
1/*
2 * ntpd.c - main program for the fixed point NTP daemon
3 */
4
5#ifdef HAVE_CONFIG_H
6# include <config.h>
7#endif
8
9#include "ntp_machine.h"
9#include "ntpd.h"
10#include "ntp_io.h"
11#include "ntp_stdlib.h"
12
13#ifdef HAVE_UNISTD_H
14# include <unistd.h>
15#endif
16#ifdef HAVE_SYS_STAT_H
17# include <sys/stat.h>
18#endif
19#include <stdio.h>
20#ifndef SYS_WINNT
21# if !defined(VMS) /*wjm*/
10#include "ntpd.h"
11#include "ntp_io.h"
12#include "ntp_stdlib.h"
13
14#ifdef HAVE_UNISTD_H
15# include <unistd.h>
16#endif
17#ifdef HAVE_SYS_STAT_H
18# include <sys/stat.h>
19#endif
20#include <stdio.h>
21#ifndef SYS_WINNT
22# if !defined(VMS) /*wjm*/
22# include <sys/param.h>
23# ifdef HAVE_SYS_PARAM_H
24# include <sys/param.h>
25# endif
23# endif /* VMS */
26# endif /* VMS */
24# include <sys/signal.h>
27# ifdef HAVE_SYS_SIGNAL_H
28# include <sys/signal.h>
29# else
30# include <signal.h>
31# endif
25# ifdef HAVE_SYS_IOCTL_H
26# include <sys/ioctl.h>
27# endif /* HAVE_SYS_IOCTL_H */
28# ifdef HAVE_SYS_RESOURCE_H
29# include <sys/resource.h>
30# endif /* HAVE_SYS_RESOURCE_H */
31#else
32# include <signal.h>

--- 80 unchanged lines hidden (view full) ---

113#endif /* SYS_WINNT */
114
115#if defined SYS_WINNT
116/* handles for various threads, process, and objects */
117HANDLE ResolverThreadHandle = NULL;
118/* variables used to inform the Service Control Manager of our current state */
119SERVICE_STATUS ssStatus;
120SERVICE_STATUS_HANDLE sshStatusHandle;
32# ifdef HAVE_SYS_IOCTL_H
33# include <sys/ioctl.h>
34# endif /* HAVE_SYS_IOCTL_H */
35# ifdef HAVE_SYS_RESOURCE_H
36# include <sys/resource.h>
37# endif /* HAVE_SYS_RESOURCE_H */
38#else
39# include <signal.h>

--- 80 unchanged lines hidden (view full) ---

120#endif /* SYS_WINNT */
121
122#if defined SYS_WINNT
123/* handles for various threads, process, and objects */
124HANDLE ResolverThreadHandle = NULL;
125/* variables used to inform the Service Control Manager of our current state */
126SERVICE_STATUS ssStatus;
127SERVICE_STATUS_HANDLE sshStatusHandle;
121HANDLE WaitHandles[2] = { NULL, NULL };
128HANDLE WaitHandles[3] = { NULL, NULL, NULL };
122char szMsgPath[255];
123static BOOL WINAPI OnConsoleEvent(DWORD dwCtrlType);
124#endif /* SYS_WINNT */
125
126/*
127 * Scheduling priority we run at
128 */
129#define NTPD_PRIO (-12)

--- 219 unchanged lines hidden (view full) ---

349 uv = umask(0);
350 if(uv)
351 (void) umask(uv);
352 else
353 (void) umask(022);
354 }
355#endif
356
129char szMsgPath[255];
130static BOOL WINAPI OnConsoleEvent(DWORD dwCtrlType);
131#endif /* SYS_WINNT */
132
133/*
134 * Scheduling priority we run at
135 */
136#define NTPD_PRIO (-12)

--- 219 unchanged lines hidden (view full) ---

356 uv = umask(0);
357 if(uv)
358 (void) umask(uv);
359 else
360 (void) umask(022);
361 }
362#endif
363
357#ifdef HAVE_GETUID
364#if defined(HAVE_GETUID) && !defined(MPE) /* MPE lacks the concept of root */
358 {
359 uid_t uid;
360
361 uid = getuid();
362 if (uid)
363 {
364 msyslog(LOG_ERR, "ntpd: must be run as root, not uid %ld", (long)uid);
365 exit(1);

--- 419 unchanged lines hidden (view full) ---

785 * have select() time out after one second.
786 * System clock updates really aren't time-critical,
787 * and - lacking a hardware reference clock - I have
788 * yet to learn about anything else that is.
789 */
790#if defined(HAVE_IO_COMPLETION_PORT)
791 WaitHandles[0] = CreateEvent(NULL, FALSE, FALSE, NULL); /* exit reques */
792 WaitHandles[1] = get_timer_handle();
365 {
366 uid_t uid;
367
368 uid = getuid();
369 if (uid)
370 {
371 msyslog(LOG_ERR, "ntpd: must be run as root, not uid %ld", (long)uid);
372 exit(1);

--- 419 unchanged lines hidden (view full) ---

792 * have select() time out after one second.
793 * System clock updates really aren't time-critical,
794 * and - lacking a hardware reference clock - I have
795 * yet to learn about anything else that is.
796 */
797#if defined(HAVE_IO_COMPLETION_PORT)
798 WaitHandles[0] = CreateEvent(NULL, FALSE, FALSE, NULL); /* exit reques */
799 WaitHandles[1] = get_timer_handle();
800 WaitHandles[2] = get_io_event();
793
794 for (;;) {
795 DWORD Index = WaitForMultipleObjectsEx(sizeof(WaitHandles)/sizeof(WaitHandles[0]), WaitHandles, FALSE, 1000, MWMO_ALERTABLE);
796 switch (Index) {
797 case WAIT_OBJECT_0 + 0 : /* exit request */
798 exit(0);
799 break;
800
801 case WAIT_OBJECT_0 + 1 : /* timer */
802 timer();
803 break;
801
802 for (;;) {
803 DWORD Index = WaitForMultipleObjectsEx(sizeof(WaitHandles)/sizeof(WaitHandles[0]), WaitHandles, FALSE, 1000, MWMO_ALERTABLE);
804 switch (Index) {
805 case WAIT_OBJECT_0 + 0 : /* exit request */
806 exit(0);
807 break;
808
809 case WAIT_OBJECT_0 + 1 : /* timer */
810 timer();
811 break;
804 case WAIT_OBJECT_0 + 2 : { /* Windows message */
812
813 case WAIT_OBJECT_0 + 2 : /* Io event */
814# ifdef DEBUG
815 if ( debug > 3 )
816 {
817 printf( "IoEvent occurred\n" );
818 }
819# endif
820 break;
821
822# if 1
823 /*
824 * FIXME: According to the documentation for WaitForMultipleObjectsEx
825 * this is not possible. This may be a vestigial from when this was
826 * MsgWaitForMultipleObjects, maybe it should be removed?
827 */
828 case WAIT_OBJECT_0 + 3 : /* windows message */
829 {
805 MSG msg;
830 MSG msg;
806 while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
807 if (msg.message == WM_QUIT) {
808 exit(0);
831 while ( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) )
832 {
833 if ( msg.message == WM_QUIT )
834 {
835 exit( 0 );
809 }
836 }
810 DispatchMessage(&msg);
837 DispatchMessage( &msg );
811 }
812 }
813 break;
838 }
839 }
840 break;
841# endif
814
815 case WAIT_IO_COMPLETION : /* loop */
816 case WAIT_TIMEOUT :
817 break;
818
819 } /* switch */
820 rbuflist = getrecvbufs(); /* get received buffers */
821

--- 313 unchanged lines hidden ---
842
843 case WAIT_IO_COMPLETION : /* loop */
844 case WAIT_TIMEOUT :
845 break;
846
847 } /* switch */
848 rbuflist = getrecvbufs(); /* get received buffers */
849

--- 313 unchanged lines hidden ---