From c6ea6947867203c9f4466471202c5607d86dd420 Mon Sep 17 00:00:00 2001 From: eric <> Date: Thu, 23 Jul 2009 18:58:42 +0000 Subject: [PATCH] make buf_write() behave like msgbuf_write(): send out only the bytes that were filled, not the whole buffer. ok pyr@ gilles@ --- src/usr.sbin/ntpd/buffer.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/usr.sbin/ntpd/buffer.c b/src/usr.sbin/ntpd/buffer.c index 88473a0d..b7693cde 100644 --- a/src/usr.sbin/ntpd/buffer.c +++ b/src/usr.sbin/ntpd/buffer.c @@ -1,4 +1,4 @@ -/* $OpenBSD: buffer.c,v 1.10 2009/06/06 18:14:25 pyr Exp $ */ +/* $OpenBSD: buffer.c,v 1.11 2009/07/23 18:58:42 eric Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer @@ -153,7 +153,7 @@ buf_write(struct msgbuf *msgbuf) if (i >= IOV_MAX) break; iov[i].iov_base = buf->buf + buf->rpos; - iov[i].iov_len = buf->size - buf->rpos; + iov[i].iov_len = buf->wpos - buf->rpos; i++; } @@ -173,8 +173,8 @@ buf_write(struct msgbuf *msgbuf) for (buf = TAILQ_FIRST(&msgbuf->bufs); buf != NULL && n > 0; buf = next) { next = TAILQ_NEXT(buf, entry); - if (buf->rpos + n >= buf->size) { - n -= buf->size - buf->rpos; + if (buf->rpos + n >= buf->wpos) { + n -= buf->wpos - buf->rpos; buf_dequeue(msgbuf, buf); } else { buf->rpos += n;