Browse Source

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
OPENBSD_3_7
henning 20 years ago
parent
commit
25a5d7fd19
2 changed files with 10 additions and 16 deletions
  1. +9
    -13
      src/usr.sbin/ntpd/ntp.c
  2. +1
    -3
      src/usr.sbin/ntpd/ntpd.h

+ 9
- 13
src/usr.sbin/ntpd/ntp.c View File

@ -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 <henning@openbsd.org>
@ -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);


+ 1
- 3
src/usr.sbin/ntpd/ntpd.h View File

@ -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 <henning@openbsd.org>
@ -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


Loading…
Cancel
Save