1
0
mirror of https://github.com/apache/httpd.git synced 2026-01-13 21:42:17 +03:00
Commit Graph

267 Commits

Author SHA1 Message Date
Yann Ylavic
8fb0b6f980 mpm_{prefork,worker}: follow up to r1635521.
Don't crash when there is no accept mutex (one listener => apr_proc_mutex_name(NULL)).

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1643179 13f79535-47bb-0310-9956-ffa450edef68
2014-12-05 07:57:57 +00:00
Yann Ylavic
4669bc745b 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).


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1640763 13f79535-47bb-0310-9956-ffa450edef68
2014-11-20 16:26:04 +00:00
Yann Ylavic
9d670bcfdf mpm_event(opt), mpm_worker: follow up to r1635521.
Allocate retained idle_spawn_rate vector on the process pool.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1640161 13f79535-47bb-0310-9956-ffa450edef68
2014-11-17 13:59:36 +00:00
Yann Ylavic
c5d85f6439 mpm_worker, mpm_prefork: follow up to r1635521.
Use one dedicated accept mutex per listeners bucket.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1640145 13f79535-47bb-0310-9956-ffa450edef68
2014-11-17 11:45:29 +00:00
Yann Ylavic
61d5a3c1ca MPMs, core: make duplicated listeners (SO_REUSEPORT) introduced in r1599531
less intrusive.

Submitted by: Yingqi Lu <yingqi.lu@intel.com>
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
default.

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.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1635521 13f79535-47bb-0310-9956-ffa450edef68
2014-10-30 15:24:58 +00:00
Yann Ylavic
7ecfc45fdf core: follow up to r1629909: fix min_spare_threads lower bound and check wrt num_buckets.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1629990 13f79535-47bb-0310-9956-ffa450edef68
2014-10-07 21:59:02 +00:00
Yann Ylavic
d2bec9df64 core: ensure that MPMs return an error on runtime failure and hence that
httpd's main process also exits with an error.



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1629925 13f79535-47bb-0310-9956-ffa450edef68
2014-10-07 16:54:31 +00:00
Yann Ylavic
90d30c63e0 mpms: enforce assertion that unreachable code is not reached.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1629918 13f79535-47bb-0310-9956-ffa450edef68
2014-10-07 15:46:05 +00:00
Yann Ylavic
a527db4331 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).



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1629909 13f79535-47bb-0310-9956-ffa450edef68
2014-10-07 15:16:02 +00:00
Jan Kaluža
3bd97552e9 worker MPM: Fix null-dereference crash when using -DFOREGROUND with worker MPM
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1620569 13f79535-47bb-0310-9956-ffa450edef68
2014-08-26 11:05:37 +00:00
Yann Ylavic
d2e9cc1e16 Mark all unused/duplicated/closed child listeners as inactive.
Fix unused "ap_listen_rec *lr;" in worker_run().


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1602826 13f79535-47bb-0310-9956-ffa450edef68
2014-06-16 09:28:01 +00:00
Yann Ylavic
9f9dc4c4d2 -MPMs prefork & worker: avoid segfault with SAFE_ACCEPT in ONE_PROCESS mode.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1601170 13f79535-47bb-0310-9956-ffa450edef68
2014-06-07 22:04:48 +00:00
Jim Jagielski
e91b9104df fix restart issues
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1600656 13f79535-47bb-0310-9956-ffa450edef68
2014-06-05 13:38:08 +00:00
Jim Jagielski
db0457b3b2 Break out common code to be share-able
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1599641 13f79535-47bb-0310-9956-ffa450edef68
2014-06-03 16:02:44 +00:00
Jim Jagielski
cdf5c0570f Now allow MPMs to call ap_log_common()
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1599603 13f79535-47bb-0310-9956-ffa450edef68
2014-06-03 15:25:59 +00:00
Jim Jagielski
c539206da2 Optimize w/ duplicated listeners and use of SO_REUSEPORT
where available.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1599531 13f79535-47bb-0310-9956-ffa450edef68
2014-06-03 13:07:29 +00:00
Mike Rumph
ebd3ed2bf8 Fix some comment typos
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1594301 13f79535-47bb-0310-9956-ffa450edef68
2014-05-13 17:50:39 +00:00
Jeff Trawick
d7a099b80c worker MPM: Don't forcibly kill worker threads if the child process is
exiting gracefully.

