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/rde.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/rde.c')
-rw-r--r-- | usr.sbin/bgpd/rde.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/usr.sbin/bgpd/rde.c b/usr.sbin/bgpd/rde.c index e8b1248f1db..236589583be 100644 --- a/usr.sbin/bgpd/rde.c +++ b/usr.sbin/bgpd/rde.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rde.c,v 1.39 2003/12/27 00:53:51 henning Exp $ */ +/* $OpenBSD: rde.c,v 1.40 2004/01/01 23:09:09 henning Exp $ */ /* * Copyright (c) 2003 Henning Brauer <henning@openbsd.org> @@ -176,10 +176,16 @@ rde_dispatch_imsg(struct imsgbuf *ibuf, int idx) u_int32_t rid; int n; - if ((n = imsg_get(ibuf, &imsg)) == -1) - fatal("imsg_get error"); + if (imsg_read(ibuf) == -1) + fatal("rde_dispatch_imsg: imsg_read error"); + + for (;;) { + if ((n = imsg_get(ibuf, &imsg)) == -1) + fatal("rde_dispatch_imsg: imsg_read error"); + + if (n == 0) + break; - if (n > 0) { switch (imsg.hdr.type) { case IMSG_RECONF_CONF: if (idx != PFD_PIPE_MAIN) |