summaryrefslogtreecommitdiff
path: root/usr.sbin/bgpd
diff options
context:
space:
mode:
authorHenning Brauer <henning@cvs.openbsd.org>2005-03-14 11:59:14 +0000
committerHenning Brauer <henning@cvs.openbsd.org>2005-03-14 11:59:14 +0000
commit7a95482a13fda95e11af763758735e1f2ba628e1 (patch)
tree8cb0d859d6104c891c9abc1877263078940a4592 /usr.sbin/bgpd
parentcfd931622f0e30d11d731bf621aef06c3cc42dca (diff)
when a buffer has a file descriptor to pass attached, we tried to send
out all pending buffers up to and including the one with the fd attached. the fd is sent with the data and closed after all data is sent. when this amount of data exceeds what we can get rid of with a single sendmsg() on our nonblocking sockets we might send the fd more than once, leaving unused fds around. when we see a buffer with an fd attached, send out everything up to, but EXcluding that buffer, so that in the next round a seperate message with just the one buffer and the associated fd is sent. if anything got written in that sendmsg() call consider the fd sent and close it. from a debugging session with theo hunting something else, claudio ok
Diffstat (limited to 'usr.sbin/bgpd')
-rw-r--r--usr.sbin/bgpd/buffer.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/usr.sbin/bgpd/buffer.c b/usr.sbin/bgpd/buffer.c
index a0e196ca0bb..40de87e4fb6 100644
--- a/usr.sbin/bgpd/buffer.c
+++ b/usr.sbin/bgpd/buffer.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: buffer.c,v 1.26 2005/02/01 21:36:02 henning Exp $ */
+/* $OpenBSD: buffer.c,v 1.27 2005/03/14 11:59:13 henning Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -151,6 +151,8 @@ 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++;
@@ -192,6 +194,11 @@ 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;
+ }
}
}