summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorPierre-Yves Ritschard <pyr@cvs.openbsd.org>2007-06-19 06:29:21 +0000
committerPierre-Yves Ritschard <pyr@cvs.openbsd.org>2007-06-19 06:29:21 +0000
commit206cdd52ced690add46605396f3610feb9f5d417 (patch)
treecbd8214d43f9a032cae9838cf413c803607ae0d1 /usr.sbin
parentc1eea903d4acc5860aa5b3e80b2d71c9a0d92358 (diff)
Do not fatal out with ``pipe closed'' when a short read occurs on one
of our socket pairs. Instead disable listening on the pipe, terminate the event loop, and let the parent process's SIGCHLD handler do a clean shutdown. from an ospfd diff by claudio, ok claudio@
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/hoststated/hce.c18
-rw-r--r--usr.sbin/hoststated/hoststated.c26
-rw-r--r--usr.sbin/hoststated/pfe.c26
-rw-r--r--usr.sbin/hoststated/relay.c18
-rw-r--r--usr.sbin/relayd/hce.c18
-rw-r--r--usr.sbin/relayd/pfe.c26
-rw-r--r--usr.sbin/relayd/relay.c18
-rw-r--r--usr.sbin/relayd/relayd.c26
8 files changed, 128 insertions, 48 deletions
diff --git a/usr.sbin/hoststated/hce.c b/usr.sbin/hoststated/hce.c
index 9e9677a742e..f725c1afa5e 100644
--- a/usr.sbin/hoststated/hce.c
+++ b/usr.sbin/hoststated/hce.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: hce.c,v 1.27 2007/06/12 15:16:10 msf Exp $ */
+/* $OpenBSD: hce.c,v 1.28 2007/06/19 06:29:20 pyr Exp $ */
/*
* Copyright (c) 2006 Pierre-Yves Ritschard <pyr@spootnik.org>
@@ -345,8 +345,12 @@ hce_dispatch_imsg(int fd, short event, void *ptr)
case EV_READ:
if ((n = imsg_read(ibuf)) == -1)
fatal("hce_dispatch_imsg: imsg_read_error");
- if (n == 0)
- fatalx("hce_dispatch_imsg: pipe closed");
+ if (n == 0) {
+ /* this pipe is dead, so remove the event handler */
+ event_del(&ibuf->ev);
+ event_loopexit(NULL);
+ return;
+ }
break;
case EV_WRITE:
if (msgbuf_write(&ibuf->w) == -1)
@@ -423,8 +427,12 @@ hce_dispatch_parent(int fd, short event, void * ptr)
case EV_READ:
if ((n = imsg_read(ibuf)) == -1)
fatal("hce_dispatch_parent: imsg_read error");
- if (n == 0)
- fatalx("hce_dispatch_parent: pipe closed");
+ if (n == 0) {
+ /* this pipe is dead, so remove the event handler */
+ event_del(&ibuf->ev);
+ event_loopexit(NULL);
+ return;
+ }
break;
case EV_WRITE:
if (msgbuf_write(&ibuf->w) == -1)
diff --git a/usr.sbin/hoststated/hoststated.c b/usr.sbin/hoststated/hoststated.c
index 6b0a1c6f833..ab22e2c296f 100644
--- a/usr.sbin/hoststated/hoststated.c
+++ b/usr.sbin/hoststated/hoststated.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: hoststated.c,v 1.36 2007/06/12 15:16:10 msf Exp $ */
+/* $OpenBSD: hoststated.c,v 1.37 2007/06/19 06:29:20 pyr Exp $ */
/*
* Copyright (c) 2006 Pierre-Yves Ritschard <pyr@spootnik.org>
@@ -541,8 +541,12 @@ main_dispatch_pfe(int fd, short event, void *ptr)
case EV_READ:
if ((n = imsg_read(ibuf)) == -1)
fatal("imsg_read_error");
- if (n == 0)
- fatalx("main_dispatch_pfe: pipe closed");
+ if (n == 0) {
+ /* this pipe is dead, so remove the event handler */
+ event_del(&ibuf->ev);
+ event_loopexit(NULL);
+ return;
+ }
break;
case EV_WRITE:
if (msgbuf_write(&ibuf->w) == -1)
@@ -599,8 +603,12 @@ main_dispatch_hce(int fd, short event, void * ptr)
case EV_READ:
if ((n = imsg_read(ibuf)) == -1)
fatal("imsg_read error");
- if (n == 0)
- fatalx("main_dispatch_hce: pipe closed");
+ if (n == 0) {
+ /* this pipe is dead, so remove the event handler */
+ event_del(&ibuf->ev);
+ event_loopexit(NULL);
+ return;
+ }
break;
case EV_WRITE:
if (msgbuf_write(&ibuf->w) == -1)
@@ -650,8 +658,12 @@ main_dispatch_relay(int fd, short event, void * ptr)
case EV_READ:
if ((n = imsg_read(ibuf)) == -1)
fatal("imsg_read error");
- if (n == 0)
- fatalx("main_dispatch_relay: pipe closed");
+ if (n == 0) {
+ /* this pipe is dead, so remove the event handler */
+ event_del(&ibuf->ev);
+ event_loopexit(NULL);
+ return;
+ }
break;
case EV_WRITE:
if (msgbuf_write(&ibuf->w) == -1)
diff --git a/usr.sbin/hoststated/pfe.c b/usr.sbin/hoststated/pfe.c
index b0d4f35bf60..5e967f72e91 100644
--- a/usr.sbin/hoststated/pfe.c
+++ b/usr.sbin/hoststated/pfe.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pfe.c,v 1.31 2007/06/12 15:16:10 msf Exp $ */
+/* $OpenBSD: pfe.c,v 1.32 2007/06/19 06:29:20 pyr Exp $ */
/*
* Copyright (c) 2006 Pierre-Yves Ritschard <pyr@spootnik.org>
@@ -229,8 +229,12 @@ pfe_dispatch_imsg(int fd, short event, void *ptr)
case EV_READ:
if ((n = imsg_read(ibuf)) == -1)
fatal("pfe_dispatch_imsg: imsg_read_error");
- if (n == 0)
- fatalx("pfe_dispatch_imsg: pipe closed");
+ if (n == 0) {
+ /* this pipe is dead, so remove the event handler */
+ event_del(&ibuf->ev);
+ event_loopexit(NULL);
+ return;
+ }
break;
case EV_WRITE:
if (msgbuf_write(&ibuf->w) == -1)
@@ -335,8 +339,12 @@ pfe_dispatch_parent(int fd, short event, void * ptr)
case EV_READ:
if ((n = imsg_read(ibuf)) == -1)
fatal("imsg_read error");
- if (n == 0)
- fatalx("pfe_dispatch_parent: pipe closed");
+ if (n == 0) {
+ /* this pipe is dead, so remove the event handler */
+ event_del(&ibuf->ev);
+ event_loopexit(NULL);
+ return;
+ }
break;
case EV_WRITE:
if (msgbuf_write(&ibuf->w) == -1)
@@ -443,8 +451,12 @@ pfe_dispatch_relay(int fd, short event, void * ptr)
case EV_READ:
if ((n = imsg_read(ibuf)) == -1)
fatal("imsg_read error");
- if (n == 0)
- fatalx("pfe_dispatch_relay: pipe closed");
+ if (n == 0) {
+ /* this pipe is dead, so remove the event handler */
+ event_del(&ibuf->ev);
+ event_loopexit(NULL);
+ return;
+ }
break;
case EV_WRITE:
if (msgbuf_write(&ibuf->w) == -1)
diff --git a/usr.sbin/hoststated/relay.c b/usr.sbin/hoststated/relay.c
index 0733aaa9cd1..33f54f8f099 100644
--- a/usr.sbin/hoststated/relay.c
+++ b/usr.sbin/hoststated/relay.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: relay.c,v 1.34 2007/06/12 15:16:10 msf Exp $ */
+/* $OpenBSD: relay.c,v 1.35 2007/06/19 06:29:20 pyr Exp $ */
/*
* Copyright (c) 2006, 2007 Reyk Floeter <reyk@openbsd.org>
@@ -1814,8 +1814,12 @@ relay_dispatch_pfe(int fd, short event, void *ptr)
case EV_READ:
if ((n = imsg_read(ibuf)) == -1)
fatal("relay_dispatch_pfe: imsg_read_error");
- if (n == 0)
- fatalx("relay_dispatch_pfe: pipe closed");
+ if (n == 0) {
+ /* this pipe is dead, so remove the event handler */
+ event_del(&ibuf->ev);
+ event_loopexit(NULL);
+ return;
+ }
break;
case EV_WRITE:
if (msgbuf_write(&ibuf->w) == -1)
@@ -1921,8 +1925,12 @@ relay_dispatch_parent(int fd, short event, void * ptr)
case EV_READ:
if ((n = imsg_read(ibuf)) == -1)
fatal("relay_dispatch_parent: imsg_read error");
- if (n == 0)
- fatalx("relay_dispatch_parent: pipe closed");
+ if (n == 0) {
+ /* this pipe is dead, so remove the event handler */
+ event_del(&ibuf->ev);
+ event_loopexit(NULL);
+ return;
+ }
break;
case EV_WRITE:
if (msgbuf_write(&ibuf->w) == -1)
diff --git a/usr.sbin/relayd/hce.c b/usr.sbin/relayd/hce.c
index 9e9677a742e..f725c1afa5e 100644
--- a/usr.sbin/relayd/hce.c
+++ b/usr.sbin/relayd/hce.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: hce.c,v 1.27 2007/06/12 15:16:10 msf Exp $ */
+/* $OpenBSD: hce.c,v 1.28 2007/06/19 06:29:20 pyr Exp $ */
/*
* Copyright (c) 2006 Pierre-Yves Ritschard <pyr@spootnik.org>
@@ -345,8 +345,12 @@ hce_dispatch_imsg(int fd, short event, void *ptr)
case EV_READ:
if ((n = imsg_read(ibuf)) == -1)
fatal("hce_dispatch_imsg: imsg_read_error");
- if (n == 0)
- fatalx("hce_dispatch_imsg: pipe closed");
+ if (n == 0) {
+ /* this pipe is dead, so remove the event handler */
+ event_del(&ibuf->ev);
+ event_loopexit(NULL);
+ return;
+ }
break;
case EV_WRITE:
if (msgbuf_write(&ibuf->w) == -1)
@@ -423,8 +427,12 @@ hce_dispatch_parent(int fd, short event, void * ptr)
case EV_READ:
if ((n = imsg_read(ibuf)) == -1)
fatal("hce_dispatch_parent: imsg_read error");
- if (n == 0)
- fatalx("hce_dispatch_parent: pipe closed");
+ if (n == 0) {
+ /* this pipe is dead, so remove the event handler */
+ event_del(&ibuf->ev);
+ event_loopexit(NULL);
+ return;
+ }
break;
case EV_WRITE:
if (msgbuf_write(&ibuf->w) == -1)
diff --git a/usr.sbin/relayd/pfe.c b/usr.sbin/relayd/pfe.c
index b0d4f35bf60..5e967f72e91 100644
--- a/usr.sbin/relayd/pfe.c
+++ b/usr.sbin/relayd/pfe.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pfe.c,v 1.31 2007/06/12 15:16:10 msf Exp $ */
+/* $OpenBSD: pfe.c,v 1.32 2007/06/19 06:29:20 pyr Exp $ */
/*
* Copyright (c) 2006 Pierre-Yves Ritschard <pyr@spootnik.org>
@@ -229,8 +229,12 @@ pfe_dispatch_imsg(int fd, short event, void *ptr)
case EV_READ:
if ((n = imsg_read(ibuf)) == -1)
fatal("pfe_dispatch_imsg: imsg_read_error");
- if (n == 0)
- fatalx("pfe_dispatch_imsg: pipe closed");
+ if (n == 0) {
+ /* this pipe is dead, so remove the event handler */
+ event_del(&ibuf->ev);
+ event_loopexit(NULL);
+ return;
+ }
break;
case EV_WRITE:
if (msgbuf_write(&ibuf->w) == -1)
@@ -335,8 +339,12 @@ pfe_dispatch_parent(int fd, short event, void * ptr)
case EV_READ:
if ((n = imsg_read(ibuf)) == -1)
fatal("imsg_read error");
- if (n == 0)
- fatalx("pfe_dispatch_parent: pipe closed");
+ if (n == 0) {
+ /* this pipe is dead, so remove the event handler */
+ event_del(&ibuf->ev);
+ event_loopexit(NULL);
+ return;
+ }
break;
case EV_WRITE:
if (msgbuf_write(&ibuf->w) == -1)
@@ -443,8 +451,12 @@ pfe_dispatch_relay(int fd, short event, void * ptr)
case EV_READ:
if ((n = imsg_read(ibuf)) == -1)
fatal("imsg_read error");
- if (n == 0)
- fatalx("pfe_dispatch_relay: pipe closed");
+ if (n == 0) {
+ /* this pipe is dead, so remove the event handler */
+ event_del(&ibuf->ev);
+ event_loopexit(NULL);
+ return;
+ }
break;
case EV_WRITE:
if (msgbuf_write(&ibuf->w) == -1)
diff --git a/usr.sbin/relayd/relay.c b/usr.sbin/relayd/relay.c
index 0733aaa9cd1..33f54f8f099 100644
--- a/usr.sbin/relayd/relay.c
+++ b/usr.sbin/relayd/relay.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: relay.c,v 1.34 2007/06/12 15:16:10 msf Exp $ */
+/* $OpenBSD: relay.c,v 1.35 2007/06/19 06:29:20 pyr Exp $ */
/*
* Copyright (c) 2006, 2007 Reyk Floeter <reyk@openbsd.org>
@@ -1814,8 +1814,12 @@ relay_dispatch_pfe(int fd, short event, void *ptr)
case EV_READ:
if ((n = imsg_read(ibuf)) == -1)
fatal("relay_dispatch_pfe: imsg_read_error");
- if (n == 0)
- fatalx("relay_dispatch_pfe: pipe closed");
+ if (n == 0) {
+ /* this pipe is dead, so remove the event handler */
+ event_del(&ibuf->ev);
+ event_loopexit(NULL);
+ return;
+ }
break;
case EV_WRITE:
if (msgbuf_write(&ibuf->w) == -1)
@@ -1921,8 +1925,12 @@ relay_dispatch_parent(int fd, short event, void * ptr)
case EV_READ:
if ((n = imsg_read(ibuf)) == -1)
fatal("relay_dispatch_parent: imsg_read error");
- if (n == 0)
- fatalx("relay_dispatch_parent: pipe closed");
+ if (n == 0) {
+ /* this pipe is dead, so remove the event handler */
+ event_del(&ibuf->ev);
+ event_loopexit(NULL);
+ return;
+ }
break;
case EV_WRITE:
if (msgbuf_write(&ibuf->w) == -1)
diff --git a/usr.sbin/relayd/relayd.c b/usr.sbin/relayd/relayd.c
index d348480d098..a72279016bd 100644
--- a/usr.sbin/relayd/relayd.c
+++ b/usr.sbin/relayd/relayd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: relayd.c,v 1.36 2007/06/12 15:16:10 msf Exp $ */
+/* $OpenBSD: relayd.c,v 1.37 2007/06/19 06:29:20 pyr Exp $ */
/*
* Copyright (c) 2006 Pierre-Yves Ritschard <pyr@spootnik.org>
@@ -541,8 +541,12 @@ main_dispatch_pfe(int fd, short event, void *ptr)
case EV_READ:
if ((n = imsg_read(ibuf)) == -1)
fatal("imsg_read_error");
- if (n == 0)
- fatalx("main_dispatch_pfe: pipe closed");
+ if (n == 0) {
+ /* this pipe is dead, so remove the event handler */
+ event_del(&ibuf->ev);
+ event_loopexit(NULL);
+ return;
+ }
break;
case EV_WRITE:
if (msgbuf_write(&ibuf->w) == -1)
@@ -599,8 +603,12 @@ main_dispatch_hce(int fd, short event, void * ptr)
case EV_READ:
if ((n = imsg_read(ibuf)) == -1)
fatal("imsg_read error");
- if (n == 0)
- fatalx("main_dispatch_hce: pipe closed");
+ if (n == 0) {
+ /* this pipe is dead, so remove the event handler */
+ event_del(&ibuf->ev);
+ event_loopexit(NULL);
+ return;
+ }
break;
case EV_WRITE:
if (msgbuf_write(&ibuf->w) == -1)
@@ -650,8 +658,12 @@ main_dispatch_relay(int fd, short event, void * ptr)
case EV_READ:
if ((n = imsg_read(ibuf)) == -1)
fatal("imsg_read error");
- if (n == 0)
- fatalx("main_dispatch_relay: pipe closed");
+ if (n == 0) {
+ /* this pipe is dead, so remove the event handler */
+ event_del(&ibuf->ev);
+ event_loopexit(NULL);
+ return;
+ }
break;
case EV_WRITE:
if (msgbuf_write(&ibuf->w) == -1)