Submitted by: Oracle, via trawick

This modification was made some years ago for Oracle HTTP Server
by an Oracle employee.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1526220 13f79535-47bb-0310-9956-ffa450edef68
2013-09-25 16:23:28 +00:00
Christophe Jaillet
08b6d16ffc Log a warning if ThreadStackSize has an inappropriate value.
PR : 54311
Submitted by: Tianyin Xu <tixu cs ucsd edu>

Only event.c has been compiled on my system. The 2 others are just cut and paste.
I have left the same value for APLOGNO in event and eventopt has for the other logged messages. I don't know if it is the right way to do.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1433682 13f79535-47bb-0310-9956-ffa450edef68
2013-01-15 21:53:07 +00:00
Jim Jagielski
1d0042a397 missed one
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1410004 13f79535-47bb-0310-9956-ffa450edef68
2012-11-15 20:57:23 +00:00
Jim Jagielski
3452941de8 no longer needed
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1409273 13f79535-47bb-0310-9956-ffa450edef68
2012-11-14 17:45:42 +00:00
Jim Jagielski
a24b85145b Pull out the "extended" pod functions used by event and worker
to core, since it will be used by Simple and Lean and
likely other MPMs. Avoid duplication.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1409214 13f79535-47bb-0310-9956-ffa450edef68
2012-11-14 14:26:26 +00:00
Jeff Trawick
4f5b52d406 Follow up to r1363557:
Refactor with some existing code to slightly optimize thread tracking.

Fix an implementation problem affecting statically linked MPMs which 
would break the ability to fail restart if a resource shortage was
found immediately.

Found by: rjung


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1364601 13f79535-47bb-0310-9956-ffa450edef68
2012-07-23 12:15:39 +00:00
Jeff Trawick
932dec80a8 mpm_event, mpm_worker: Remain active amidst prevalent child process
resource shortages.

