|
|
@ -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> |
|
|
@ -98,7 +98,7 @@ msgbuf_write(struct msgbuf *msgbuf) |
|
|
|
ssize_t n; |
|
|
|
|
|
|
|
bzero(&iov, sizeof(iov)); |
|
|
|
TAILQ_FOREACH(buf, &msgbuf->bufs, entries) { |
|
|
|
TAILQ_FOREACH(buf, &msgbuf->bufs, entry) { |
|
|
|
if (i >= IOV_MAX) |
|
|
|
break; |
|
|
|
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; |
|
|
|
buf = next) { |
|
|
|
next = TAILQ_NEXT(buf, entries); |
|
|
|
next = TAILQ_NEXT(buf, entry); |
|
|
|
if (buf->rpos + n >= buf->size) { |
|
|
|
n -= buf->size - buf->rpos; |
|
|
|
buf_dequeue(msgbuf, buf); |
|
|
@ -136,14 +136,14 @@ msgbuf_write(struct msgbuf *msgbuf) |
|
|
|
void |
|
|
|
buf_enqueue(struct msgbuf *msgbuf, struct buf *buf) |
|
|
|
{ |
|
|
|
TAILQ_INSERT_TAIL(&msgbuf->bufs, buf, entries); |
|
|
|
TAILQ_INSERT_TAIL(&msgbuf->bufs, buf, entry); |
|
|
|
msgbuf->queued++; |
|
|
|
} |
|
|
|
|
|
|
|
void |
|
|
|
buf_dequeue(struct msgbuf *msgbuf, struct buf *buf) |
|
|
|
{ |
|
|
|
TAILQ_REMOVE(&msgbuf->bufs, buf, entries); |
|
|
|
TAILQ_REMOVE(&msgbuf->bufs, buf, entry); |
|
|
|
msgbuf->queued--; |
|
|
|
buf_free(buf); |
|
|
|
} |