summaryrefslogtreecommitdiff
path: root/usr.sbin/httpd
diff options
context:
space:
mode:
authorOtto Moerbeek <otto@cvs.openbsd.org>2021-03-16 06:44:15 +0000
committerOtto Moerbeek <otto@cvs.openbsd.org>2021-03-16 06:44:15 +0000
commitd75658567a61f4c9ccc29945910b3a2bb46f0247 (patch)
tree56b1051c7be96e900fd22e39693f16c57695ba53 /usr.sbin/httpd
parent5fd1104a90c6098185749b70544f2216e7088680 (diff)
A socket buffer is not the best size to read from a disk.
Use st_blksize to set high water mark; florian@
Diffstat (limited to 'usr.sbin/httpd')
-rw-r--r--usr.sbin/httpd/server_file.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/usr.sbin/httpd/server_file.c b/usr.sbin/httpd/server_file.c
index d62590037ae..6b01ba7f3d6 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.68 2020/05/22 07:18:17 bentley Exp $ */
+/* $OpenBSD: server_file.c,v 1.69 2021/03/16 06:44:14 otto Exp $ */
/*
* Copyright (c) 2006 - 2017 Reyk Floeter <reyk@openbsd.org>
@@ -224,6 +224,7 @@ server_file_request(struct httpd *env, struct client *clt, char *path,
struct media_type *media;
const char *errstr = NULL;
int fd = -1, ret, code = 500;
+ size_t bufsiz;
if ((ret = server_file_method(clt)) != 0) {
code = ret;
@@ -269,9 +270,10 @@ server_file_request(struct httpd *env, struct client *clt, char *path,
goto fail;
}
- /* Adjust read watermark to the socket output buffer size */
+ /* Adjust read watermark to the optimal file io size */
+ bufsiz = MAXIMUM(st->st_blksize, 64 * 1024);
bufferevent_setwatermark(clt->clt_srvbev, EV_READ, 0,
- clt->clt_sndbufsiz);
+ bufsiz);
bufferevent_settimeout(clt->clt_srvbev,
srv_conf->timeout.tv_sec, srv_conf->timeout.tv_sec);
@@ -304,7 +306,7 @@ server_partial_file_request(struct httpd *env, struct client *clt, char *path,
struct media_type *media, multipart_media;
struct range_data *r = &clt->clt_ranges;
struct range *range;
- size_t content_length = 0;
+ size_t content_length = 0, bufsiz;
int code = 500, fd = -1, i, nranges, ret;
char content_range[64];
const char *errstr = NULL;
@@ -403,9 +405,10 @@ server_partial_file_request(struct httpd *env, struct client *clt, char *path,
goto fail;
}
- /* Adjust read watermark to the socket output buffer size */
+ /* Adjust read watermark to the optimal file io size */
+ bufsiz = MAXIMUM(st->st_blksize, 64 * 1024);
bufferevent_setwatermark(clt->clt_srvbev, EV_READ, 0,
- clt->clt_sndbufsiz);
+ bufsiz);
bufferevent_settimeout(clt->clt_srvbev,
srv_conf->timeout.tv_sec, srv_conf->timeout.tv_sec);