2 * ntpd.c - main program for the fixed point NTP daemon
9 #include "ntp_machine.h"
12 #include "ntp_stdlib.h"
13 #include <ntp_random.h>
17 # include "ntpdsim-opts.h"
19 # include "ntpd-opts.h"
25 #ifdef HAVE_SYS_STAT_H
26 # include <sys/stat.h>
30 # if !defined(VMS) /*wjm*/
31 # ifdef HAVE_SYS_PARAM_H
32 # include <sys/param.h>
35 # ifdef HAVE_SYS_SIGNAL_H
36 # include <sys/signal.h>
40 # ifdef HAVE_SYS_IOCTL_H
41 # include <sys/ioctl.h>
42 # endif /* HAVE_SYS_IOCTL_H */
43 # ifdef HAVE_SYS_RESOURCE_H
44 # include <sys/resource.h>
45 # endif /* HAVE_SYS_RESOURCE_H */
50 # include <clockstuff.h>
51 #include "ntp_iocompletionport.h"
52 #endif /* SYS_WINNT */
53 #if defined(HAVE_RTPRIO)
54 # ifdef HAVE_SYS_RESOURCE_H
55 # include <sys/resource.h>
57 # ifdef HAVE_SYS_LOCK_H
58 # include <sys/lock.h>
60 # include <sys/rtprio.h>
63 # ifdef HAVE_SYS_LOCK_H
64 # include <sys/lock.h>
68 #if defined(HAVE_SCHED_SETSCHEDULER)
72 # ifdef HAVE_SYS_SCHED_H
73 # include <sys/sched.h>
77 #if defined(HAVE_SYS_MMAN_H)
78 # include <sys/mman.h>
86 # include <apollo/base.h>
87 #endif /* SYS_DOMAINOS */
90 #include "ntp_cmdargs.h"
92 #if 0 /* HMS: I don't think we need this. 961223 */
95 # include <sys/mman.h>
97 # include <sys/lock.h>
107 # include <sys/ci/ciioctl.h>
114 #ifdef HAVE_LINUX_CAPABILITIES
115 # include <sys/capability.h>
116 # include <sys/prctl.h>
121 * Signals we catch for debugging. If not debugging we ignore them.
123 #define MOREDEBUGSIG SIGUSR1
124 #define LESSDEBUGSIG SIGUSR2
127 * Signals which terminate us gracefully.
130 # define SIGDIE1 SIGHUP
131 # define SIGDIE3 SIGQUIT
132 # define SIGDIE2 SIGINT
133 # define SIGDIE4 SIGTERM
134 #endif /* SYS_WINNT */
136 #ifdef HAVE_DNSREGISTRATION
142 * Scheduling priority we run at
144 #define NTPD_PRIO (-12)
146 int priority_done = 2; /* 0 - Set priority */
147 /* 1 - priority is OK where it is */
148 /* 2 - Don't set priority */
149 /* 1 and 2 are pretty much the same */
155 volatile int debug = 0; /* No debugging by default */
158 int listen_to_virtual_ips = 1;
159 const char *specific_interface = NULL; /* interface name or IP address to bind to */
162 * No-fork flag. If set, we do not become a background daemon.
164 int nofork = 0; /* Fork by default */
168 char *user = NULL; /* User to switch to */
169 char *group = NULL; /* group to switch to */
170 char *chrootdir = NULL; /* directory to chroot to */
176 #endif /* HAVE_DROPROOT */
179 * Initializing flag. All async routines watch this and only do their
180 * thing when it is clear.
185 * Version declaration
187 extern const char *Version;
189 char const *progname;
195 * We put this here, since the argument profile is syscall-specific
197 extern int syscall P((int, ...));
198 #endif /* DECL_SYSCALL */
202 static RETSIGTYPE finish P((int));
207 static RETSIGTYPE moredebug P((int));
208 static RETSIGTYPE lessdebug P((int));
210 #else /* not DEBUG */
211 static RETSIGTYPE no_debug P((int));
212 #endif /* not DEBUG */
214 int ntpdmain P((int, char **));
215 static void set_process_priority P((void));
216 static void init_logging P((char const *));
217 static void setup_logfile P((void));
220 * Initialize the logging
223 init_logging(char const *name)
228 * Logging. This may actually work on the gizmo board. Find a name
229 * to log with by using the basename
231 cp = strrchr(name, '/');
240 openlog(cp, LOG_PID);
241 # else /* LOG_DAEMON */
244 # define LOG_NTP LOG_DAEMON
246 openlog(cp, LOG_PID | LOG_NDELAY, LOG_NTP);
249 setlogmask(LOG_UPTO(LOG_DEBUG));
252 setlogmask(LOG_UPTO(LOG_DEBUG)); /* @@@ was INFO */
253 # endif /* LOG_DAEMON */
254 #endif /* !SYS_WINNT && !VMS */
256 NLOG(NLOG_SYSINFO) /* conditional if clause for conditional syslog */
257 msyslog(LOG_NOTICE, "%s", Version);
262 * See if we should redirect the logfile
270 if (HAVE_OPT( LOGFILE )) {
271 const char *my_optarg = OPT_ARG( LOGFILE );
274 if(strcmp(my_optarg, "stderr") == 0)
276 else if(strcmp(my_optarg, "stdout") == 0)
279 new_file = fopen(my_optarg, "a");
280 if (new_file != NULL) {
282 msyslog(LOG_NOTICE, "logging to file %s", my_optarg);
283 if (syslog_file != NULL &&
284 fileno(syslog_file) != fileno(new_file))
285 (void)fclose(syslog_file);
287 syslog_file = new_file;
292 "Cannot open log file %s",
304 return ntpsim(argc, argv);
307 #ifdef NO_MAIN_ALLOWED
308 CALL(ntpd,"ntpd",ntpdmain);
317 return ntpdmain(argc, argv);
319 #endif /* SYS_WINNT */
320 #endif /* NO_MAIN_ALLOWED */
325 * OK. AIX is different than solaris in how it implements plock().
326 * If you do NOT adjust the stack limit, you will get the MAXIMUM
327 * stack size allocated and PINNED with you program. To check the
328 * value, use ulimit -a.
330 * To fix this, we create an automatic variable and set our stack limit
331 * to that PLUS 32KB of extra space (we need some headroom).
333 * This subroutine gets the stack address.
335 * Grover Davidson and Matt Ladendorf
346 * Signal handler for SIGDANGER.
349 catch_danger(int signo)
351 msyslog(LOG_INFO, "ntpd: setpgid(): %m");
352 /* Make the system believe we'll free something, but don't do it! */
358 * Set the process priority
361 set_process_priority(void)
366 msyslog(LOG_DEBUG, "set_process_priority: %s: priority_done is <%d>",
368 ? "Leave priority alone"
369 : "Attempt to set priority"
375 priority_done += NT_set_process_priority();
378 #if defined(HAVE_SCHED_SETSCHEDULER)
379 if (!priority_done) {
380 extern int config_priority_override, config_priority;
382 struct sched_param sched;
384 pmax = sched_get_priority_max(SCHED_FIFO);
385 sched.sched_priority = pmax;
386 if ( config_priority_override ) {
387 pmin = sched_get_priority_min(SCHED_FIFO);
388 if ( config_priority > pmax )
389 sched.sched_priority = pmax;
390 else if ( config_priority < pmin )
391 sched.sched_priority = pmin;
393 sched.sched_priority = config_priority;
395 if ( sched_setscheduler(0, SCHED_FIFO, &sched) == -1 )
396 msyslog(LOG_ERR, "sched_setscheduler(): %m");
400 #endif /* HAVE_SCHED_SETSCHEDULER */
401 #if defined(HAVE_RTPRIO)
403 if (!priority_done) {
406 srtp.type = RTP_PRIO_REALTIME; /* was: RTP_PRIO_NORMAL */
407 srtp.prio = 0; /* 0 (hi) -> RTP_PRIO_MAX (31,lo) */
409 if (rtprio(RTP_SET, getpid(), &srtp) < 0)
410 msyslog(LOG_ERR, "rtprio() error: %m");
414 # else /* not RTP_SET */
415 if (!priority_done) {
416 if (rtprio(0, 120) < 0)
417 msyslog(LOG_ERR, "rtprio() error: %m");
421 # endif /* not RTP_SET */
422 #endif /* HAVE_RTPRIO */
423 #if defined(NTPD_PRIO) && NTPD_PRIO != 0
424 # ifdef HAVE_ATT_NICE
425 if (!priority_done) {
427 if (-1 == nice (NTPD_PRIO) && errno != 0)
428 msyslog(LOG_ERR, "nice() error: %m");
432 # endif /* HAVE_ATT_NICE */
433 # ifdef HAVE_BSD_NICE
434 if (!priority_done) {
435 if (-1 == setpriority(PRIO_PROCESS, 0, NTPD_PRIO))
436 msyslog(LOG_ERR, "setpriority() error: %m");
440 # endif /* HAVE_BSD_NICE */
441 #endif /* NTPD_PRIO && NTPD_PRIO != 0 */
443 msyslog(LOG_ERR, "set_process_priority: No way found to improve our priority");
448 * Main program. Initialize us, disconnect us from the tty if necessary,
449 * and loop waiting for I/O and/or timer expiries.
458 struct recvbuf *rbuf;
459 #ifdef _AIX /* HMS: ifdef SIGDANGER? */
465 initializing = 1; /* mark that we are initializing */
468 int optct = optionProcess(
479 /* HMS: is this lame? Should we process -l first? */
481 init_logging(progname); /* Open the log file */
495 #if defined(HAVE_GETUID) && !defined(MPE) /* MPE lacks the concept of root */
502 msyslog(LOG_ERR, "ntpd: must be run as root, not uid %ld", (long)uid);
503 printf("must be run as root, not uid %ld", (long)uid);
510 if ((SSLeay() ^ OPENSSL_VERSION_NUMBER) & ~0xff0L) {
512 "ntpd: OpenSSL version mismatch. Built against %lx, you have %lx\n",
513 OPENSSL_VERSION_NUMBER, SSLeay());
518 /* getstartup(argc, argv); / * startup configuration, may set debug */
521 debug = DESC(DEBUG_LEVEL).optOccCt;
523 printf("%s\n", Version);
527 * Enable the Multi-Media Timer for Windows?
530 if (HAVE_OPT( MODIFYMMTIMER ))
531 set_mm_timer(MM_TIMER_HIRES);
534 if (HAVE_OPT( NOFORK ) || HAVE_OPT( QUIT ))
537 if (HAVE_OPT( NOVIRTUALIPS ))
538 listen_to_virtual_ips = 0;
540 if (HAVE_OPT( INTERFACE )) {
542 int ifacect = STACKCT_OPT( INTERFACE );
543 char** ifaces = STACKLST_OPT( INTERFACE );
545 /* malloc space for the array of names */
546 while (ifacect-- > 0) {
547 next_iface = *ifaces++;
550 specific_interface = OPT_ARG( INTERFACE );
554 if (HAVE_OPT( NICE ))
557 #if defined(HAVE_SCHED_SETSCHEDULER)
558 if (HAVE_OPT( PRIORITY )) {
559 config_priority = OPT_VALUE_PRIORITY;
560 config_priority_override = 1;
567 * Initialize the time structures and variables
575 * Initialize random generator and public key pair
579 ntp_srandom((int)(now.l_i * now.l_uf));
581 #ifdef HAVE_DNSREGISTRATION
582 /* HMS: does this have to happen this early? */
583 msyslog(LOG_INFO, "Attemping to register mDNS");
584 if ( DNSServiceRegister (&mdns, 0, 0, NULL, "_ntp._udp", NULL, NULL, htons(NTP_PORT), 0, NULL, NULL, NULL) != kDNSServiceErr_NoError ) {
585 msyslog(LOG_ERR, "Unable to register mDNS");
592 * Detach us from the terminal. May need an #ifndef GIZMO.
603 # else /* not HAVE_DAEMON */
604 if (fork()) /* HMS: What about a -1? */
608 #if !defined(F_CLOSEM)
611 #endif /* not F_CLOSEM */
613 #if defined(F_CLOSEM)
615 * From 'Writing Reliable AIX Daemons,' SG24-4946-00,
616 * by Eric Agar (saves us from doing 32767 system
619 if (fcntl(0, F_CLOSEM, 0) == -1)
620 msyslog(LOG_ERR, "ntpd: failed to close open files(): %m");
621 #else /* not F_CLOSEM */
623 # if defined(HAVE_SYSCONF) && defined(_SC_OPEN_MAX)
624 max_fd = sysconf(_SC_OPEN_MAX);
625 # else /* HAVE_SYSCONF && _SC_OPEN_MAX */
626 max_fd = getdtablesize();
627 # endif /* HAVE_SYSCONF && _SC_OPEN_MAX */
628 for (s = 0; s < max_fd; s++)
629 (void) close((int)s);
630 #endif /* not F_CLOSEM */
639 proc2_$who_am_i(&puid);
640 proc2_$make_server(&puid, &st);
642 #endif /* SYS_DOMAINOS */
643 #if defined(HAVE_SETPGID) || defined(HAVE_SETSID)
645 if (setsid() == (pid_t)-1)
646 msyslog(LOG_ERR, "ntpd: setsid(): %m");
648 if (setpgid(0, 0) == -1)
649 msyslog(LOG_ERR, "ntpd: setpgid(): %m");
651 #else /* HAVE_SETPGID || HAVE_SETSID */
653 # if defined(TIOCNOTTY)
656 fid = open("/dev/tty", 2);
659 (void) ioctl(fid, (u_long) TIOCNOTTY, (char *) 0);
662 # endif /* defined(TIOCNOTTY) */
663 # ifdef HAVE_SETPGRP_0
665 # else /* HAVE_SETPGRP_0 */
666 (void) setpgrp(0, getpid());
667 # endif /* HAVE_SETPGRP_0 */
669 #endif /* HAVE_SETPGID || HAVE_SETSID */
671 /* Don't get killed by low-on-memory signal. */
672 sa.sa_handler = catch_danger;
673 sigemptyset(&sa.sa_mask);
674 sa.sa_flags = SA_RESTART;
676 (void) sigaction(SIGDANGER, &sa, NULL);
679 # endif /* not HAVE_DAEMON */
680 # endif /* SYS_WINNT */
682 # endif /* NODETACH */
685 setup_logfile(); /* We lost any redirect when we daemonized */
689 * SCO OpenServer's system clock offers much more precise timekeeping
690 * on the base CPU than the other CPUs (for multiprocessor systems),
691 * so we must lock to the base CPU.
694 int fd = open("/dev/at1", O_RDONLY);
697 if (ioctl(fd, ACPU_LOCK, &zero) < 0)
698 msyslog(LOG_ERR, "cannot lock to base CPU: %m");
701 * If we can't open the device, this probably just isn't
702 * a multiprocessor system, so we're A-OK.
707 #if defined(HAVE_MLOCKALL) && defined(MCL_CURRENT) && defined(MCL_FUTURE)
708 # ifdef HAVE_SETRLIMIT
710 * Set the stack limit to something smaller, so that we don't lock a lot
711 * of unused stack memory.
716 /* HMS: must make the rlim_cur amount configurable */
717 if (getrlimit(RLIMIT_STACK, &rl) != -1
718 && (rl.rlim_cur = 50 * 4096) < rl.rlim_max)
720 if (setrlimit(RLIMIT_STACK, &rl) == -1)
723 "Cannot adjust stack limit for mlockall: %m");
726 # ifdef RLIMIT_MEMLOCK
728 * The default RLIMIT_MEMLOCK is very low on Linux systems.
729 * Unless we increase this limit malloc calls are likely to
730 * fail if we drop root privlege. To be useful the value
731 * has to be larger than the largest ntpd resident set size.
733 rl.rlim_cur = rl.rlim_max = 32*1024*1024;
734 if (setrlimit(RLIMIT_MEMLOCK, &rl) == -1) {
735 msyslog(LOG_ERR, "Cannot set RLIMIT_MEMLOCK: %m");
737 # endif /* RLIMIT_MEMLOCK */
739 # endif /* HAVE_SETRLIMIT */
741 * lock the process into memory
743 if (mlockall(MCL_CURRENT|MCL_FUTURE) < 0)
744 msyslog(LOG_ERR, "mlockall(): %m");
745 #else /* not (HAVE_MLOCKALL && MCL_CURRENT && MCL_FUTURE) */
750 * set the stack limit for AIX for plock().
751 * see get_aix_stack() for more info.
753 if (ulimit(SET_STACKLIM, (get_aix_stack() - 8*4096)) < 0)
755 msyslog(LOG_ERR,"Cannot adjust stack limit for plock on AIX: %m");
759 * lock the process into memory
761 if (plock(PROCLOCK) < 0)
762 msyslog(LOG_ERR, "plock(PROCLOCK): %m");
763 # else /* not PROCLOCK */
768 if (plock(TXTLOCK) < 0)
769 msyslog(LOG_ERR, "plock(TXTLOCK) error: %m");
770 # else /* not TXTLOCK */
771 msyslog(LOG_ERR, "plock() - don't know what to lock!");
772 # endif /* not TXTLOCK */
773 # endif /* not PROCLOCK */
774 # endif /* HAVE_PLOCK */
775 #endif /* not (HAVE_MLOCKALL && MCL_CURRENT && MCL_FUTURE) */
778 * Set up signals we pay attention to locally.
781 (void) signal_no_reset(SIGDIE1, finish);
784 (void) signal_no_reset(SIGDIE2, finish);
787 (void) signal_no_reset(SIGDIE3, finish);
790 (void) signal_no_reset(SIGDIE4, finish);
794 (void) signal_no_reset(SIGBUS, finish);
797 #if !defined(SYS_WINNT) && !defined(VMS)
799 (void) signal_no_reset(MOREDEBUGSIG, moredebug);
800 (void) signal_no_reset(LESSDEBUGSIG, lessdebug);
802 (void) signal_no_reset(MOREDEBUGSIG, no_debug);
803 (void) signal_no_reset(LESSDEBUGSIG, no_debug);
805 #endif /* !SYS_WINNT && !VMS */
808 * Set up signals we should never pay attention to.
811 (void) signal_no_reset(SIGPIPE, SIG_IGN);
815 * Call the init_ routines to initialize the data structures.
817 * Exactly what command-line options are we expecting here?
824 #if defined (HAVE_IO_COMPLETION_PORT)
825 init_io_completion_port();
834 set_process_priority();
835 init_proto(); /* Call at high priority */
838 mon_start(MON_ON); /* monitor on by default now */
839 /* turn off in config if unwanted */
842 * Get the configuration. This is done in a separate module
843 * since this will definitely be different for the gizmo board.
846 getconfig(argc, argv);
848 loop_config(LOOP_DRIFTCOMP, old_drift / 1e6);
856 /* Drop super-user privileges and chroot now if the OS supports this */
858 #ifdef HAVE_LINUX_CAPABILITIES
859 /* set flag: keep privileges accross setuid() call (we only really need cap_sys_time): */
860 if( prctl( PR_SET_KEEPCAPS, 1L, 0L, 0L, 0L ) == -1 ) {
861 msyslog( LOG_ERR, "prctl( PR_SET_KEEPCAPS, 1L ) failed: %m" );
865 /* we need a user to switch to */
867 msyslog(LOG_ERR, "Need user name to drop root privileges (see -u flag!)" );
870 #endif /* HAVE_LINUX_CAPABILITIES */
873 if (isdigit((unsigned char)*user)) {
874 sw_uid = (uid_t)strtoul(user, &endp, 0);
879 if ((pw = getpwnam(user)) != NULL) {
883 msyslog(LOG_ERR, "Cannot find user `%s'", user);
889 if (isdigit((unsigned char)*group)) {
890 sw_gid = (gid_t)strtoul(group, &endp, 0);
895 if ((gr = getgrnam(group)) != NULL) {
899 msyslog(LOG_ERR, "Cannot find group `%s'", group);
906 /* make sure cwd is inside the jail: */
907 if( chdir(chrootdir) ) {
908 msyslog(LOG_ERR, "Cannot chdir() to `%s': %m", chrootdir);
911 if( chroot(chrootdir) ) {
912 msyslog(LOG_ERR, "Cannot chroot() to `%s': %m", chrootdir);
916 if (group && setgid(sw_gid)) {
917 msyslog(LOG_ERR, "Cannot setgid() to group `%s': %m", group);
920 if (group && setegid(sw_gid)) {
921 msyslog(LOG_ERR, "Cannot setegid() to group `%s': %m", group);
924 if (user && setuid(sw_uid)) {
925 msyslog(LOG_ERR, "Cannot setuid() to user `%s': %m", user);
928 if (user && seteuid(sw_uid)) {
929 msyslog(LOG_ERR, "Cannot seteuid() to user `%s': %m", user);
933 #ifndef HAVE_LINUX_CAPABILITIES
935 * for now assume that the privilege to bind to privileged ports
936 * is associated with running with uid 0 - should be refined on
937 * ports that allow binding to NTP_PORT with uid != 0
939 disable_dynamic_updates |= (sw_uid != 0); /* also notifies routing message listener */
942 if (disable_dynamic_updates && interface_interval) {
943 interface_interval = 0;
944 msyslog(LOG_INFO, "running in unprivileged mode disables dynamic interface tracking");
947 #ifdef HAVE_LINUX_CAPABILITIES
950 * We may be running under non-root uid now, but we still hold full root privileges!
951 * We drop all of them, except for the crucial one or two: cap_sys_time and
952 * cap_net_bind_service if doing dynamic interface tracking.
955 char *captext = interface_interval ?
956 "cap_sys_time,cap_net_bind_service=ipe" :
958 if( ! ( caps = cap_from_text( captext ) ) ) {
959 msyslog( LOG_ERR, "cap_from_text() failed: %m" );
962 if( cap_set_proc( caps ) == -1 ) {
963 msyslog( LOG_ERR, "cap_set_proc() failed to drop root privileges: %m" );
968 #endif /* HAVE_LINUX_CAPABILITIES */
970 } /* if( droproot ) */
971 #endif /* HAVE_DROPROOT */
974 * Report that we're up to any trappers
976 report_event(EVNT_SYSRESTART, (struct peer *)0);
979 * Use select() on all on all input fd's for unlimited
980 * time. select() will terminate on SIGALARM or on the
981 * reception of input. Using select() means we can't do
982 * robust signal handling and we get a potential race
983 * between checking for alarms and doing the select().
984 * Mostly harmless, I think.
986 /* On VMS, I suspect that select() can't be interrupted
987 * by a "signal" either, so I take the easy way out and
988 * have select() time out after one second.
989 * System clock updates really aren't time-critical,
990 * and - lacking a hardware reference clock - I have
991 * yet to learn about anything else that is.
993 #if defined(HAVE_IO_COMPLETION_PORT)
996 int tot_full_recvbufs = GetReceivedBuffers();
997 #else /* normal I/O */
999 BLOCK_IO_AND_ALARM();
1003 # if !defined(HAVE_SIGNALED_IO)
1004 extern fd_set activefds;
1005 extern int maxactivefd;
1011 if (alarm_flag) /* alarmed? */
1017 if (!was_alarmed && has_full_recv_buffer() == ISC_FALSE)
1020 * Nothing to do. Wait for something.
1022 # ifndef HAVE_SIGNALED_IO
1024 # if defined(VMS) || defined(SYS_VXWORKS)
1025 /* make select() wake up after one second */
1029 t1.tv_sec = 1; t1.tv_usec = 0;
1030 nfound = select(maxactivefd+1, &rdfdes, (fd_set *)0,
1034 nfound = select(maxactivefd+1, &rdfdes, (fd_set *)0,
1035 (fd_set *)0, (struct timeval *)0);
1043 (void)input_handler(&ts);
1045 else if (nfound == -1 && errno != EINTR)
1046 netsyslog(LOG_ERR, "select() error: %m");
1049 netsyslog(LOG_DEBUG, "select(): nfound=%d, error: %m", nfound);
1051 # else /* HAVE_SIGNALED_IO */
1054 # endif /* HAVE_SIGNALED_IO */
1055 if (alarm_flag) /* alarmed? */
1064 UNBLOCK_IO_AND_ALARM();
1066 * Out here, signals are unblocked. Call timer routine
1067 * to process expiry.
1071 BLOCK_IO_AND_ALARM();
1074 #endif /* HAVE_IO_COMPLETION_PORT */
1085 rbuf = get_full_recv_buffer();
1086 while (rbuf != NULL)
1093 UNBLOCK_IO_AND_ALARM();
1096 { /* avoid timer starvation during lengthy I/O handling */
1102 * Call the data procedure to handle each received
1105 if (rbuf->receiver != NULL) /* This should always be true */
1110 L_SUB(&dts, &rbuf->recv_time);
1111 DPRINTF(2, ("processing timestamp delta %s (with prec. fuzz)\n", lfptoa(&dts, 9)));
1112 collect_timing(rbuf, "buffer processing delay", 1, &dts);
1115 (rbuf->receiver)(rbuf);
1117 msyslog(LOG_ERR, "receive buffer corruption - receiver found to be NULL - ABORTING");
1121 BLOCK_IO_AND_ALARM();
1123 rbuf = get_full_recv_buffer();
1129 collect_timing(NULL, "processing", bufcount, &tsb);
1130 DPRINTF(2, ("processing time for %d buffers %s\n", bufcount, lfptoa(&tsb, 9)));
1139 UNBLOCK_IO_AND_ALARM();
1146 * finish - exit gracefully
1154 msyslog(LOG_NOTICE, "ntpd exiting on signal %d", sig);
1156 #ifdef HAVE_DNSREGISTRATION
1158 DNSServiceRefDeallocate(mdns);
1165 printf("\nfinish(SIGBUS)\n");
1168 case 0: /* Should never happen... */
1174 #endif /* SIGDIE2 */
1180 * moredebug - increase debugging verbosity
1187 int saved_errno = errno;
1192 msyslog(LOG_DEBUG, "debug raised to %d", debug);
1194 errno = saved_errno;
1198 * lessdebug - decrease debugging verbosity
1205 int saved_errno = errno;
1210 msyslog(LOG_DEBUG, "debug lowered to %d", debug);
1212 errno = saved_errno;
1215 #else /* not DEBUG */
1218 * no_debug - We don't do the debug here.
1225 int saved_errno = errno;
1227 msyslog(LOG_DEBUG, "ntpd not compiled for debugging (signal %d)", sig);
1228 errno = saved_errno;
1230 #endif /* not SYS_WINNT */
1231 #endif /* not DEBUG */