From: reyk Date: Sun, 13 Jul 2014 15:07:50 +0000 (+0000) Subject: Finish writing the output before closing the connection X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=20a974a2179e816445602aec2b91f06ae0800f46;p=openbsd Finish writing the output before closing the connection (adopted from relayd). --- diff --git a/usr.sbin/httpd/server.c b/usr.sbin/httpd/server.c index f461e5f8bba..f75f49ec056 100644 --- a/usr.sbin/httpd/server.c +++ b/usr.sbin/httpd/server.c @@ -1,4 +1,4 @@ -/* $OpenBSD: server.c,v 1.3 2014/07/13 14:46:52 reyk Exp $ */ +/* $OpenBSD: server.c,v 1.4 2014/07/13 15:07:50 reyk Exp $ */ /* * Copyright (c) 2006 - 2014 Reyk Floeter @@ -384,6 +384,7 @@ void server_error(struct bufferevent *bev, short error, void *arg) { struct client *clt = arg; + struct evbuffer *dst; if (error & EVBUFFER_TIMEOUT) { server_close(clt, "buffer event timeout"); @@ -397,8 +398,15 @@ server_error(struct bufferevent *bev, short error, void *arg) bufferevent_disable(bev, EV_READ|EV_WRITE); clt->clt_done = 1; - server_close(clt, "done"); + if (bev != clt->clt_bev) { + dst = EVBUFFER_OUTPUT(clt->clt_bev); + if (EVBUFFER_LENGTH(dst)) + return; + } else + return; + + server_close(clt, "done"); return; } server_close(clt, "buffer event error"); diff --git a/usr.sbin/httpd/server_file.c b/usr.sbin/httpd/server_file.c index 9774173f186..20cb1565aff 100644 --- a/usr.sbin/httpd/server_file.c +++ b/usr.sbin/httpd/server_file.c @@ -1,4 +1,4 @@ -/* $OpenBSD: server_file.c,v 1.2 2014/07/13 14:17:37 reyk Exp $ */ +/* $OpenBSD: server_file.c,v 1.3 2014/07/13 15:07:50 reyk Exp $ */ /* * Copyright (c) 2006 - 2014 Reyk Floeter @@ -133,7 +133,7 @@ server_response(struct httpd *env, struct client *clt) bufferevent_settimeout(clt->clt_file, srv->srv_conf.timeout.tv_sec, srv->srv_conf.timeout.tv_sec); - bufferevent_enable(clt->clt_file, EV_READ|EV_WRITE); + bufferevent_enable(clt->clt_file, EV_READ); return (0); fail: