Browse Source

unify shared code a bit again to make future syncs easier

From: Alexander von Gernler <grunk@pestilenz.org>
OPENBSD_3_8
henning 19 years ago
parent
commit
50e41e169b
3 changed files with 11 additions and 10 deletions
  1. +5
    -5
      src/usr.sbin/ntpd/buffer.c
  2. +3
    -2
      src/usr.sbin/ntpd/imsg.c
  3. +3
    -3
      src/usr.sbin/ntpd/ntpd.h

+ 5
- 5
src/usr.sbin/ntpd/buffer.c View File

@ -1,4 +1,4 @@
/* $OpenBSD: buffer.c,v 1.6 2005/03/23 11:36:35 henning Exp $ */
/* $OpenBSD: buffer.c,v 1.7 2005/04/26 15:18:22 henning Exp $ */
/* /*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@ -98,7 +98,7 @@ msgbuf_write(struct msgbuf *msgbuf)
ssize_t n; ssize_t n;
bzero(&iov, sizeof(iov)); bzero(&iov, sizeof(iov));
TAILQ_FOREACH(buf, &msgbuf->bufs, entries) {
TAILQ_FOREACH(buf, &msgbuf->bufs, entry) {
if (i >= IOV_MAX) if (i >= IOV_MAX)
break; break;
iov[i].iov_base = buf->buf + buf->rpos; iov[i].iov_base = buf->buf + buf->rpos;
@ -120,7 +120,7 @@ msgbuf_write(struct msgbuf *msgbuf)
for (buf = TAILQ_FIRST(&msgbuf->bufs); buf != NULL && n > 0; for (buf = TAILQ_FIRST(&msgbuf->bufs); buf != NULL && n > 0;
buf = next) { buf = next) {
next = TAILQ_NEXT(buf, entries);
next = TAILQ_NEXT(buf, entry);
if (buf->rpos + n >= buf->size) { if (buf->rpos + n >= buf->size) {
n -= buf->size - buf->rpos; n -= buf->size - buf->rpos;
buf_dequeue(msgbuf, buf); buf_dequeue(msgbuf, buf);
@ -136,14 +136,14 @@ msgbuf_write(struct msgbuf *msgbuf)
void void
buf_enqueue(struct msgbuf *msgbuf, struct buf *buf) buf_enqueue(struct msgbuf *msgbuf, struct buf *buf)
{ {
TAILQ_INSERT_TAIL(&msgbuf->bufs, buf, entries);
TAILQ_INSERT_TAIL(&msgbuf->bufs, buf, entry);
msgbuf->queued++; msgbuf->queued++;
} }
void void
buf_dequeue(struct msgbuf *msgbuf, struct buf *buf) buf_dequeue(struct msgbuf *msgbuf, struct buf *buf)
{ {
TAILQ_REMOVE(&msgbuf->bufs, buf, entries);
TAILQ_REMOVE(&msgbuf->bufs, buf, entry);
msgbuf->queued--; msgbuf->queued--;
buf_free(buf); buf_free(buf);
} }

+ 3
- 2
src/usr.sbin/ntpd/imsg.c View File

@ -1,4 +1,4 @@
/* $OpenBSD: imsg.c,v 1.10 2005/03/23 10:42:04 henning Exp $ */
/* $OpenBSD: imsg.c,v 1.11 2005/04/26 15:18:22 henning Exp $ */
/* /*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@ -67,7 +67,8 @@ imsg_get(struct imsgbuf *ibuf, struct imsg *imsg)
memcpy(&imsg->hdr, ibuf->r.buf, sizeof(imsg->hdr)); memcpy(&imsg->hdr, ibuf->r.buf, sizeof(imsg->hdr));
if (imsg->hdr.len < IMSG_HEADER_SIZE || if (imsg->hdr.len < IMSG_HEADER_SIZE ||
imsg->hdr.len > MAX_IMSGSIZE) { imsg->hdr.len > MAX_IMSGSIZE) {
log_warnx("imsg_get: imsg hdr len out of bounds");
log_warnx("imsg_get: imsg hdr len %u out of bounds, type=%u",
imsg->hdr.len, imsg->hdr.type);
return (-1); return (-1);
} }
if (imsg->hdr.len > av) if (imsg->hdr.len > av)


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

@ -1,4 +1,4 @@
/* $OpenBSD: ntpd.h,v 1.54 2005/03/23 10:42:04 henning Exp $ */
/* $OpenBSD: ntpd.h,v 1.55 2005/04/26 15:18:22 henning Exp $ */
/* /*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@ -127,7 +127,7 @@ struct ntpd_conf {
}; };
struct buf { struct buf {
TAILQ_ENTRY(buf) entries;
TAILQ_ENTRY(buf) entry;
u_char *buf; u_char *buf;
size_t size; size_t size;
size_t wpos; size_t wpos;
@ -135,7 +135,7 @@ struct buf {
}; };
struct msgbuf { struct msgbuf {
TAILQ_HEAD(bufs, buf) bufs;
TAILQ_HEAD(, buf) bufs;
u_int32_t queued; u_int32_t queued;
int fd; int fd;
}; };


Loading…
Cancel
Save