summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDarren Tucker <dtucker@cvs.openbsd.org>2014-02-10 09:12:35 +0000
committerDarren Tucker <dtucker@cvs.openbsd.org>2014-02-10 09:12:35 +0000
commit75f8a2e5a773cdcca333f0743b84ac4145b9fb70 (patch)
treef1d9ff70e7d9e751ec8f3ca2b421493092412cf9
parentcb60e22829ef23044dcf046b63e53d0e677b9653 (diff)
Run the serving and privileged ntpd processes at high priority and the
dns process at normal priority. Should improve latency on loaded machines. ok henning@
-rw-r--r--usr.sbin/ntpd/ntp_dns.c8
-rw-r--r--usr.sbin/ntpd/ntpd.c6
2 files changed, 12 insertions, 2 deletions
diff --git a/usr.sbin/ntpd/ntp_dns.c b/usr.sbin/ntpd/ntp_dns.c
index 44148fe2641..931c25ee5da 100644
--- a/usr.sbin/ntpd/ntp_dns.c
+++ b/usr.sbin/ntpd/ntp_dns.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ntp_dns.c,v 1.4 2013/11/13 20:44:39 benno Exp $ */
+/* $OpenBSD: ntp_dns.c,v 1.5 2014/02/10 09:12:34 dtucker Exp $ */
/*
* Copyright (c) 2003-2008 Henning Brauer <henning@openbsd.org>
@@ -17,7 +17,10 @@
*/
#include <sys/param.h>
+#include <sys/resource.h>
#include <sys/time.h>
+
+#include <err.h>
#include <errno.h>
#include <poll.h>
#include <signal.h>
@@ -61,6 +64,9 @@ ntp_dns(int pipe_ntp[2], struct ntpd_conf *nconf, struct passwd *pw)
return (pid);
}
+ if (setpriority(PRIO_PROCESS, 0, 0) == -1)
+ warn("could not set priority");
+
/* in this case the parent didn't init logging and didn't daemonize */
if (nconf->settime && !nconf->debug) {
log_init(nconf->debug);
diff --git a/usr.sbin/ntpd/ntpd.c b/usr.sbin/ntpd/ntpd.c
index 3d1e9a0730c..20b499330c3 100644
--- a/usr.sbin/ntpd/ntpd.c
+++ b/usr.sbin/ntpd/ntpd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ntpd.c,v 1.78 2014/01/28 22:57:37 sthen Exp $ */
+/* $OpenBSD: ntpd.c,v 1.79 2014/02/10 09:12:34 dtucker Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -18,6 +18,7 @@
*/
#include <sys/types.h>
+#include <sys/resource.h>
#include <sys/socket.h>
#include <sys/wait.h>
#include <sys/un.h>
@@ -166,6 +167,9 @@ main(int argc, char *argv[])
if ((pw = getpwnam(NTPD_USER)) == NULL)
errx(1, "unknown user %s", NTPD_USER);
+ if (setpriority(PRIO_PROCESS, 0, -20) == -1)
+ warn("can't set priority");
+
reset_adjtime();
if (!lconf.settime) {
log_init(lconf.debug);