Download raw body.
httpd: apply correct request timeouts for server
hi, after setting up gitea behind httpd/relayd, i was having trouble cloning large repos (openbsd src, linux). the request would time out in httpd, and i began looking at why. i found that the default timeout is 60 seconds, so i tried to change the timeout a larger value. this value did not seem to get used, and the request continued to time out after the default 60 seconds. note that i have multiple server blocks, where my gitea server is in the second server block for the port 80 listener. it seems that today, if you write a `connection request timeout` in subsequent server block besides the first, this value is never applied. this appears to be because a request timeout is applied once httpd accepts a connection before it matches the incoming request to a server block, but httpd never applies a new timeout after matching. so, whatever the timeout in your first server block for a listener is applies to all subsequent server blocks, no matter what the configuration for them specifies. i don't think this is expected, but if it is, it should be documented. if not, i offer my attempt at fixing this by reapplying the request timeout after matching the incoming request to a server configuration. thank you, nick From 23c7cfc6054c171581e8fc48aa0884a2b00a139e Mon Sep 17 00:00:00 2001 From: Nick Owens <mischief@offblast.org> Date: Tue, 17 Dec 2024 09:06:59 -0800 Subject: [PATCH] httpd: apply correct request timeouts for server httpd applies a request timeout shortly after accepting a connection, and this timeout will come from the configuration of the first listener. the configured timeout for a server should be reapplied after we match the incoming request to a server configuration, otherwise we continue to use the default from the first listener instead of the timeout asked for. --- usr.sbin/httpd/server_http.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/usr.sbin/httpd/server_http.c b/usr.sbin/httpd/server_http.c index 0a814e7a656..42cd5535bd6 100644 --- a/usr.sbin/httpd/server_http.c +++ b/usr.sbin/httpd/server_http.c @@ -1368,6 +1368,10 @@ server_response(struct httpd *httpd, struct client *clt) srv_conf = clt->clt_srv_conf; } + /* reapply possibly changed request timeout after server match */ + bufferevent_settimeout(clt->clt_bev, + srv_conf->requesttimeout.tv_sec, srv_conf->requesttimeout.tv_sec); + if (clt->clt_persist >= srv_conf->maxrequests) clt->clt_persist = 0; -- 2.45.2
httpd: apply correct request timeouts for server