summaryrefslogtreecommitdiff
path: root/usr.sbin/smtpd/mproc.c
diff options
context:
space:
mode:
authorEric Faurot <eric@cvs.openbsd.org>2013-10-24 19:20:47 +0000
committerEric Faurot <eric@cvs.openbsd.org>2013-10-24 19:20:47 +0000
commitf0916475c87d7997394209910b97f9e208aa130c (patch)
treedb348adb8579578f4596e980f0053a8fec27dd68 /usr.sbin/smtpd/mproc.c
parent0e3b86e44292259cc31630d0b43a3d9b1061b357 (diff)
Do not fatal() immediatly on write error, but report to the upper layer.
Fix a bug where the server would stop if smtpctl exits early.
Diffstat (limited to 'usr.sbin/smtpd/mproc.c')
-rw-r--r--usr.sbin/smtpd/mproc.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/usr.sbin/smtpd/mproc.c b/usr.sbin/smtpd/mproc.c
index ebede2adcc2..2bab474b8b9 100644
--- a/usr.sbin/smtpd/mproc.c
+++ b/usr.sbin/smtpd/mproc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mproc.c,v 1.4 2013/07/19 15:18:42 eric Exp $ */
+/* $OpenBSD: mproc.c,v 1.5 2013/10/24 19:20:46 eric Exp $ */
/*
* Copyright (c) 2012 Eric Faurot <eric@faurot.net>
@@ -170,8 +170,15 @@ mproc_dispatch(int fd, short event, void *arg)
if (event & EV_WRITE) {
n = msgbuf_write2(&p->imsgbuf.w);
- if (n == -1)
- fatal("msgbuf_write");
+ if (n == -1) {
+ /* this pipe is dead, so remove the event handler */
+ if (smtpd_process != PROC_CONTROL ||
+ p->proc != PROC_CLIENT)
+ log_warnx("warn: %s -> %s: pipe closed",
+ proc_name(smtpd_process), p->name);
+ p->handler(p, NULL);
+ return;
+ }
p->bytes_out += n;
p->bytes_queued -= n;
}