A child asked to stop gracefully (AP_SIG_GRACEFUL, the pipe-of-death, a
generation change or MaxConnectionsPerChild) used to set die_now, which
stopped the pollers and cancelled everything still queued in the worker
pool. Connections writing a response, parked keep-alive connections and
accepted connections not yet started were dropped, so a slow download
was truncated by any graceful restart.
The child now drains. The supervisor starts it, the listener-owning
poller closes the listening sockets from its own thread, idle keep-alive
connections are expired at once, and the child exits when the count of
open connections reaches zero. The parent no longer counts a draining
child, so its replacement starts in a free slot while the old one
finishes. Run child_stopping and child_stopped from the child exit path
as the other MPMs do.
The scoreboard is sized from the daemon limit when first created and is
kept across graceful restarts, but motorz reported StartServers as that
limit, so raising StartServers on a graceful restart indexed past the
end of shared memory and crashed the parent. Add ServerLimit, defaulting
to twice StartServers, and fix it and ThreadLimit across restarts as
mpm_event does.
perform_idle_server_maintenance() could fork into slot 0 when no slot
was free, and did not count a child that was still starting. Count
children by recorded pid, generation and quiescing state instead, and
start one only in a free slot.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1939361 13f79535-47bb-0310-9956-ffa450edef68
Follow-up to r1939354. Register the extra connection optional functions
from the pre-config hook, and have a child that stops gracefully (on
AP_SIG_GRACEFUL or an idle kill through the pod) wait for the connections
noted by modules before exiting. Ungraceful exits are unchanged.
Add mpm_motorz to the CHANGES entry.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1939355 13f79535-47bb-0310-9956-ffa450edef68
LogIOTrackTTFU / %^FU was added to trunk only (r1828727) and never
backported to 2.4.x, so the 'Available in Apache 2.4.34 and later'
claim was incorrect. Correct it to 2.5.1 in both the %^FU format table
entry and the LogIOTrackTTFU directive compatibility line. Also document
that %^FB and %^FU log '-' when tracking is disabled or the measured
point was never reached. PR 70174.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1939346 13f79535-47bb-0310-9956-ffa450edef68
The cache entry for the first request is committed by the CACHE_SAVE
filter on the EOS-only pass that follows the body, which can still be
running server side for an instant after the client has already read
the complete body. Two back-to-back requests with no delay can race
this, making the second one miss the cache and hit the backend again.
Give the commit room to land before relying on it, instead of
asserting immediately after the first request returns. Reproduced
locally (about 1 in 5 runs failing, on different parametrized cases
each time, none of them involving a comma) and confirmed fixed (0
failures in 55 runs) before and after this change.
Also harden the TCPFaker backend used by this test to close its
socket with an orderly shutdown() instead of an abrupt close(), which
removes one more way for a slow platform to see a reset instead of a
clean end of response.
GitHub: closes#864
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1939305 13f79535-47bb-0310-9956-ffa450edef68
ap_duplicate_listeners() ignored the return value of make_sock() for a
duplicated listener. On failure make_sock() logs the error and closes
the socket, but the loop carried on with the closed listener: with one
Listen the server started or restarted with fewer listeners, and with
several it failed on the closed descriptor with a misleading "Bad file
descriptor". Return the error so that the MPM reports "could not
duplicate listeners" with the original status.
PR: 70106
Submitted by: Xuqing Yang
GitHub: closes#861
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1939304 13f79535-47bb-0310-9956-ffa450edef68
* server/util.c (ap_size_parameter_parse): Allow an optional
case-insensitive 'b', 'k', 'm' or 'g' suffix, bounding the
multiplication by the range of apr_off_t.
* include/httpd.h: Update doxygen accordingly.
* test/unit/util.c (size_parameter_parse_handles_suffixes): New test.
* test/modules/core/test_012_config_off_t.py: Update for suffix
support.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
GitHub: PR #851
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1939295 13f79535-47bb-0310-9956-ffa450edef68
This evolved from troubleshooting content under NT4 that had origins outside of
httpd, but likely was never necessary for httpd.
Also remove gory details about how to change the rights of the user.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1939285 13f79535-47bb-0310-9956-ffa450edef68
* modules/md/md_crypt.c (md_asn1_time_get): For OpenSSL >= 1.1.1,
convert the certificate's ASN1_TIME directly via ASN1_TIME_to_tm()
instead of reconstructing it as apr_time_now() + ASN1_TIME_diff().
The latter samples the current time twice (once explicitly, once
inside ASN1_TIME_diff()); if the wall clock ticks over a second
between the two reads, the result is off by one second. This is a
real, reproducible race, not a theoretical one: forcing the two
reads to straddle a second boundary reproduces it in 29-39 out of
40 trials. It intermittently broke the exact-timestamp assertions
in test/modules/md/test_920_status.py::test_md_920_002.
* changes-entries/md-asn1-time-race.txt: Add entry.
GitHub: closes#838
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1939271 13f79535-47bb-0310-9956-ffa450edef68
A MultiViews response took the media type of the selected file as it
was, so the qs source quality set with AddType was sent to the client.
Drop it after the variant has been selected. Other parameters are kept.
PR: 53595
GitHub: closes#824
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1939268 13f79535-47bb-0310-9956-ffa450edef68
cache_strqtok() did not end a token at a comma or whitespace unless an
argument followed, so "private, no-store" was read as one token and the
response was stored. Stop at any non-token character, after the '='
test.
This is a trunk-only regression from r1856507, which rewrote the
tokenizer as a state machine and dropped the T_HTTP_TOKEN_STOP check in
the token state that r1856493 and r1856500 still had.
PR: 70028
GitHub: closes#821
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1939267 13f79535-47bb-0310-9956-ffa450edef68
Stop reading (and writing) one byte past the end of a file
description when it ends inside an unterminated "&" entity or "<"
tag, as a ScanHTMLTitles title can.
* modules/generators/mod_autoindex.c (terminate_description): Check
for the terminating NUL before advancing past it when scanning an
unterminated "<" tag or "&" entity, and break out of the loop at
end of string rather than continuing past it.
* test/modules/generators/env.py (GeneratorsTestSetup.__init__): Load
mod_autoindex for the generators test suite.
* test/modules/generators/htdocs/autoindex/: New test content.
* test/modules/generators/test_002_autoindex.py (TestAutoindex): New
test that a ScanHTMLTitles description ending in a bare "&" is
rendered without reading past the end of the description.
Submitted by: arshiya tabasum <arshi bugqore.com>
GitHub: closes#812
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1939181 13f79535-47bb-0310-9956-ffa450edef68
* .github/workflows/linux.yml: Add a "Python pytest test suites,
64-bit ARM" job to the matrix, as the existing pytest job but on
the ubuntu-24.04-arm runner.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
GitHub: closes#855
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1939169 13f79535-47bb-0310-9956-ffa450edef68
* test/clients/h2ws.c (main): Use int for the getopt() return value;
with unsigned char (e.g. on aarch64) the -1 terminator is never
matched, so every invocation failed with "invalid option".
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
GitHub: PR #855
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1939168 13f79535-47bb-0310-9956-ffa450edef68
to a script from 256 to APACHE_ARG_MAX, and bound URI/query/env-value
lengths against the configured request limits rather than APR_PATH_MAX.
PR 70270.
* changes-entries/cgid-env-limit.txt: Add changelog entry.
* modules/generators/mod_cgid.c: Replace ENV_COUNT_MAX with ENV_VAL_MAX,
a sanity bound on the length of a single environment variable value.
(get_req): Take the main server_rec as an argument. Allow up to
APACHE_ARG_MAX environment variables; check uri_len and args_len
against the configured LimitRequestLine rather than APR_PATH_MAX;
check each environment variable value against ENV_VAL_MAX.
(send_req): Fail with APR_ENOSPC if more than APACHE_ARG_MAX
environment variables are present.
(cgid_server): Pass main_server to get_req.
* test/modules/generators/htdocs/cgi/: New tests scripts.
* test/modules/generators/test_001_cgid.py: New tests.
Submitted by: Emmanuel Dreyfus <manu netbsd.org>, jorton
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
GitHub: closes#850
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1939165 13f79535-47bb-0310-9956-ffa450edef68
modules/generators/mod_cgi.c (cgi_handler): For the CGI bucket
creation-error path, return a 503 rather than a 500 and log via
log_scripterror().
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1939164 13f79535-47bb-0310-9956-ffa450edef68
ap_size_parameter_parse() returned APR_ERANGE for a value without any
digits where the libc sets EINVAL when nothing is converted (FreeBSD,
musl), and APR_EINVAL with glibc. end == parameter tells portably that
nothing was converted, so check it before the apr_strtoff() status.
APR_EINVAL is for invalid syntax, APR_ERANGE stays for overflow and
underflow.
Use it for LimitXMLRequestBody too, which had its own apr_strtoff()
parsing from #825, so that it reports the same errors as
LimitRequestBody on every platform. No change in the accepted values.
Extend test_012 to check that LimitRequestBody reports invalid syntax
and range errors with their own messages, and to cover
LimitXMLRequestBody.
GitHub: closes#848
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1939163 13f79535-47bb-0310-9956-ffa450edef68
h2_session_shutdown() passed its reason, an APR or nghttp2 status, as the
error code of the GOAWAY frame. A connection timeout was sent as 70007
(APR_TIMEUP), an inadequate TLS connection as 22 (APR_EINVAL).
Give h2_session_shutdown() the HTTP/2 error code as a separate argument.
Timeouts and graceful shutdowns send NO_ERROR, failures INTERNAL_ERROR
and inadequate TLS parameters INADEQUATE_SECURITY.
PR: 70212
GitHub: closes#799
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1939156 13f79535-47bb-0310-9956-ffa450edef68
dav_method_options() builds its own Allow field and unconditionally
advertised TRACE for existing DAV resources, even when TraceEnable was
off.
Respect TraceEnable when constructing the DAV Allow field.
PR: 70264
GitHub: closes#827
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1939146 13f79535-47bb-0310-9956-ffa450edef68
Add ap_size_parameter_parse(), a helper to parse a configuration value
as an apr_off_t, which fails on trailing characters and on overflow.
The range of the value remains up to the directive.
Use it for configuration directives which parsed such values in
different ways, some of them accepting trailing characters or doing no
checks at all: LimitRequestBody (unchanged behavior), ScriptLogLength,
ScriptLogBuffer, DavQuota, BufferSize, AuthFormSize, and the
mod_cache_disk and mod_cache_socache size and time directives.
GitHub: closes#829
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1939129 13f79535-47bb-0310-9956-ffa450edef68
* changes-entries/deflate-xlen-unsigned.txt: Add changes entry.
* modules/filters/mod_deflate.c (consume_zlib_flags): Cast the
FEXTRA length bytes through unsigned char before widening so a
byte with the high bit set is not sign-extended, fixing inflation
of gzip streams carrying an extra field.
Submitted by: arshiya tabasum <arshi bugqore.com>
GitHub: closes#839
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1939124 13f79535-47bb-0310-9956-ffa450edef68
set_limit_xml_req_body() used atol(), so "abc123" and "123abc" were
accepted as 0 and 123, and a value out of range of a long gave an
undefined result. Parse the whole argument with apr_strtoff() like
LimitRequestBody, and reject values that do not fit in limit_xml_body
or exceed AP_MAX_LIMIT_XML_BODY.
PR: 69975
GitHub: closes#825
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1939121 13f79535-47bb-0310-9956-ffa450edef68
consistency and we could use a dummy file in 2.4.x
so changes-entries/ is not dropped by git every
time `make update-changes` empties it.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1939103 13f79535-47bb-0310-9956-ffa450edef68
On Windows, a subrequest (against a different per-dir config?)
could get and cleanup an LDC that the main subrequest will also
cleanup.
Also don't use ldc->r for trace if null for any reason
Submitted by: covener
Github: closes#830
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1939088 13f79535-47bb-0310-9956-ffa450edef68