2000-07-17 Harlan Stenn <stenn@whimsy.udel.edu>
+ * 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
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.
* disable auth|bclient|pll|kernel|monitor|stats
* phone ...
* pps device [assert|clear] [hardpps]
+ * priority high|normal
*/
/*
#ifdef PUBKEY
#define CONFIG_CRYPTO 34
#endif /* PUBKEY */
+#define CONFIG_PRIORITY 35
/*
* "peer", "server", "broadcast" modifier keywords
{ "phone", CONFIG_PHONE },
{ "pidfile", CONFIG_PIDFILE },
{ "pps", CONFIG_PPS },
+ { "priority", CONFIG_PRIORITY },
{ "requestkey", CONFIG_REQUESTKEY },
{ "restrict", CONFIG_RESTRICT },
{ "revoke", CONFIG_REVOKE },
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;
*/
#define NTPD_PRIO (-12)
+int priority_done = 2;
+
/*
* Debugging flag
*/
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;
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;
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 */
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");
}