diff options
author | Rafael Zalamena <rzalamena@cvs.openbsd.org> | 2016-10-10 16:31:36 +0000 |
---|---|---|
committer | Rafael Zalamena <rzalamena@cvs.openbsd.org> | 2016-10-10 16:31:36 +0000 |
commit | a5e7cd932e67da152eb1ec2d2c9e9cbdba908aa1 (patch) | |
tree | 37639d9afa507f8611eadc559a6e660adfafb255 /usr.sbin/httpd/proc.c | |
parent | afa8324c7eda51a056334b982e493ceffa551b90 (diff) |
Fix msgbuf_write() usage idiom and modify the treatment for socket close
to exit gracefully instead of fatal()ing.
ok reyk@
Diffstat (limited to 'usr.sbin/httpd/proc.c')
-rw-r--r-- | usr.sbin/httpd/proc.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/usr.sbin/httpd/proc.c b/usr.sbin/httpd/proc.c index bc7f3637c7b..e595aafaa50 100644 --- a/usr.sbin/httpd/proc.c +++ b/usr.sbin/httpd/proc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: proc.c,v 1.31 2016/10/10 11:13:48 rzalamena Exp $ */ +/* $OpenBSD: proc.c,v 1.32 2016/10/10 16:31:35 rzalamena Exp $ */ /* * Copyright (c) 2010 - 2016 Reyk Floeter <reyk@openbsd.org> @@ -620,8 +620,14 @@ proc_dispatch(int fd, short event, void *arg) } if (event & EV_WRITE) { - if (msgbuf_write(&ibuf->w) <= 0 && errno != EAGAIN) + if ((n = msgbuf_write(&ibuf->w)) == -1 && errno != EAGAIN) fatal("%s: msgbuf_write", __func__); + if (n == 0) { + /* this pipe is dead, so remove the event handler */ + event_del(&iev->ev); + event_loopexit(NULL); + return; + } } for (;;) { |