From 25a5d7fd19c12a538a47cca36aee2efdabe43844 Mon Sep 17 00:00:00 2001 From: henning <> Date: Sat, 18 Sep 2004 07:33:14 +0000 Subject: [PATCH] do not bother overallocating and shrinking the pfd and idx2peer arrays, doesn't by us anything. discussed with ryan during dinner at original joe's --- src/usr.sbin/ntpd/ntp.c | 22 +++++++++------------- src/usr.sbin/ntpd/ntpd.h | 4 +--- 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/src/usr.sbin/ntpd/ntp.c b/src/usr.sbin/ntpd/ntp.c index 47828af9..568178b2 100644 --- a/src/usr.sbin/ntpd/ntp.c +++ b/src/usr.sbin/ntpd/ntp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ntp.c,v 1.31 2004/09/15 19:21:25 henning Exp $ */ +/* $OpenBSD: ntp.c,v 1.32 2004/09/18 07:33:14 henning Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer @@ -125,33 +125,29 @@ ntp_main(int pipe_prnt[2], struct ntpd_conf *nconf) peer_cnt++; while (ntp_quit == 0) { - if (peer_cnt > idx2peer_elms || - peer_cnt + IDX2PEER_RESERVE < idx2peer_elms) { + if (peer_cnt > idx2peer_elms) { if ((newp = realloc(idx2peer, sizeof(void *) * - (peer_cnt + IDX2PEER_RESERVE))) == NULL) { + peer_cnt)) == NULL) { /* panic for now */ log_warn("could not resize idx2peer from %u -> " - "%u entries", idx2peer_elms, - peer_cnt + IDX2PEER_RESERVE); + "%u entries", idx2peer_elms, peer_cnt); fatalx("exiting"); } idx2peer = newp; - idx2peer_elms = peer_cnt + IDX2PEER_RESERVE; + idx2peer_elms = peer_cnt; } new_cnt = PFD_MAX + peer_cnt + listener_cnt; - if (new_cnt > pfd_elms || - new_cnt + PFD_RESERVE < pfd_elms) { + if (new_cnt > pfd_elms) { if ((newp = realloc(pfd, sizeof(struct pollfd) * - (new_cnt + PFD_RESERVE))) == NULL) { + new_cnt)) == NULL) { /* panic for now */ log_warn("could not resize pfd from %u -> " - "%u entries", pfd_elms, - new_cnt + PFD_RESERVE); + "%u entries", pfd_elms, new_cnt); fatalx("exiting"); } pfd = newp; - pfd_elms = new_cnt + PFD_RESERVE; + pfd_elms = new_cnt; } bzero(pfd, sizeof(struct pollfd) * pfd_elms); diff --git a/src/usr.sbin/ntpd/ntpd.h b/src/usr.sbin/ntpd/ntpd.h index 1c29af2f..d571ba9f 100644 --- a/src/usr.sbin/ntpd/ntpd.h +++ b/src/usr.sbin/ntpd/ntpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ntpd.h,v 1.36 2004/09/16 01:13:42 henning Exp $ */ +/* $OpenBSD: ntpd.h,v 1.37 2004/09/18 07:33:14 henning Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer @@ -31,8 +31,6 @@ #define CONFFILE "/etc/ntpd.conf" #define READ_BUF_SIZE 65535 -#define IDX2PEER_RESERVE 5 -#define PFD_RESERVE 10 #define NTPD_OPT_VERBOSE 0x0001 #define NTPD_OPT_VERBOSE2 0x0002