summaryrefslogtreecommitdiff
path: root/usr.sbin/relayd
diff options
context:
space:
mode:
authorClaudio Jeker <claudio@cvs.openbsd.org>2017-11-27 17:35:50 +0000
committerClaudio Jeker <claudio@cvs.openbsd.org>2017-11-27 17:35:50 +0000
commita00e067073e0c6a78dd5b32f62fa7d6512c2e8cc (patch)
tree0ce8701fb502f9ff05bae77940ee7d8d02061f3f /usr.sbin/relayd
parent1ead5edeb3f531e81df4e1ec9e0608ec27cb1645 (diff)
Do not rip out the output buffer of the bufferevent. Instead just use an
initial bufferevent_write_buffer() to write out the queued up HTTP request. OK benno@
Diffstat (limited to 'usr.sbin/relayd')
-rw-r--r--usr.sbin/relayd/relay.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/usr.sbin/relayd/relay.c b/usr.sbin/relayd/relay.c
index 42127f48141..ed6662651d0 100644
--- a/usr.sbin/relayd/relay.c
+++ b/usr.sbin/relayd/relay.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: relay.c,v 1.228 2017/11/27 03:40:04 claudio Exp $ */
+/* $OpenBSD: relay.c,v 1.229 2017/11/27 17:35:49 claudio Exp $ */
/*
* Copyright (c) 2006 - 2014 Reyk Floeter <reyk@openbsd.org>
@@ -712,10 +712,11 @@ relay_connected(int fd, short sig, void *arg)
"failed to allocate output buffer event", 0);
return;
}
- evbuffer_free(bev->output);
- bev->output = con->se_out.output;
- if (bev->output == NULL)
- fatal("%s: invalid output buffer", __func__);
+ /* write pending output buffer now */
+ if (bufferevent_write_buffer(bev, con->se_out.output)) {
+ relay_abort_http(con, 500, strerror(errno), 0);
+ return;
+ }
con->se_out.bev = bev;
/* Initialize the TLS wrapper */
@@ -1698,7 +1699,7 @@ relay_close(struct rsession *con, const char *msg)
free(con->se_priv);
if (con->se_in.bev != NULL)
bufferevent_free(con->se_in.bev);
- else if (con->se_in.output != NULL)
+ if (con->se_in.output != NULL)
evbuffer_free(con->se_in.output);
if (con->se_in.tls != NULL)
tls_close(con->se_in.tls);
@@ -1720,7 +1721,7 @@ relay_close(struct rsession *con, const char *msg)
if (con->se_out.bev != NULL)
bufferevent_free(con->se_out.bev);
- else if (con->se_out.output != NULL)
+ if (con->se_out.output != NULL)
evbuffer_free(con->se_out.output);
if (con->se_out.tls != NULL)
tls_close(con->se_out.tls);