-/* $OpenBSD: httpd.h,v 1.47 2014/08/06 02:04:42 jsing Exp $ */
+/* $OpenBSD: httpd.h,v 1.48 2014/08/06 09:36:31 reyk Exp $ */
/*
* Copyright (c) 2006 - 2014 Reyk Floeter <reyk@openbsd.org>
struct evbuffer *clt_output;
struct event clt_ev;
void *clt_desc;
+ int clt_sndbufsiz;
int clt_fd;
struct ressl *clt_ressl_ctx;
-/* $OpenBSD: server.c,v 1.31 2014/08/06 04:39:50 jsg Exp $ */
+/* $OpenBSD: server.c,v 1.32 2014/08/06 09:36:31 reyk Exp $ */
/*
* Copyright (c) 2006 - 2014 Reyk Floeter <reyk@openbsd.org>
struct server_config *srv_conf = clt->clt_srv_conf;
evbuffercb inrd = server_read;
evbuffercb inwr = server_write;
+ socklen_t slen;
if (server_httpdesc_init(clt) == -1) {
server_close(clt, "failed to allocate http descriptor");
clt->clt_toread = TOREAD_HTTP_HEADER;
inrd = server_read_http;
+ slen = sizeof(clt->clt_sndbufsiz);
+ if (getsockopt(clt->clt_s, SOL_SOCKET, SO_SNDBUF,
+ &clt->clt_sndbufsiz, &slen) == -1) {
+ server_close(clt, "failed to get send buffer size");
+ return;
+ }
+
/*
* Client <-> Server
*/
server_ssl_writecb, clt->clt_bev);
}
+ /* Adjust write watermark to the socket buffer output size */
+ bufferevent_setwatermark(clt->clt_bev, EV_WRITE,
+ clt->clt_sndbufsiz, 0);
+
bufferevent_settimeout(clt->clt_bev,
srv_conf->timeout.tv_sec, srv_conf->timeout.tv_sec);
bufferevent_enable(clt->clt_bev, EV_READ|EV_WRITE);
-/* $OpenBSD: server_file.c,v 1.29 2014/08/04 17:43:20 reyk Exp $ */
+/* $OpenBSD: server_file.c,v 1.30 2014/08/06 09:36:31 reyk Exp $ */
/*
* Copyright (c) 2006 - 2014 Reyk Floeter <reyk@openbsd.org>
goto fail;
}
+ /* Adjust read watermark to the socket output buffer size */
+ bufferevent_setwatermark(clt->clt_srvbev, EV_READ, 0,
+ clt->clt_sndbufsiz);
+
bufferevent_settimeout(clt->clt_srvbev,
srv_conf->timeout.tv_sec, srv_conf->timeout.tv_sec);
bufferevent_enable(clt->clt_srvbev, EV_READ);