]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
ChangeLog, ntp_config.c, ntpd.c:
authorHarlan Stenn <stenn@ntp.org>
Tue, 18 Jul 2000 03:27:27 +0000 (03:27 -0000)
committerHarlan Stenn <stenn@ntp.org>
Tue, 18 Jul 2000 03:27:27 +0000 (03:27 -0000)
  * ntpd/ntp_config.c (getconfig): CONFIG_PRIORITY support
  * ntpd/ntpd.c (set_process_priority): Use it.

bk: 3973ce9fTVU-GDkNtiKvXShI4u-Uvg

ChangeLog
ntpd/ntp_config.c
ntpd/ntpd.c

index d1d8c7cc3af42fc18944d2d7212518a657535061..f7bb8b4f6b977eec6ab994fd099c93b3d81d6abb 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 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
index f9c68e0332c4b877667aad73ce2f7a56125ef592..66db3e17b0c6e28199580271ae0e6ef04e16cea6 100644 (file)
@@ -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;
index bd7c2058b7c2ccc9eab652fcea38bc5340886096..236ed06d1b92f064f4ed790caf18f5cbf57c825b 100644 (file)
@@ -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");
 }