From c438f027ad0c2ef8d6466454e8d2a0b65acf0ab2 Mon Sep 17 00:00:00 2001 From: dtucker <> Date: Mon, 10 Feb 2014 09:12:34 +0000 Subject: [PATCH] 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@ --- src/usr.sbin/ntpd/ntp_dns.c | 8 +++++++- src/usr.sbin/ntpd/ntpd.c | 6 +++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/usr.sbin/ntpd/ntp_dns.c b/src/usr.sbin/ntpd/ntp_dns.c index 44148fe2..931c25ee 100644 --- a/src/usr.sbin/ntpd/ntp_dns.c +++ b/src/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 @@ -17,7 +17,10 @@ */ #include +#include #include + +#include #include #include #include @@ -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/src/usr.sbin/ntpd/ntpd.c b/src/usr.sbin/ntpd/ntpd.c index 3d1e9a07..20b49933 100644 --- a/src/usr.sbin/ntpd/ntpd.c +++ b/src/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 @@ -18,6 +18,7 @@ */ #include +#include #include #include #include @@ -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);