summaryrefslogtreecommitdiff
path: root/usr.sbin/httpd/server.c
diff options
context:
space:
mode:
authorReyk Floeter <reyk@cvs.openbsd.org>2015-07-18 22:19:51 +0000
committerReyk Floeter <reyk@cvs.openbsd.org>2015-07-18 22:19:51 +0000
commit998e6222760cb4ee67095c69115a8cfee0a86130 (patch)
treef8148f4d4a3bfec1029981fa346f2e81a02e2b58 /usr.sbin/httpd/server.c
parent8c87e442183921ee77fe3b97418101d762645608 (diff)
libtls has been changed to set SSL_MODE_ENABLE_PARTIAL_WRITE and
SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER by default. This gives tls_write() a similar short write semantics as write(2) and a workaround in httpd to cope with the previous differences can be removed. Specifically, httpd can stop copying data into a local buffer that was used to keep it around for repeated writes. OK bluhm@
Diffstat (limited to 'usr.sbin/httpd/server.c')
-rw-r--r--usr.sbin/httpd/server.c29
1 files changed, 5 insertions, 24 deletions
diff --git a/usr.sbin/httpd/server.c b/usr.sbin/httpd/server.c
index 86d0dca25e5..8d5e3ce7258 100644
--- a/usr.sbin/httpd/server.c
+++ b/usr.sbin/httpd/server.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: server.c,v 1.70 2015/07/16 16:29:25 florian Exp $ */
+/* $OpenBSD: server.c,v 1.71 2015/07/18 22:19:50 reyk Exp $ */
/*
* Copyright (c) 2006 - 2015 Reyk Floeter <reyk@openbsd.org>
@@ -632,17 +632,9 @@ server_tls_writecb(int fd, short event, void *arg)
}
if (EVBUFFER_LENGTH(bufev->output)) {
- if (clt->clt_buf == NULL) {
- clt->clt_buflen = EVBUFFER_LENGTH(bufev->output);
- if ((clt->clt_buf = malloc(clt->clt_buflen)) == NULL) {
- what |= EVBUFFER_ERROR;
- goto err;
- }
- bcopy(EVBUFFER_DATA(bufev->output),
- clt->clt_buf, clt->clt_buflen);
- }
- ret = tls_write(clt->clt_tls_ctx, clt->clt_buf,
- clt->clt_buflen, &len);
+ ret = tls_write(clt->clt_tls_ctx,
+ EVBUFFER_DATA(bufev->output),
+ EVBUFFER_LENGTH(bufev->output), &len);
if (ret == TLS_READ_AGAIN || ret == TLS_WRITE_AGAIN) {
goto retry;
} else if (ret != 0) {
@@ -651,11 +643,6 @@ server_tls_writecb(int fd, short event, void *arg)
}
evbuffer_drain(bufev->output, len);
}
- if (clt->clt_buf != NULL) {
- free(clt->clt_buf);
- clt->clt_buf = NULL;
- clt->clt_buflen = 0;
- }
if (EVBUFFER_LENGTH(bufev->output) != 0)
server_bufferevent_add(&bufev->ev_write, bufev->timeout_write);
@@ -666,16 +653,10 @@ server_tls_writecb(int fd, short event, void *arg)
return;
retry:
- if (clt->clt_buflen != 0)
- server_bufferevent_add(&bufev->ev_write, bufev->timeout_write);
+ server_bufferevent_add(&bufev->ev_write, bufev->timeout_write);
return;
err:
- if (clt->clt_buf != NULL) {
- free(clt->clt_buf);
- clt->clt_buf = NULL;
- clt->clt_buflen = 0;
- }
(*bufev->errorcb)(bufev, what, bufev->cbarg);
}