Checkout Tools
  • last updated 2 hours ago
Constraints: committers
Constraints: files
Constraints: dates
* server/mpm/prefork/prefork.c (prefork_pre_config): Use pconf as

passed to the hook with ap_fatal_signal_child_setup, since

prefork.c's pconf "global" is not set until the (later) open_logs

hook, and if built as a DSO it may be reset inbetween.

* server/mpm/motorz/motorz.c (motorz_pre_config): Likewise.

[event and worker do not appear to have the same issue]

  1. … 1 more file in changeset.
Fix spelling errors found by codespell. [skip ci]

  1. … 100 more files in changeset.
MPMs unix: bind the bucket number of each child to its slot number

We need not remember each child's bucket number in SHM for restarts, for the

lifetime of the httpd main process the bucket number can be bound to the slot

number such that: bucket = slot % num_buckets.

This both simplifies the logic and helps children maintenance per bucket in

threaded MPMs, where previously perform_idle_server_maintenance() could create

or kill children processes for the buckets it was not in charge of.

  1. … 5 more files in changeset.
MPMs: early initialize scoreboard's child generation number.

Since [mpm]_note_child_killed uses the scoreboard's generation number for

child_status hook (MPM_CHILD_EXITED), we must initialize it early (i.e. in

[mpm]_note_child_started where MPM_CHILD_STARTED is set) to avoid race

conditions on restart (e.g. storm/loop of restarts) leading to AH00546.

PR 62658.

  1. … 5 more files in changeset.
Revert r1814112, it does not work for threaded MPMs.

  1. … 2 more files in changeset.
incorporate review comments from Rüdiger

  1. … 1 more file in changeset.
Add "AcceptErrorsNonFatal" directive

This tweaks accept() failure processing by having ap_unixd_accept

pass more errors up, and having the MPM's check against a macro

to see if they are in a whitelist of non ENETDOWN/EMFILE kind

of potential process-wide errors.

Default behavior is still to exit.

edit: MMN bump in 1820099.

  1. … 8 more files in changeset.
mpm_unix(es): cleanup properly on exit in one_process mode.

We can't destroy ap_pglobal because clean_child_exit() runs in DSO which would

be unloaded under us, so use atexit() to defer the final apr_terminate().

[Reverted by 1822535]

  1. … 2 more files in changeset.
core, MPMs unix: follow up to r1809881.

Deregister all hooks first (in pre_cleanup), by doing it last we could still

have had them run when DSOs were unloaded.

Likewise, avoid double faults when handling fatal signals by restoring the

