diff options
author | Claudio Jeker <claudio@cvs.openbsd.org> | 2007-07-25 19:11:28 +0000 |
---|---|---|
committer | Claudio Jeker <claudio@cvs.openbsd.org> | 2007-07-25 19:11:28 +0000 |
commit | f87c0abacee8e961fce6f6fab542f60d5d614025 (patch) | |
tree | 0d031c2abc7d7876ea317043f2e668cfe90edd5e | |
parent | d417b66f59a15a5aea30d31a19cd577ae3cde834 (diff) |
Don't fatal if the imsg pipe is closed, this is often triggered in the parent
and hides the real cause of the termination.
OK norby@, reyk@, pyr@
-rw-r--r-- | usr.sbin/ospfd/ospfd.c | 24 | ||||
-rw-r--r-- | usr.sbin/ospfd/ospfe.c | 26 | ||||
-rw-r--r-- | usr.sbin/ospfd/rde.c | 25 |
3 files changed, 57 insertions, 18 deletions
diff --git a/usr.sbin/ospfd/ospfd.c b/usr.sbin/ospfd/ospfd.c index 523b6367792..4f3bf3d274f 100644 --- a/usr.sbin/ospfd/ospfd.c +++ b/usr.sbin/ospfd/ospfd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ospfd.c,v 1.47 2007/06/19 14:42:09 pyr Exp $ */ +/* $OpenBSD: ospfd.c,v 1.48 2007/07/25 19:11:27 claudio Exp $ */ /* * Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org> @@ -347,13 +347,14 @@ main_dispatch_ospfe(int fd, short event, void *bula) struct imsg imsg; struct demote_msg dmsg; ssize_t n; + int shut = 0; switch (event) { case EV_READ: if ((n = imsg_read(ibuf)) == -1) fatal("imsg_read error"); if (n == 0) /* connection closed */ - fatalx("pipe closed"); + shut = 1; break; case EV_WRITE: if (msgbuf_write(&ibuf->w) == -1) @@ -409,7 +410,13 @@ main_dispatch_ospfe(int fd, short event, void *bula) } imsg_free(&imsg); } - imsg_event_add(ibuf); + if (!shut) + imsg_event_add(ibuf); + else { + /* this pipe is dead, so remove the event handler */ + event_del(&ibuf->ev); + event_loopexit(NULL); + } } /* ARGSUSED */ @@ -419,13 +426,14 @@ main_dispatch_rde(int fd, short event, void *bula) struct imsgbuf *ibuf = bula; struct imsg imsg; ssize_t n; + int shut = 0; switch (event) { case EV_READ: if ((n = imsg_read(ibuf)) == -1) fatal("imsg_read error"); if (n == 0) /* connection closed */ - fatalx("pipe closed"); + shut = 1; break; case EV_WRITE: if (msgbuf_write(&ibuf->w) == -1) @@ -461,7 +469,13 @@ main_dispatch_rde(int fd, short event, void *bula) } imsg_free(&imsg); } - imsg_event_add(ibuf); + if (!shut) + imsg_event_add(ibuf); + else { + /* this pipe is dead, so remove the event handler */ + event_del(&ibuf->ev); + event_loopexit(NULL); + } } void diff --git a/usr.sbin/ospfd/ospfe.c b/usr.sbin/ospfd/ospfe.c index 8e831593dcd..ceaca7984bb 100644 --- a/usr.sbin/ospfd/ospfe.c +++ b/usr.sbin/ospfd/ospfe.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ospfe.c,v 1.56 2007/06/19 14:42:09 pyr Exp $ */ +/* $OpenBSD: ospfe.c,v 1.57 2007/07/25 19:11:27 claudio Exp $ */ /* * Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org> @@ -257,14 +257,14 @@ ospfe_dispatch_main(int fd, short event, void *bula) struct iface *iface = NULL; struct kif *kif; struct auth_md md; - int n, link_ok, stub_changed; + int n, link_ok, stub_changed, shut = 0; switch (event) { case EV_READ: if ((n = imsg_read(ibuf)) == -1) fatal("imsg_read error"); if (n == 0) /* connection closed */ - fatalx("pipe closed"); + shut = 1; break; case EV_WRITE: if (msgbuf_write(&ibuf->w) == -1) @@ -378,7 +378,13 @@ ospfe_dispatch_main(int fd, short event, void *bula) } imsg_free(&imsg); } - imsg_event_add(ibuf); + if (!shut) + imsg_event_add(ibuf); + else { + /* this pipe is dead, so remove the event handler */ + event_del(&ibuf->ev); + event_loopexit(NULL); + } } /* ARGSUSED */ @@ -395,7 +401,7 @@ ospfe_dispatch_rde(int fd, short event, void *bula) struct lsa_entry *le; struct imsg imsg; struct abr_rtr ar; - int n, noack = 0; + int n, noack = 0, shut = 0; u_int16_t l, age; switch (event) { @@ -403,7 +409,7 @@ ospfe_dispatch_rde(int fd, short event, void *bula) if ((n = imsg_read(ibuf)) == -1) fatal("imsg_read error"); if (n == 0) /* connection closed */ - fatalx("pipe closed"); + shut = 1; break; case EV_WRITE: if (msgbuf_write(&ibuf->w) == -1) @@ -641,7 +647,13 @@ ospfe_dispatch_rde(int fd, short event, void *bula) } imsg_free(&imsg); } - imsg_event_add(ibuf); + if (!shut) + imsg_event_add(ibuf); + else { + /* this pipe is dead, so remove the event handler */ + event_del(&ibuf->ev); + event_loopexit(NULL); + } } struct iface * diff --git a/usr.sbin/ospfd/rde.c b/usr.sbin/ospfd/rde.c index 8b94b5dd0dc..7949a087d12 100644 --- a/usr.sbin/ospfd/rde.c +++ b/usr.sbin/ospfd/rde.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rde.c,v 1.68 2007/06/19 16:45:15 reyk Exp $ */ +/* $OpenBSD: rde.c,v 1.69 2007/07/25 19:11:27 claudio Exp $ */ /* * Copyright (c) 2004, 2005 Claudio Jeker <claudio@openbsd.org> @@ -236,7 +236,7 @@ rde_dispatch_imsg(int fd, short event, void *bula) char *buf; ssize_t n; time_t now; - int r, state, self; + int r, state, self, shut = 0; u_int16_t l; switch (event) { @@ -244,7 +244,7 @@ rde_dispatch_imsg(int fd, short event, void *bula) if ((n = imsg_read(ibuf)) == -1) fatal("imsg_read error"); if (n == 0) /* connection closed */ - fatalx("pipe closed"); + shut = 1; break; case EV_WRITE: if (msgbuf_write(&ibuf->w) == -1) @@ -559,7 +559,13 @@ rde_dispatch_imsg(int fd, short event, void *bula) } imsg_free(&imsg); } - imsg_event_add(ibuf); + if (!shut) + imsg_event_add(ibuf); + else { + /* this pipe is dead, so remove the event handler */ + event_del(&ibuf->ev); + event_loopexit(NULL); + } } /* ARGSUSED */ @@ -576,13 +582,14 @@ rde_dispatch_parent(int fd, short event, void *bula) struct vertex *v; struct rt_node *rn; ssize_t n; + int shut = 0; switch (event) { case EV_READ: if ((n = imsg_read(ibuf)) == -1) fatal("imsg_read error"); if (n == 0) /* connection closed */ - fatalx("pipe closed"); + shut = 1; break; case EV_WRITE: if (msgbuf_write(&ibuf->w) == -1) @@ -692,7 +699,13 @@ rde_dispatch_parent(int fd, short event, void *bula) } imsg_free(&imsg); } - imsg_event_add(ibuf); + if (!shut) + imsg_event_add(ibuf); + else { + /* this pipe is dead, so remove the event handler */ + event_del(&ibuf->ev); + event_loopexit(NULL); + } } u_int32_t |