diff options
author | Henning Brauer <henning@cvs.openbsd.org> | 2004-01-01 23:09:10 +0000 |
---|---|---|
committer | Henning Brauer <henning@cvs.openbsd.org> | 2004-01-01 23:09:10 +0000 |
commit | b0fe3d62ce222a08711e8e5b1baac92a3a38274f (patch) | |
tree | 32de7a4f9362cf82034eac9437c4cf7d6cc00ab3 /usr.sbin/bgpd/bgpd.c | |
parent | 6cabb1abe96ce74073c96812753fe62daa7f8a68 (diff) |
now that imsg_get uses bigger buffers, one read call can put more than one
imsg into the buffer. since imsg_get by definition only returns one imsg we
missed the next imsg(s) until the next poll event on the socket in question,
building up a queue on that socket. didn't show up as a problem yet...
factor out imsg_read, which reads into the buffer. imsg_get now entirely
operates on the buffers and does not read(2) itself.
make all callers cope by calling imsg_read on poll events and calling
imsg_get in a loop until all imsgs are processed.
Diffstat (limited to 'usr.sbin/bgpd/bgpd.c')
-rw-r--r-- | usr.sbin/bgpd/bgpd.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/usr.sbin/bgpd/bgpd.c b/usr.sbin/bgpd/bgpd.c index fb2cbd6ea79..370d8948948 100644 --- a/usr.sbin/bgpd/bgpd.c +++ b/usr.sbin/bgpd/bgpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bgpd.c,v 1.47 2003/12/30 22:42:31 henning Exp $ */ +/* $OpenBSD: bgpd.c,v 1.48 2004/01/01 23:09:08 henning Exp $ */ /* * Copyright (c) 2003 Henning Brauer <henning@openbsd.org> @@ -340,10 +340,16 @@ dispatch_imsg(struct imsgbuf *ibuf, int idx, struct mrt_config *conf) int n; in_addr_t ina; - if ((n = imsg_get(ibuf, &imsg)) == -1) + if (imsg_read(ibuf) == -1) return (-1); - if (n > 0) { + for (;;) { + if ((n = imsg_get(ibuf, &imsg)) == -1) + return (-1); + + if (n == 0) + break; + switch (imsg.hdr.type) { case IMSG_MRT_MSG: case IMSG_MRT_END: |