diff options
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/bgpd/bgpd.c | 9 | ||||
-rw-r--r-- | usr.sbin/bgpd/control.c | 4 | ||||
-rw-r--r-- | usr.sbin/bgpd/imsg.c | 10 | ||||
-rw-r--r-- | usr.sbin/bgpd/rde.c | 7 | ||||
-rw-r--r-- | usr.sbin/bgpd/session.c | 7 |
5 files changed, 22 insertions, 15 deletions
diff --git a/usr.sbin/bgpd/bgpd.c b/usr.sbin/bgpd/bgpd.c index 916db012358..1b37de9ecb1 100644 --- a/usr.sbin/bgpd/bgpd.c +++ b/usr.sbin/bgpd/bgpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bgpd.c,v 1.49 2004/01/01 23:46:47 henning Exp $ */ +/* $OpenBSD: bgpd.c,v 1.50 2004/01/03 14:06:35 henning Exp $ */ /* * Copyright (c) 2003 Henning Brauer <henning@openbsd.org> @@ -345,9 +345,14 @@ dispatch_imsg(struct imsgbuf *ibuf, int idx, struct mrt_config *conf) int n; in_addr_t ina; - if (imsg_read(ibuf) == -1) + if ((n = imsg_read(ibuf)) == -1) return (-1); + if (n == 0) { /* connection closed */ + logit(LOG_CRIT, "dispatch_imsg in main: pipe closed"); + return (-1); + } + for (;;) { if ((n = imsg_get(ibuf, &imsg)) == -1) return (-1); diff --git a/usr.sbin/bgpd/control.c b/usr.sbin/bgpd/control.c index 8dba7cffb4f..c201b20dc3c 100644 --- a/usr.sbin/bgpd/control.c +++ b/usr.sbin/bgpd/control.c @@ -1,4 +1,4 @@ -/* $OpenBSD: control.c,v 1.5 2004/01/03 13:54:27 henning Exp $ */ +/* $OpenBSD: control.c,v 1.6 2004/01/03 14:06:35 henning Exp $ */ /* * Copyright (c) 2003 Henning Brauer <henning@openbsd.org> @@ -179,7 +179,7 @@ control_dispatch_msg(struct pollfd *pfd, int i) return (0); } - if (imsg_read(&c->ibuf) == -1) { + if (imsg_read(&c->ibuf) <= 0) { control_close(pfd->fd); return (1); } diff --git a/usr.sbin/bgpd/imsg.c b/usr.sbin/bgpd/imsg.c index 1d2a8d4abab..a008c5dd00e 100644 --- a/usr.sbin/bgpd/imsg.c +++ b/usr.sbin/bgpd/imsg.c @@ -1,4 +1,4 @@ -/* $OpenBSD: imsg.c,v 1.17 2004/01/01 23:46:47 henning Exp $ */ +/* $OpenBSD: imsg.c,v 1.18 2004/01/03 14:06:35 henning Exp $ */ /* * Copyright (c) 2003 Henning Brauer <henning@openbsd.org> @@ -42,19 +42,15 @@ imsg_read(struct imsgbuf *ibuf) if ((n = read(ibuf->sock, ibuf->r.buf + ibuf->r.wpos, sizeof(ibuf->r.buf) - ibuf->r.wpos)) == -1) { if (errno != EINTR && errno != EAGAIN) { - log_err("imsg_get: pipe read error"); + log_err("imsg_read: pipe read error"); return (-1); } return (0); } - if (n == 0) { /* connection closed */ - logit(LOG_CRIT, "imsg_get: pipe closed"); - return (-1); - } ibuf->r.wpos += n; - return (0); + return (n); } int diff --git a/usr.sbin/bgpd/rde.c b/usr.sbin/bgpd/rde.c index 236589583be..7010c8177c5 100644 --- a/usr.sbin/bgpd/rde.c +++ b/usr.sbin/bgpd/rde.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rde.c,v 1.40 2004/01/01 23:09:09 henning Exp $ */ +/* $OpenBSD: rde.c,v 1.41 2004/01/03 14:06:35 henning Exp $ */ /* * Copyright (c) 2003 Henning Brauer <henning@openbsd.org> @@ -176,9 +176,12 @@ rde_dispatch_imsg(struct imsgbuf *ibuf, int idx) u_int32_t rid; int n; - if (imsg_read(ibuf) == -1) + if ((n = imsg_read(ibuf)) == -1) fatal("rde_dispatch_imsg: imsg_read error"); + if (n == 0) /* connection closed */ + fatal("rde_dispatch_imsg: pipe closed"); + for (;;) { if ((n = imsg_get(ibuf, &imsg)) == -1) fatal("rde_dispatch_imsg: imsg_read error"); diff --git a/usr.sbin/bgpd/session.c b/usr.sbin/bgpd/session.c index 6efc3ad2643..52e546334e9 100644 --- a/usr.sbin/bgpd/session.c +++ b/usr.sbin/bgpd/session.c @@ -1,4 +1,4 @@ -/* $OpenBSD: session.c,v 1.54 2004/01/01 23:46:47 henning Exp $ */ +/* $OpenBSD: session.c,v 1.55 2004/01/03 14:06:35 henning Exp $ */ /* * Copyright (c) 2003 Henning Brauer <henning@openbsd.org> @@ -1270,9 +1270,12 @@ session_dispatch_imsg(struct imsgbuf *ibuf, int idx) enum reconf_action reconf; int n; - if (imsg_read(ibuf) == -1) + if ((n = imsg_read(ibuf)) == -1) fatal("session_dispatch_imsg: imsg_read error"); + if (n == 0) /* connection closed */ + fatal("session_dispatch_imsg: pipe closed"); + for (;;) { if ((n = imsg_get(ibuf, &imsg)) == -1) fatal("session_dispatch_imsg: imsg_get error"); |