default handler before pconf is cleared (we can't ap_log_error there).

Finally, we need to ignore sig_term/restart (do nothing) when the main

process is exiting (i.e. ap_pglobal is destroyed), since retained_data are


Aimed to fix all faults in PR 61558.

  1. … 6 more files in changeset.
MPMs unix: Place signals handlers and helpers out of DSOs to avoid

a possible crash if a signal is caught during (graceful) restart.

PR 60487.

  1. … 8 more files in changeset.
Fix spelling in comments and text files.

No functional change.

PR 59990

  1. … 69 more files in changeset.
mpms: follow up to r1629925: more error reports.

Failing to setup (or no) listeners is also an error.

  1. … 4 more files in changeset.
mpms: follow up to r1629925: more error reports.

We want to be able to distinguish errors from stops to exit() with non-zero.

  1. … 2 more files in changeset.
Join multi-line MPM startup log messages into

single long lines.

Followup to r1725394 and r1725548.

  1. … 6 more files in changeset.
Added some more log numbers to log statements that

had none.

Those were not detected by the coccinelle script.

Only a few hard cases are remaining now.

  1. … 12 more files in changeset.
Added many log numbers to log statements that

had none.

Handled all files in server/mpm/.

I used the coccinelle script provided by Stefan.

  1. … 6 more files in changeset.
fixing compile errors due to if assignment warnings
  1. … 2 more files in changeset.
Fix crash in ap_mpm_pod_check call caused by NULL dereference of its parameter

when starting httpd as single process (httpd -X).

  1. … 2 more files in changeset.
core: Follow up to r1599601: s/ap_log_common/ap_log_mpm_common/.
  1. … 9 more files in changeset.
mpm_{worker,prefork}: save some cycles by not copying the listener's pollfds

for each pollset operation.

We don't need a copy when poll()ing if those are allocated with the correct

lifetime (the listener thread) at the very beginning.

  1. … 1 more file in changeset.

mpm_{prefork,worker}: follow up to r1635521.

Don't crash when there is no accept mutex (one listener => apr_proc_mutex_name(NULL)).

  1. … 1 more file in changeset.
mpm_event(opt), mpm_worker, mpm_prefork: follow up to r1635521, r1640161.

Retain num_buckets and max_buckets accross restarts so that we can determine

whether new buckets were allocated and set their idle_spawn_rate at the same

level as the existing ones (max).

Also, adjust ap_daemons_limit and ap_daemons_to_start lower bounds at mpm_run()

time, once num_buckets is available for the current generation (previously done

at check_config time, hence before num_buckets is computed, and then with the

previous generation's value).

  1. … 3 more files in changeset.
mpm_prefork: follow up to r1635521.

Avoid oddity on bucket_make_child_record overflow.

mpm_worker, mpm_prefork: follow up to r1635521.

Use one dedicated accept mutex per listeners bucket.

  1. … 1 more file in changeset.
MPMs, core: make duplicated listeners (SO_REUSEPORT) introduced in r1599531

less intrusive.

Submitted by: Yingqi Lu <>

Modified/Committed by: ylavic

Add ListenCoresBucketsRatio which is a configurable ratio between the number of

CPU cores (online) and the number of listeners buckets to create, defaulting to

zero (so that listeners buckets become an opt-in, ie. ncpus / ratio > 1).

This could also be made an opt-out by using the previous hardcoded value (8) as


Make ap_close_listeners() act on all the listeners (including duplicated ones),

since the function is also called externally (eg. mod_cgid, mod_ssl_ct and

possibly any third party module) to cleanup opened descriptors when a process

is forked (the duplicated listeners are kept in a scoped/static variable).

Add ap_close_listeners_ex() to close a single bucket of listeners, used by the

children to close unused duplicates and internally by ap_close_listeners().

Make ap_duplicate_listeners() compute the number of buckets to be used, instead

of each MPM. This number is now based on the above ratio and will not change

unless asked to (given *num_buckets < 1, that is when the MPM does not run in

one-process mode nor after a graceful restart).

Remove some global variables (mpm_listen, enable_default_listeners) previously

used to communicate between MPMs and ap_listen, since ap_duplicate_listeners()

API can now be used to do so.

Also rename num_buckets as ap_num_listen_buckets, and prefix have_so_reuseport

with ap_ (both printed by ap_log_common(), hence kept global).

Detect ap_have_so_reuseport once only at startup.

Restore dummy_connection() as before r1599531 since sending POD signals should

not depend on the number of listeners buckets (there is still one single socket

receiving the connections).

For each MPM (concerned), move the bucket data (pod, listeners and eventually

accept mutex) into a struct and instanciate an array of them (sized by the

number of buckets), for each child to use its own data according to its bucket

index, and the parent to maintain the whole.

  1. … 9 more files in changeset.
core: ensure that MPMs return an error on runtime failure and hence that

httpd's main process also exits with an error.

  1. … 9 more files in changeset.
mpms: enforce assertion that unreachable code is not reached.
  1. … 3 more files in changeset.
core: follow up to r1629909: ap_daemons_to_start can't be lower than 1 (not 0) for prefork either.
core: Use process scoreboard to store each child's listener bucket,

and silently adjust the configured number of processes/threads to

be above the computed number of listener buckets (depending on the

CPU cores).

  1. … 5 more files in changeset.
prefork: Ignore SIGINT in child. This fixes race-condition in signals handling

when httpd is runnning on foreground and user hits ctrl+c. In this case, SIGINT

is sent to all children followed by SIGTERM from the main process, which

interrupts the SIGINT handler and leads to inconsistency (process freezes

or crashes).