Yann Ylavic [Fri, 20 Nov 2020 21:20:33 +0000 (21:20 +0000)]
mod_proxy_http2: stop/wait the workers threads before their pool is killed.
There shouldn't be any worker thread active when pchild is destroyed (thus each
thread's pool), so register workers_pool_cleanup as a pre_cleanup of pchild.
This is to avoid races like the below stacktrace, where slot_run() threads
are still running when clean_child_exit() is called.
Thread 23 (Thread 0x7f4865b79800 (LWP 3740)):
#0 0x00007f4864dec449 in pthread_cond_destroy@@GLIBC_2.3.2 () from /lib/x86_64-linux-gnu/libpthread.so.0
#1 0x00007f4865020117 in run_cleanups (cref=<optimized out>) at memory/unix/apr_pools.c:2629
#2 pool_clear_debug (pool=pool@entry=0x558a5297e4a0, file_line=0x558a5237456b "event.c:757") at memory/unix/apr_pools.c:1830
#3 0x00007f486501ffee in pool_destroy_debug (pool=0x558a5297e4a0, file_line=<optimized out>) at memory/unix/apr_pools.c:1915
#4 0x00007f48650200f0 in pool_clear_debug (pool=pool@entry=0x558a52a41070, file_line=0x558a5237456b "event.c:757") at memory/unix/apr_pools.c:1827
#5 0x00007f486501ffee in pool_destroy_debug (pool=0x558a52a41070, file_line=<optimized out>) at memory/unix/apr_pools.c:1915
#6 0x00007f486502085c in apr_pool_destroy_debug (pool=<optimized out>, file_line=<optimized out>) at memory/unix/apr_pools.c:1957
#7 0x0000558a52326cfc in clean_child_exit (code=0) at event.c:757
#8 0x0000558a52327969 in child_main (child_num_arg=child_num_arg@entry=1, child_bucket=child_bucket@entry=0) at event.c:2926
#9 0x0000558a52327ce5 in make_child (s=0x558a52c9f840, slot=slot@entry=1, bucket=0) at event.c:2992
#10 0x0000558a52327d4c in startup_children (number_to_start=2, number_to_start@entry=3) at event.c:3015
#11 0x0000558a523289ac in event_run (_pconf=<optimized out>, plog=0x558a5273ce00, s=0x558a52c9f840) at event.c:3374
#12 0x0000558a5233e91e in ap_run_mpm (pconf=0x558a5270cbe0, plog=0x558a5273ce00, s=0x558a52c9f840) at mpm_common.c:100
#13 0x0000558a5231b763 in main (argc=<optimized out>, argv=<optimized out>) at main.c:844
Thread 2 (Thread 0x7f4840b70700 (LWP 3836)):
#0 0x00007f4864dec9f3 in pthread_cond_wait@@GLIBC_2.3.2 () from /lib/x86_64-linux-gnu/libpthread.so.0
#1 0x00007f486501f65d in apr_thread_cond_wait (cond=<optimized out>, mutex=<optimized out>) at locks/unix/thread_cond.c:68
#2 0x00007f484e14ae4a in get_next (slot=0x558a528d5fe0) at h2_workers.c:209
#3 slot_run (thread=0x558a52828b30, wctx=0x558a528d5fe0) at h2_workers.c:228
#4 0x00007f4864de66db in start_thread () from /lib/x86_64-linux-gnu/libpthread.so.0
#5 0x00007f4864b0f88f in clone () from /lib/x86_64-linux-gnu/libc.so.6
Thread 1 (Thread 0x7f4841b72700 (LWP 3834)):
#0 0x00007f4864a2ce97 in raise () from /lib/x86_64-linux-gnu/libc.so.6
#1 0x00007f4864a2e801 in abort () from /lib/x86_64-linux-gnu/libc.so.6
#2 0x00007f4865020865 in apr_pool_destroy_debug (pool=<optimized out>, file_line=<optimized out>) at memory/unix/apr_pools.c:1955
#3 0x00007f486502b536 in apr_thread_exit (thd=thd@entry=0x558a52ba8980, retval=retval@entry=0) at threadproc/unix/thread.c:206
#4 0x00007f484e14aec6 in slot_run (thread=0x558a52ba8980, wctx=0x558a528d6060) at h2_workers.c:248
#5 0x00007f4864de66db in start_thread () from /lib/x86_64-linux-gnu/libpthread.so.0
#6 0x00007f4864b0f88f in clone () from /lib/x86_64-linux-gnu/libc.so.6
While at it, rename server_pool as pchild in h2_workers_create(), to make it
clear which pool it is.
Yann Ylavic [Fri, 20 Nov 2020 16:31:21 +0000 (16:31 +0000)]
mod_ssl_ct: join the threads before their parent pools are destroyed.
This can happen on stop/restart for the daeomon thread, or on clean_child_exit()
for the service thread.
When an apr_thread_create()d thread exits it destroys its pool (in any case),
either explicitely when apr_thread_exit() is called, or implicitely after the
function returns (only in APR 2.0 for now).
So we should make sure that mod_ssl_ct's daemon and service threads exit before
pconf and pchild (the parent pools, respectively) destroy their children pools,
otherwise the threads' pool will be destroyed twice and cause a crash.
Using a pre_cleanup to wait for the threads avoids this.
Yann Ylavic [Thu, 19 Nov 2020 12:12:04 +0000 (12:12 +0000)]
Make HTTP_IN filter send 100 continue in blocking mode only.
When mod_proxy_http prefetches input data it calls the HTTP_IN filter
in nonblocking mode, but since it does not want 100 continue to be sent
for every case (e.g. 100-continue forwarding), it hacks r->expecting_100
(save in req->expecting_100, reset, eventually restore..) all over the
place.
Let's avoid this by making the HTTP_IN filter send 100 continue only
when called in blocking mode (once still), instead of the first time
it's called.
* modules/http/http_filters.c (struct http_filter_ctx): Add the seen_data
bit and rename eos_sent to at_eos (HTTP_IN does not send any EOS).
* modules/http/http_filters.c (ap_http_filter): Move 100 continue
handling outside the initialization/once block, and do it in blocking
mode only. Track in ctx->seen_data whether some data were already
received, and if so don't send 100 continue per RFC 7231 5.1.1.
* modules/proxy/mod_proxy_http.c: Remove req->expecting_100 (and its
danse with r->expecting_100) now that reading from the input filters
does the right thing.
Yann Ylavic [Wed, 4 Nov 2020 00:32:50 +0000 (00:32 +0000)]
mpm_event: don't reset connections after lingering close timeout
While httpd is supposed to do lingering close for incoming data, it has no
control anyway over outgoing/pending data once they are handled by the
system.
So don't reset the connection after lingering close times out, otherwise the
system won't do its own lingering close to flush un-acked data.
The connection reset was introduced by r1802875 and backported to 2.4.28.
Yann Ylavic [Tue, 3 Nov 2020 23:58:35 +0000 (23:58 +0000)]
mpm_event: don't kill keepalive connections on connections_above_limit().
Before r1819855 (backported to 2.4.30), mpm_event killed keepalive connections
only when workers were exhausted, while this commit set workers_were_busy for
connections_above_limit().
Restore prior to r1819855 behaviour, and since ap_queue_info_num_idlers() is
now part of connections_above_limit(), let's update workers_were_busy there
only when necessary.
Joe Orton [Fri, 30 Oct 2020 10:28:30 +0000 (10:28 +0000)]
Document that KeepAliveTimeout still applies regardless of
how RequestReadTimeout is used (had some user confusion by this
since the behaviour changed within 2.4.x, e.g. PR 56729).
Joe Orton [Thu, 15 Oct 2020 16:04:12 +0000 (16:04 +0000)]
Disable mod_http2 and mod_ssl_ct for prefork builds, since the former
shouldn't be used under prefork and the latter isn't tested at all.
Possibly related to infrequent prefork child segfaults under pool-debug.
e.g. https://travis-ci.org/github/apache/httpd/jobs/736044109
is a multi-threaded prefork child dying with both mod_h2 and mod_ssl_ct
threads active.
Ruediger Pluem [Fri, 9 Oct 2020 19:32:27 +0000 (19:32 +0000)]
Adjust signal handler before unblocking
* server/mpm/event/event.c: Set the new signal handler before unblocking the
signal as otherwise queued signals get delivered to the old handler
immediately when the signal is unblocked.
* server/mpm/worker/worker.c: Same thing as with event.
Joe Orton [Thu, 17 Sep 2020 11:31:43 +0000 (11:31 +0000)]
mod_proxy: Add support for an optional third argument to ProxyRemote*
to configure the Basic auth credentials to send to the remote proxy.
(Note that credentials are always sent w/o waiting for a challenge as
with proxy-chain-auth, and only Basic is supported - both of which are
not exactly ideal - but better than nothing.)
* modules/proxy/mod_proxy.c (proxy_handler): Pass forward proxy
credentials via r->notes.
(add_proxy): Take credentials and base64-encode into ->creds field if
passed.
(add_proxy_noregex, add_proxy_regex): Take optional creds argument.
* modules/proxy/proxy_util.c (ap_proxy_determine_connection):
Use proxy credentials from r->notes if available.
(ap_proxy_create_hdrbrgd): Set Proxy-Authorization header from
credentials in r->notes if present.
Joe Orton [Tue, 15 Sep 2020 09:14:39 +0000 (09:14 +0000)]
* modules/dav/fs/repos.c (dav_fs_open_stream): Add specific logs for
different modes in dav_fs_open_stream(), indicate failure because of
different file open modes. Also add the filepath in the log messages.
Process early errors via a dummy HTTP/1.1 request as well
Process early errors via a dummy HTTP/1.1 request as well to ensure
that the request gets logged correctly and possible custom error
pages are considered. The previous way of directly sending a HTTP/2
answer with the HTTP status code appropriate for the error is more
efficient, but does not log the request nor sents a possible custom
error page.
* modules/http2/h2.h: Add http_status to h2_request struct and define
H2_HTTP_STATUS_UNSET.
* modules/http2/h2_request.c(h2_request_create_rec): Check if
http_status is set for the request and die with the
status code it contains if set.
* modules/http2/h2_session.c(on_header_cb): Adjust the error condition
now that we mark early errors via http_status: Only return an error
if the status is not success and http_status is not H2_HTTP_STATUS_UNSET.
* modules/http2/h2_stream.c(set_error_response): Set http_status
on the request instead of creating headers for a response and a
respective brigade.
Joe Orton [Tue, 8 Sep 2020 14:08:22 +0000 (14:08 +0000)]
Further re-unification of code duplicated across mod_cgi/mod_cgid into
cgi_common.h. Functional changes:
- brings the PR 61980 fix to mod_cgid as well, and
- some mod_cgid-specific APLOGNOs are dropped in favour of the
code used in the equivalent error path in mod_cgi
... otherwise no user-visible changes (intended).
* modules/generators/cgi_common.h (log_scripterror, log_script_err): Move
here from mod_cgi.
(cgi_handle_exec): Move here, renamed from mod_cgi's handle_exec.
(cgi_optfns_retrieve): New function, split out from mod_cgi's cgi_post_config.
- Embeds the HAVE_PCRE2 define as a compiler flag rather than try to work around
.h file substitutions, because the flag is only relevant to compiling the single
server/util_pcre.c file.
Restore broken win32 build, include apr/std headers before httpd headers
- In httpd we override exit() to trap the true exit code (see os/win32/os.h)
- process.h was redefining exit() which picked up the macro instead of the
original exit() declaration
- Cleaner style pulls in apr, then standard C headers, and finally sets down
the httpd includes on top of these, resolving the windows build regression
Joe Orton [Wed, 19 Aug 2020 07:26:18 +0000 (07:26 +0000)]
Follow up to r1880368 by adjusting en.xml to match lang-targets.xml.
Ran "./build.sh bootstrap" which regenerates style/xsl/util/designations.xml
which in turn will then be used to regenerate the typemap files.
[skip ci]