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