diff options
Diffstat (limited to 'usr.sbin/bgpd')
-rw-r--r-- | usr.sbin/bgpd/buffer.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/usr.sbin/bgpd/buffer.c b/usr.sbin/bgpd/buffer.c index 40de87e4fb6..86437d6a1ff 100644 --- a/usr.sbin/bgpd/buffer.c +++ b/usr.sbin/bgpd/buffer.c @@ -1,4 +1,4 @@ -/* $OpenBSD: buffer.c,v 1.27 2005/03/14 11:59:13 henning Exp $ */ +/* $OpenBSD: buffer.c,v 1.28 2005/03/17 21:51:26 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -151,8 +151,6 @@ msgbuf_write(struct msgbuf *msgbuf) TAILQ_FOREACH(buf, &msgbuf->bufs, entry) { if (i >= IOV_MAX) break; - if (i != 0 && buf->fd != -1) /* fds on their own */ - break; iov[i].iov_base = buf->buf + buf->rpos; iov[i].iov_len = buf->size - buf->rpos; i++; @@ -185,6 +183,15 @@ msgbuf_write(struct msgbuf *msgbuf) return (-2); } + /* + * assumption: fd got sent if sendmsg sent anything + * this works because fds are passed one at a time + */ + if (buf != NULL && buf->fd != -1) { + close(buf->fd); + buf->fd = -1; + } + for (buf = TAILQ_FIRST(&msgbuf->bufs); buf != NULL && n > 0; buf = next) { next = TAILQ_NEXT(buf, entry); @@ -194,11 +201,6 @@ msgbuf_write(struct msgbuf *msgbuf) } else { buf->rpos += n; n = 0; - /* assumption: fd got sent if sendmsg sent anything */ - if (buf->fd != -1) { - close(buf->fd); - buf->fd = -1; - } } } |