From: Harlan Stenn Date: Tue, 18 Jul 2000 03:27:27 +0000 (-0000) Subject: ChangeLog, ntp_config.c, ntpd.c: X-Git-Tag: NTP_4_0_99_K~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0e4579bf85524cd56bdad418909ffe8d652a9a21;p=thirdparty%2Fntp.git ChangeLog, ntp_config.c, ntpd.c: * ntpd/ntp_config.c (getconfig): CONFIG_PRIORITY support * ntpd/ntpd.c (set_process_priority): Use it. bk: 3973ce9fTVU-GDkNtiKvXShI4u-Uvg --- diff --git a/ChangeLog b/ChangeLog index d1d8c7cc3a..f7bb8b4f6b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2000-07-17 Harlan Stenn + * ntpd/ntp_config.c (getconfig): CONFIG_PRIORITY support + * ntpd/ntpd.c (set_process_priority): Use it. + * ntpd/ntp_crypto.c: Crypto key stuff * ntpd/ntp_proto.c: pubkey -> pubkey.ptr * ntpd/ntp_control.c (ctl_putpeer): fstamp -> pubkey.fstamp diff --git a/ntpd/ntp_config.c b/ntpd/ntp_config.c index f9c68e0332..66db3e17b0 100644 --- a/ntpd/ntp_config.c +++ b/ntpd/ntp_config.c @@ -40,6 +40,8 @@ extern HANDLE ResolverThreadHandle; #endif /* SYS_WINNT */ +extern int priority_done; + /* * These routines are used to read the configuration file at * startup time. An entry in the file must fit on a single line. @@ -93,6 +95,7 @@ extern HANDLE ResolverThreadHandle; * disable auth|bclient|pll|kernel|monitor|stats * phone ... * pps device [assert|clear] [hardpps] + * priority high|normal */ /* @@ -141,6 +144,7 @@ extern HANDLE ResolverThreadHandle; #ifdef PUBKEY #define CONFIG_CRYPTO 34 #endif /* PUBKEY */ +#define CONFIG_PRIORITY 35 /* * "peer", "server", "broadcast" modifier keywords @@ -261,6 +265,7 @@ static struct keyword keywords[] = { { "phone", CONFIG_PHONE }, { "pidfile", CONFIG_PIDFILE }, { "pps", CONFIG_PPS }, + { "priority", CONFIG_PRIORITY }, { "requestkey", CONFIG_REQUESTKEY }, { "restrict", CONFIG_RESTRICT }, { "revoke", CONFIG_REVOKE }, @@ -1174,6 +1179,13 @@ getconfig( stats_config(STATS_PID_FILE, (char *)0); break; + case CONFIG_PRIORITY: + if (ntokens >= 1) + priority_done = strcmp(tokens[1], "high"); + else + priority_done = 1; + break; + case CONFIG_LOGFILE: if (ntokens >= 2) { FILE *new_file; diff --git a/ntpd/ntpd.c b/ntpd/ntpd.c index bd7c2058b7..236ed06d1b 100644 --- a/ntpd/ntpd.c +++ b/ntpd/ntpd.c @@ -128,6 +128,8 @@ static BOOL WINAPI OnConsoleEvent(DWORD dwCtrlType); */ #define NTPD_PRIO (-12) +int priority_done = 2; + /* * Debugging flag */ @@ -227,7 +229,9 @@ catch_danger(int signo) static void set_process_priority(void) { - int done = 1; + + msyslog(LOG_DEBUG, "set_process_priority: priority_done is <%d>", + priority_done); #ifdef SYS_WINNT DWORD SingleCPUMask = 0; @@ -255,11 +259,11 @@ set_process_priority(void) if (!SetPriorityClass(GetCurrentProcess(), (DWORD) REALTIME_PRIORITY_CLASS)) msyslog(LOG_ERR, "SetPriorityClass: %m"); else - ++done; + ++priority_done; #endif #if defined(HAVE_SCHED_SETSCHEDULER) - if (!done) { + if (!priority_done) { extern int config_priority_override, config_priority; int pmax, pmin; struct sched_param sched; @@ -278,12 +282,12 @@ set_process_priority(void) if ( sched_setscheduler(0, SCHED_FIFO, &sched) == -1 ) msyslog(LOG_ERR, "sched_setscheduler(): %m"); else - ++done; + ++priority_done; } #endif /* HAVE_SCHED_SETSCHEDULER */ #if defined(HAVE_RTPRIO) # ifdef RTP_SET - if (!done) { + if (!priority_done) { struct rtprio srtp; srtp.type = RTP_PRIO_REALTIME; /* was: RTP_PRIO_NORMAL */ @@ -292,37 +296,37 @@ set_process_priority(void) if (rtprio(RTP_SET, getpid(), &srtp) < 0) msyslog(LOG_ERR, "rtprio() error: %m"); else - ++done; + ++priority_done; } # else /* not RTP_SET */ - if (!done) { + if (!priority_done) { if (rtprio(0, 120) < 0) msyslog(LOG_ERR, "rtprio() error: %m"); else - ++done; + ++priority_done; } # endif /* not RTP_SET */ #endif /* HAVE_RTPRIO */ #if defined(NTPD_PRIO) && NTPD_PRIO != 0 # ifdef HAVE_ATT_NICE - if (!done) { + if (!priority_done) { errno = 0; if (-1 == nice (NTPD_PRIO) && errno != 0) msyslog(LOG_ERR, "nice() error: %m"); else - ++done; + ++priority_done; } # endif /* HAVE_ATT_NICE */ # ifdef HAVE_BSD_NICE - if (!done) { + if (!priority_done) { if (-1 == setpriority(PRIO_PROCESS, 0, NTPD_PRIO)) msyslog(LOG_ERR, "setpriority() error: %m"); else - ++done; + ++priority_done; } # endif /* HAVE_BSD_NICE */ #endif /* NTPD_PRIO && NTPD_PRIO != 0 */ - if (!done) + if (!priority_done) msyslog(LOG_ERR, "set_process_priority: No way found to improve our priority"); }