Stefan Eissing [Wed, 13 Apr 2022 08:38:12 +0000 (08:38 +0000)]
*) mod_http2: use the new REQUEST buckets to forward request
on secondary connections. Use the now generic
ap_process_connection() in h2 workers to process those.
Stefan Eissing [Wed, 13 Apr 2022 07:40:17 +0000 (07:40 +0000)]
Merge PR 311:
*) core/mod_http: use REQUEST meta buckets and a new HTTP/1.x specific
input filter to separate the handling for HTTP requests from the
handling of HTTP/1.x request parsing and checks.
A new HTTP1_REQUEST_IN filter installs itself on http/1.1 connections
before a request is being read. It generates either a REQUEST meta
bucket on success or an ERROR bucket with the proposed response status.
The core connection processing, relying on ap_read_request(), now expects
a REQUEST or ERROR bucket from the input filters and is agnostic to
specific HTTP versions and how they bring requests into the server.
Joe Orton [Tue, 12 Apr 2022 15:43:04 +0000 (15:43 +0000)]
Remove libsystemd dependency from main httpd binary
Until this change httpd was linking libsystemd to the main httpd binary. If you want to run lightweight version of httpd in container, sometimes you just want to install
httpd binary with as little dependencies as possible to make container small in size and do not pull uncencessary dependencies and libraries.
This change will move all systemd library calls from listen.c to mod_systemd module and remove systemd linking from the main httpd bin.
Fixed mixed declaration and wrongly declared variable.
mpm_event: Fix accounting of active/total processes on ungraceful restart.
Children processes terminated by ap_{reclaim,relieve}_child_processes() were
were not un-accounted for total_daemons and active_daemons, which was done in
server_main_loop() only. This led to perform_idle_server_maintenance() thinking
it was over the limit of children processes and never create new ones.
Have this accounting right in event_note_child_{started,stopped}() which is
called both at runtime and reload time.
* server/mpm/event/event.c(struct event_retained_data):
Rename field max_daemons_limit to max_daemon_used to better describe what
it's about and to align with AP_MPMQ_MAX_DAEMON_USED.
* server/mpm/event/event.c(event_note_child_stopped):
Renamed from event_note_child_killed() to clarify that it's not only called
when a child is killed (i.e. on restart) but whenever a child has stopped.
* server/mpm/event/event.c(event_note_child_stopped):
Move decrementing {active,total}_daemons and marking child's threads as
SERVER_DEAD from server_main_loop() so that it's done both at runtime and
reload time. Log the current number/state of daemons at APLOG_DEBUG level
for each child stopped.
* server/mpm/event/event.c(event_note_child_started):
Move incrementing {active,total}_daemons from make_child() for symmetry,
given that make_child() calls event_note_child_started(). Log the current
number/state of daemons at APLOG_DEBUG level for each child started.
* server/mpm/event/event.c(perform_idle_server_maintenance):
Fix possible miscounting of retained->max_daemon_used accross the multiple
calls to perform_idle_server_maintenance() if ListenCoresBucketsRatio > 0.
Pass an int *max_daemon_used which starts at zero and is bumped consistently
for all the buckets, while retained->max_daemon_used is updated only after
all the buckets have been maintained.
* server/mpm/event/event.c(perform_idle_server_maintenance):
Use event_note_child_stopped() to handle exited children processes.
Stefan Eissing [Thu, 7 Apr 2022 10:55:09 +0000 (10:55 +0000)]
*) mod_http2: use the new RESPONSE buckets introduced in r1899648.
This replaces the internal H2_HEADERS bucket, removing its
source file and also obsoletes any interim response parsing
needs.
Stefan Eissing [Thu, 7 Apr 2022 10:41:46 +0000 (10:41 +0000)]
*) core/mod_http: use RESPONSE meta buckets and a new HTTP/1.x specific
filter to send responses through the output filter chain.
Specifically: the HTTP_HEADER output filter and ap_send_interim_response()
create a RESPONSE bucket and no longer are concerned with HTTP/1.x
serialization.
A new HTTP1_RESPONSE_OUT transcode filter writes the proper HTTP/1.x
bytes when dealing with a RESPONSE bucket. That filter installs itself
on the pre_read_request hook when the connection has protocol 'http/1.1'.
Stefan Eissing [Wed, 6 Apr 2022 09:17:42 +0000 (09:17 +0000)]
*) core: make ap_escape_quotes() work correctly on strings
with more than MAX_INT/2 characters, counting quotes double.
Credit to <generalbugs@zippenhop.com> for finding this.
* Report a broken backend in case reading the response line failed on the
first request on this connection otherwise we assume we have just run
into a keepalive race and the backend is still healthy.
* We need to set r->status on each call after we noticed an EOC as
data bucket generators like ap_die might have changed the status
code. But we know better in this case and insist on the status
code that we have seen in the error bucket.
Stefan Eissing [Mon, 4 Apr 2022 08:24:09 +0000 (08:24 +0000)]
*) core/mod_http/mod_http2:
- adds new meta bucket types REQUEST, RESPONSE and HEADERS to the API.
- adds a new method for setting standard response headers Date and Server
- adds helper methods for formatting parts of HTTP/1.x, like headers and
end chunks for use in non-core parts of the server, e.g. mod_proxy
- splits the HTTP_IN filter into a "generic HTTP" and "specific HTTP/1.x"
filter. The latter one named HTTP1_BODY_IN.
- Uses HTTP1_BODY_IN only for requests with HTTP version <= 1.1
- Removes the chunked input simulation from mod_http2
- adds body_indeterminate flag to request_rec that indicates that a request
body may be present and needs to be read/discarded. This replaces logic
that thinks without Content-Length and Transfer-Encoding, no request
body can exist.
Ruediger Pluem [Thu, 31 Mar 2022 20:10:21 +0000 (20:10 +0000)]
* In case we see an EOC bucket and there was an error bucket before, use its
status as status for the request. This should ensure proper status logging
in the access log.
'interpolate' is a keyword, not a user-defined string.
So it should not be in <var></var> in <syntax> and <code> should be used instead of <var> in explanations.
While at it, fix some other style issues and missing links spotted here and there.
Stefan Eissing [Thu, 24 Mar 2022 10:03:59 +0000 (10:03 +0000)]
*) mod_http2: in a recent change, code was removed that prevented connections
with many parallel streams to stall. Re-added that, slightly improved and
with a comment that explains the need for future humans.
Stefan Eissing [Thu, 24 Mar 2022 09:06:29 +0000 (09:06 +0000)]
*) mod_http2: fixed a possible concurrency issue with
registering h2_mplx at h2_workers.
Improved h2_fifo internals efficiency inspired
by ap_fdqueue.
Made 711 tests repeatable.
Stefan Eissing [Mon, 21 Mar 2022 08:19:28 +0000 (08:19 +0000)]
*) mod_http2: use pollset only for main connection and wakeups
for events on streams. Provide streams in INPUT pipe when
needed and supported on the platform.
Stefan Eissing [Fri, 18 Mar 2022 09:52:52 +0000 (09:52 +0000)]
*) core: adding a new hook and method to the API:
create_secondary_connection and ap_create_secondary_connection()
to setup connections related to a "master" one, as used in
the HTTP/2 protocol implementation.
*) mod_http2: using the new API calls to get rid of knowledge
about how the core handles conn_rec specifics.
Improvements in pollset stream handling to use less sets.
Using atomic read/writes instead of volatiles now.
Keeping a reserve of "transit" pools and bucket_allocs for
use on secondary connections to avoid repeated setup/teardowns.
Stefan Eissing [Tue, 15 Mar 2022 09:38:10 +0000 (09:38 +0000)]
*) mod_http2: disabling use of apr_pollsets for secondary
connections. Measurements show that their use leads to
up to 30% performance drop on busy scenarios.
Detailed numbers in the comment where this is disabled.
Yann Ylavic [Mon, 7 Mar 2022 13:36:10 +0000 (13:36 +0000)]
core: Make sure and check that LimitXMLRequestBody fits in system memory.
LimitXMLRequestBody can not exceed the size needed to ap_escape_html2() the
body without failing to allocate memory, so enforce this at load time based
on APR_SIZE_MAX, and make sure that ap_escape_html2() is within the bounds.
Document the limits for LimitXMLRequestBody in our docs.
Yann Ylavic [Tue, 1 Mar 2022 13:26:03 +0000 (13:26 +0000)]
mod_rewrite: URI-to-filename rewrites to transparently handle proxy mappings.
Since mod_rewrite works on r->filename and mod_proxy's mapping=servlet|decoded
sets its "proxy:" URL there at pre_translate_name stage (i.e. before
mod_rewrite's translate_name hook), users have to match the full proxy URL in
their RewriteRules to handle proxy mappings, which is not very friendly nor
consistent with how proxy non-mapping requests have to be matched.
Let's use r->filename = r->uri in hook_uri2file() for pre_trans'ed reverse
proxy requests, and restore r->filename to its original value if the request
was finally DECLINED (like in hook_fixup).
But if a proxy mapping gets rewritten to a non-proxy request, clear any
proxy specific r->proxyreq or r->handler so that processing continues
accordingly.
ap_lua_init_mutex() is not about thead only . It also calls
apr_global_mutex_child_init(). So I see no good reason to skip this hook
if !APR_HAS_THREADS.
Some #if APR_HAS_THREADS are also already in place in
ap_lua_init_mutex() anyway.
Stefan Eissing [Fri, 25 Feb 2022 13:18:51 +0000 (13:18 +0000)]
*) mod_watchdog: add assertions to cleanup code
*) core/mpm_preform: do not invoke the fancy new child_stopping/stopped
hooks when invoked from a signal handler. This is a stopgap to some
strange behaviour in need of some deeper insight.
Stefan Eissing [Fri, 25 Feb 2022 09:58:48 +0000 (09:58 +0000)]
*) test: assume that modules which do not appear in our list of DSO_MODULES
or MPM_MODULES from configure are statically linked and do not need a load.
Stefan Eissing [Thu, 24 Feb 2022 13:20:19 +0000 (13:20 +0000)]
*) mod_watchdog: do not call a watchdog instance for
AP_WATCHDOG_STATE_STOPPING outside its thread, as
watchdog instances are not prepared to be invoked
concurrently.
Stefan Eissing [Thu, 24 Feb 2022 11:56:01 +0000 (11:56 +0000)]
*) mod_watchdog: use the `child_stopping` and `child_stopped` hooks
to shutdown workers before pool destruction releases global
resources and libraries.
Stefan Eissing [Thu, 24 Feb 2022 11:53:53 +0000 (11:53 +0000)]
* core/mpm: add hook 'child_stopped` that gets called when the MPM has
stopped all processing in a child process. This is when all running
threads shall be stopped and joined.
[Stefan Eissing]
Ruediger Pluem [Wed, 16 Feb 2022 12:35:36 +0000 (12:35 +0000)]
* Change the logic to choose the maximum of both timeouts (front end socket,
backend socket) instead of the minimum as backend timeouts can be
configured more selectively (per worker if needed) as front end timeouts
and typically the backend timeouts reflect the application requirements
better.