This is a somewhat different direction than r168182 ("transient thread
creation errors shouldn't take down the whole server").

r168182: If APEXIT_CHILDSICK is received and there aren't any
         active children at the time, exit.

Now:     If APEXIT_CHILDSICK is received and we never successfully
         initialized a child, exit.

The issue seen with the r168182 handling is that it is rather easy
to be left with no active child processes (which causes the server
to exit completely) during a resource shortage that lasts for some
measurable period of time, as contrasted with a resource shortage 
that results in only a handful of allocation failures.

Now the server will remain active, though as long as the resource
shortage exists children may continually fail and the parent will
try once per second to create a replacement.  The existing logic
to reduce the spawn rate after such errors will prevent the 
parent from trying to create children more rapidly.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1363557 13f79535-47bb-0310-9956-ffa450edef68
2012-07-19 21:31:52 +00:00
Jeff Trawick
7b1e88d285 mpm_event, mpm_worker: Fix cases where the spawn rate wasn't reduced
after child process resource shortages.

The broken scenario:

  child X exits with APEXIT_CHILDSICK
  another child Y is created and reuses child X's scoreboard slot
  child X's exit status is processed

The case that worked is when child X's scoreboard slot hadn't
been reused by the time that its exit status was processed.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1363440 13f79535-47bb-0310-9956-ffa450edef68
2012-07-19 17:54:13 +00:00
Stefan Fritsch
92e366007c Add lots of unique tags to error log messages
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1209766 13f79535-47bb-0310-9956-ffa450edef68
2011-12-02 23:02:04 +00:00
Jeff Trawick
00b4adb3b1 revert accidental commit 1200129
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1200140 13f79535-47bb-0310-9956-ffa450edef68
2011-11-10 04:19:21 +00:00
Jeff Trawick
e4f5c7198e clean up unused ap_my_generation variable
(presence is odd, since this variable as an API was supposedly removed
  long ago, and a similarly named static variable was removed in r1078286)


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1200129 13f79535-47bb-0310-9956-ffa450edef68
2011-11-10 04:10:42 +00:00
Stefan Fritsch
7d0348cd78 If a child is created just before graceful restart and then exits because
of a missing lock file, don't shutdown the whole server.

PR: 39311
Submitted by: Shawn Michael <smichael rightnow com>


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1180742 13f79535-47bb-0310-9956-ffa450edef68
2011-10-09 23:10:12 +00:00
Jim Jagielski
427c85bd23 Cleanup effort in prep for GA push:
Trim trailing whitespace... no func change



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1174751 13f79535-47bb-0310-9956-ffa450edef68
2011-09-23 13:39:32 +00:00
Stefan Fritsch
01ed21af9d Add wrappers for malloc, calloc, realloc that check for out of memory
situations.  Use them in most places where malloc, and friends are used.
This results in clean error messages in an out of memory situation instead of
segfaulting or silently malfunctioning. In some places, it just allows to
remove some logging code.

PR 51568, PR 51569, PR 51571.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1172686 13f79535-47bb-0310-9956-ffa450edef68
2011-09-19 16:25:42 +00:00
Stefan Fritsch
d4e7fad995 Install signal handlers for crashes before detaching. Previously, there
was a time span where crashes would be neither visible on the console nor
logged in the error log.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1151234 13f79535-47bb-0310-9956-ffa450edef68
2011-07-26 20:37:49 +00:00
Stefan Fritsch
344dbd4e82 Reduce period during startup and restart where a successive signal may be lost
PR: 43696
Submitted by: Arun Bhalla <arun shme net>


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1151233 13f79535-47bb-0310-9956-ffa450edef68
2011-07-26 20:36:56 +00:00
Stefan Fritsch
4b3f0aaf96 Log the deprecation warning at level info, not warn
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1137813 13f79535-47bb-0310-9956-ffa450edef68
2011-06-20 22:57:24 +00:00
Stefan Fritsch
5f2cf595f0 Fix search'n'replace error: Actually warn if MaxClients is used
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1137757 13f79535-47bb-0310-9956-ffa450edef68
2011-06-20 19:47:23 +00:00
Stefan Fritsch
6d8de2ff42 Rename MaxClients to MaxRequestWorkers which describes more accurately what
it does.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1137744 13f79535-47bb-0310-9956-ffa450edef68
2011-06-20 19:00:52 +00:00
Jeff Trawick
462c69e0b5 Add child_status hook for tracking creation/termination of MPM child
processes.  Add end_generation hook for notification when the last
MPM child of a generation exits.

end_generation is implemented completely by core using the
child_status hook run by the MPM.

simple and mpmt_os2 MPMs don't currently run the child_status
hook, so neither hook is invoked with those MPMs.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1096609 13f79535-47bb-0310-9956-ffa450edef68
2011-04-25 21:21:22 +00:00
Jeff Trawick
3c0476fe50 Simplify the interface to ap_reclaim_child_processes() and
ap_relieve_child_processes(): instead of requiring the MPM
to implement an otherwise-useless hook, just use a callback
function.

As I don't expect third-party MPM devs are following our day
to day progress, the API changes are considered part of
yesterday's MMN change.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1087085 13f79535-47bb-0310-9956-ffa450edef68
2011-03-30 21:32:10 +00:00
Jeff Trawick
5e3ba7d3ee mpm_common.c implements a handful of config directives; the
related state has to be re-initialized to the default values
at pre-config time, but that was handled inconsistently by
the MPMs, resulting in unexpected behavior when some of the
directives were removed across restart

move that necessary initialization from the MPMs to common 
code run from core's pre-config; MPMs that need to override
defaults can do so by running after core's pre-config (the 
NetWare MPM now does that)

