summaryrefslogtreecommitdiff
path: root/usr.sbin/relayd/relay.c
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/relayd/relay.c
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/relayd/relay.c')
-rw-r--r--usr.sbin/relayd/relay.c18
1 files changed, 13 insertions, 5 deletions
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)