From 3556c1aa0a4c1f61d008085608a009b039a24c6c Mon Sep 17 00:00:00 2001 From: Reyk Floeter Date: Wed, 6 Aug 2014 11:24:13 +0000 Subject: The watermark exposed a bug in server_write that broke keep-alive support. Instead of calling server_close from server_write, we have to proceed to the next connection by calling the error handler. OK jsg@ --- usr.sbin/httpd/server.c | 9 +++++---- usr.sbin/httpd/server_file.c | 17 +++++++++-------- 2 files changed, 14 insertions(+), 12 deletions(-) (limited to 'usr.sbin/httpd') diff --git a/usr.sbin/httpd/server.c b/usr.sbin/httpd/server.c index 6460f357237..77168e95ca3 100644 --- a/usr.sbin/httpd/server.c +++ b/usr.sbin/httpd/server.c @@ -1,4 +1,4 @@ -/* $OpenBSD: server.c,v 1.33 2014/08/06 09:40:04 reyk Exp $ */ +/* $OpenBSD: server.c,v 1.34 2014/08/06 11:24:12 reyk Exp $ */ /* * Copyright (c) 2006 - 2014 Reyk Floeter @@ -688,9 +688,11 @@ server_write(struct bufferevent *bev, void *arg) if (clt->clt_done) goto done; + + bufferevent_enable(bev, EV_READ); return; done: - server_close(clt, "last write (done)"); + (*bev->errorcb)(bev, EVBUFFER_WRITE|EVBUFFER_EOF, bev->cbarg); return; } @@ -728,10 +730,9 @@ server_read(struct bufferevent *bev, void *arg) goto fail; if (clt->clt_done) goto done; - bufferevent_enable(bev, EV_READ); return; done: - server_close(clt, "last read (done)"); + (*bev->errorcb)(bev, EVBUFFER_READ|EVBUFFER_EOF, bev->cbarg); return; fail: server_close(clt, strerror(errno)); diff --git a/usr.sbin/httpd/server_file.c b/usr.sbin/httpd/server_file.c index 5b72aaf4683..65ecb0100b8 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.30 2014/08/06 09:36:31 reyk Exp $ */ +/* $OpenBSD: server_file.c,v 1.31 2014/08/06 11:24:12 reyk Exp $ */ /* * Copyright (c) 2006 - 2014 Reyk Floeter @@ -375,13 +375,6 @@ server_file_error(struct bufferevent *bev, short error, void *arg) clt->clt_done = 1; - dst = EVBUFFER_OUTPUT(clt->clt_bev); - if (EVBUFFER_LENGTH(dst)) { - /* Finish writing all data first */ - bufferevent_enable(clt->clt_bev, EV_WRITE); - return; - } - if (clt->clt_persist) { /* Close input file and wait for next HTTP request */ if (clt->clt_fd != -1) @@ -392,6 +385,14 @@ server_file_error(struct bufferevent *bev, short error, void *arg) bufferevent_enable(clt->clt_bev, EV_READ|EV_WRITE); return; } + + dst = EVBUFFER_OUTPUT(clt->clt_bev); + if (EVBUFFER_LENGTH(dst)) { + /* Finish writing all data first */ + bufferevent_enable(clt->clt_bev, EV_WRITE); + return; + } + server_close(clt, "done"); return; } -- cgit v1.2.3