the DEFAULT_MAX_REQUESTS_PER_CHILD compile setting wasn't useful
enough to keep

the simple MPM wasn't consistent in which of these directives
were respected and which weren't, and that hasn't changed
(see procmgr.max_requests_per_child vs. ap_max_requests_per_child)


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1086293 13f79535-47bb-0310-9956-ffa450edef68
2011-03-28 16:25:20 +00:00
Jeff Trawick
7be2d26631 consolidate logic to remove the pidfile in a new API,
ap_remove_pid(), related to existing ap_log_pid() and
ap_read_pid()

presumably this is useful to third-party MPMs as well


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1086224 13f79535-47bb-0310-9956-ffa450edef68
2011-03-28 13:35:08 +00:00
Joe Orton
239188a96b * server/mpm/prefork/prefork.c (set_signals): Ignore SIGXFSZ; have a
write() beyond 2GB fail with E2BIG rather than killing the process
  in the now hopefully rare case of non-LFS file usage on LFS systems.

* server/mpm/worker/worker.c (set_signals): Likewise.
* server/mpm/event/event.c (set_signals): Likewise.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1084000 13f79535-47bb-0310-9956-ffa450edef68
2011-03-21 22:36:45 +00:00
Jeff Trawick
4487fa925a worker, event, prefork: Correct several issues when built as
DSOs; most notably, the scoreboard was reinitialized during graceful
restart, such that processes of the previous generation were not
observable.

Other noticeable ones:
* the generation number did not increment properly
* worker's check-config hook didn't detect startup properly,
  so messages about inconsistent directives could have been sent
  to the wrong place

max_daemons_limit wasn't tracked across restart, but as the scoreboard
was always cleared this was a non-issue.

Reinitialization of idle_spawn_rate, hold_off_on_exponential_spawning,
and maxclients-message-reported may or may not have been features,
but the big picture is that the behaviour shouldn't have differed.

These changes should have been part of r758185.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1078286 13f79535-47bb-0310-9956-ffa450edef68
2011-03-05 13:36:09 +00:00
Jeff Trawick
21a628f138 zap needless reinitialization of is_graceful on the 2nd
call of the open-logs hook


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1078285 13f79535-47bb-0310-9956-ffa450edef68
2011-03-05 13:09:12 +00:00
Jeff Trawick
3b75c26516 sanity check use of volatile in prefork, worker, and event
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1078170 13f79535-47bb-0310-9956-ffa450edef68
2011-03-04 22:12:21 +00:00
Jeff Trawick
b7a8638aca worker: child_main() never returns, so remove some dead code after
one of the calls


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1076614 13f79535-47bb-0310-9956-ffa450edef68
2011-03-03 13:16:14 +00:00
Stefan Fritsch
5bcd082e3d Rename MaxRequestsPerChild to MaxConnectionsPerChild, which
describes more accurately what the directive does.

The old name still works but logs a warning.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1021924 13f79535-47bb-0310-9956-ffa450edef68
2010-10-12 21:12:37 +00:00
Stefan Fritsch
ebb62867fb Use the new APLOG_USE_MODULE/AP_DECLARE_MODULE macros everywhere to take
advantage of per-module loglevels


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@951895 13f79535-47bb-0310-9956-ffa450edef68
2010-06-06 16:59:50 +00:00
Rainer Jung
6c696580ea Silence compiler warning.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@951866 13f79535-47bb-0310-9956-ffa450edef68
2010-06-06 14:04:06 +00:00
Jeff Trawick
007951df35 fix compile failure in r940981
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@941454 13f79535-47bb-0310-9956-ffa450edef68
2010-05-05 20:01:22 +00:00
William A. Rowe Jr
01d300298f Catch up with ap_[proc|global]_mutex_create api change
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@940981 13f79535-47bb-0310-9956-ffa450edef68
2010-05-04 17:40:43 +00:00