summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Bluhm <bluhm@cvs.openbsd.org>2017-08-28 17:31:01 +0000
committerAlexander Bluhm <bluhm@cvs.openbsd.org>2017-08-28 17:31:01 +0000
commit54db8e95c07c55a8be737ad72452946cec7ecd2c (patch)
tree048a9735ba610c777f65aebe228bdfc04fe67c7a
parentbc94add5d93657c156dde29ad08146157a169973 (diff)
Do not close the relay if data is still in the output buffer.
Otherwise data not written could get lost. Also try to drain the buffers when socket splicing should be enabled. The latter was lost when the expicit bufferevent_enable() was added in relay_write(). bug report, analysis, initial fix, testing Rivo Nurges; OK beck@
-rw-r--r--usr.sbin/relayd/relay.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/usr.sbin/relayd/relay.c b/usr.sbin/relayd/relay.c
index 01b5c4987f2..c7448b3fd1b 100644
--- a/usr.sbin/relayd/relay.c
+++ b/usr.sbin/relayd/relay.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: relay.c,v 1.225 2017/08/09 21:29:17 claudio Exp $ */
+/* $OpenBSD: relay.c,v 1.226 2017/08/28 17:31:00 bluhm Exp $ */
/*
* Copyright (c) 2006 - 2014 Reyk Floeter <reyk@openbsd.org>
@@ -791,12 +791,12 @@ relay_write(struct bufferevent *bev, void *arg)
getmonotime(&con->se_tv_last);
- if (con->se_done)
+ if (con->se_done && EVBUFFER_LENGTH(EVBUFFER_OUTPUT(bev)) == 0)
goto done;
- if (relay_splice(cre->dst) == -1)
- goto fail;
if (cre->dst->bev)
bufferevent_enable(cre->dst->bev, EV_READ);
+ if (relay_splice(cre->dst) == -1)
+ goto fail;
return;
done: