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

162 Commits

Author SHA1 Message Date
Eric Covener
8197971bce Update conn_rec.id when a new thread begins working on a connection, because
the old thread may work on a new connection and assign the same ID in parallel.


Submitted By:  Michael Thorpe
Committed By: covener


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1651088 13f79535-47bb-0310-9956-ffa450edef68
2015-01-12 13:42:31 +00:00
Yann Ylavic
e6d70ea7bc mpm_event(opt): zero is immutable.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1643284 13f79535-47bb-0310-9956-ffa450edef68
2014-12-05 14:00:37 +00:00
Yann Ylavic
abb1b803d6 mpm_event(opt): avoid casts/comparisons from unsigned to signed (atomics).
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1643279 13f79535-47bb-0310-9956-ffa450edef68
2014-12-05 13:41:38 +00:00
Yann Ylavic
7791f925d3 mpm_event: follow up to r1639614 (trunk) and r1642858 (2.4.x).
Notify suspend in any case when starting lingering close (blocking),
and outside the lingering queue's critical section.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1642868 13f79535-47bb-0310-9956-ffa450edef68
2014-12-02 13:41:14 +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
f1cb9b287a event, eventopt: follow up to r1638879 and r1639960.
Clear the pool in ap_push_pool() before recycling.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1640031 13f79535-47bb-0310-9956-ffa450edef68
2014-11-16 21:32:48 +00:00
Eric Covener
b38d5d5979 don't call notify_suspend() in a worker thread after
start_lingering_close_common may have put the socket back
into the pollset. 

If it becomes readable too quickly, cs can be
free'ed or accessed concurrently.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1639614 13f79535-47bb-0310-9956-ffa450edef68
2014-11-14 12:04:46 +00:00
Eric Covener
c2d42b1214 revert r1638691, more comprehensive followup planned shortly.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1639564 13f79535-47bb-0310-9956-ffa450edef68
2014-11-14 02:24:40 +00:00
Eric Covener
051a1291c9 avoid dereferencing a recently apr_pool_clear()'ed event_conn_state_t *cs
in several paths where ptrans is being recycled at the end of a request.



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1638879 13f79535-47bb-0310-9956-ffa450edef68
2014-11-12 17:32:24 +00:00
Eric Covener
48611f3ed2 Fix a bug in r1604350 that can lead to crashes in the event MPM under load.
if start_lingering_close_blocking() returns 0, notify_suspend() will 
write a 1 into some potentially recently free'd memory from 
ptrans (cs->suspended).


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1638691 13f79535-47bb-0310-9956-ffa450edef68
2014-11-12 02:29:38 +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
71af35749e event: Fix worker-listener deadlock in graceful restart caused by get_worker()
allocating new worker after ap_queue_info_term(), but not setting the
have_idle_worker variable. PR 56960.

Submitted By: Zin UDA
Committed By: jkaluza


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1629577 13f79535-47bb-0310-9956-ffa450edef68
2014-10-06 06:07:47 +00:00
Jan Kaluža
0b98be8f60 event: have_idle_worker must not be cleared in every listener_thread iteration.
Fixes bug when workers were not stopped after graceful restart (introduced in
r1605328).


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1629576 13f79535-47bb-0310-9956-ffa450edef68
2014-10-06 05:57:02 +00:00
Eric Covener
3b7584a58d mod_proxy_wstunnel: Concurrent websockets messages could be
lost or delayed with ProxyWebsocketAsync enabled.  

Submitted By: Edward Lu
Committed By: covener


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1613493 13f79535-47bb-0310-9956-ffa450edef68
2014-07-25 18:54:03 +00:00
Rainer Jung
3c4f5a1bb3 Avoid C99 idiom.
Followup to r1604466.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1610323 13f79535-47bb-0310-9956-ffa450edef68
2014-07-13 23:26:12 +00:00
Takashi Sato
3d83bde5ef Revert r1601943, r1602058, r1605307 (socket callback returning pollfds)
Revert r1605369 (wstunnel refactoring)

per discassion on dev@httpd.a.o thread Message-ID:
<CALK=YjN9HfThP_k_rF9iJPcUhcQk9sNOaDPxZNG+HcJNWS4ZAQ@mail.gmail.com>


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1605946 13f79535-47bb-0310-9956-ffa450edef68
2014-06-27 04:17:30 +00:00
Takashi Sato
b63e4f9a27 event: minify local variables scope.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1605328 13f79535-47bb-0310-9956-ffa450edef68
2014-06-25 10:42:32 +00:00
Takashi Sato
eee719b59b follow up r1601943:
Each apr_pollset_poll modified *out_pfd, so we need to copy it.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1605307 13f79535-47bb-0310-9956-ffa450edef68
2014-06-25 09:42:41 +00:00
Eric Covener
9be0156800 followup to r1604350, move the c->sbh assignment to immediately before the
socket is added to the timeout queue. Technically not needed because we hold
the lock on the timeout queue, but more consistent with other blocks that
leave the thread.


Submitted By: Edward Lu <Chaosed0 gmail com>
Committed By: covener



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1605067 13f79535-47bb-0310-9956-ffa450edef68
2014-06-24 12:34:52 +00:00
Yann Ylavic
520e7a1441 event: Avoid timer's mutex two successive locks/unlocks with unrelated (and
optional) work in between.

Also saves declaration/usage of pointer 'ep' by reusing available 'te' instead,
and removes duplicated 'te' declaration in a local block.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1604466 13f79535-47bb-0310-9956-ffa450edef68
2014-06-21 21:45:40 +00:00
Yann Ylavic
52d5055aef event: follow up to r1604347.
Don't leak the timer event when it is cancelled.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1604451 13f79535-47bb-0310-9956-ffa450edef68
2014-06-21 20:02:23 +00:00
Eric Covener
191be1b5d6 missed a case in r1538490:
PR56639

Always NULL c->sbh before putting a connection back in a pollset or queue.

We can't NULL c->sbh at the bottom of process_socket() after putting a socket back on 
the event_pollset or having it go into lingering close, because the listener or a worker
thread could A) continue on the connection or B) free and allocate the same conn_rec
pointer before we get to the bottom of process_socket().

Submitted By: Edward Lu
Committed By: covener



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1604350 13f79535-47bb-0310-9956-ffa450edef68
2014-06-21 13:03:19 +00:00
Takashi Sato
83b56e81a0 Do not call a timeout callback after the asociated socket
woke and the socket callback was called.
PR 56642


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1604347 13f79535-47bb-0310-9956-ffa450edef68
2014-06-21 12:58:35 +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
Takashi Sato
273671f6fd style fix, no functional change.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1602544 13f79535-47bb-0310-9956-ffa450edef68
2014-06-14 02:49:35 +00:00
Takashi Sato
de08177faf eventMPM:
fix SEGV in the case socket callback was registered
and no timeout function was registered.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1602409 13f79535-47bb-0310-9956-ffa450edef68
2014-06-13 12:30:12 +00:00
Takashi Sato
0e4cf76a64 Socket event callback now takes pollfd.
User (e.g. mod_proxy_wstunnel) can know
which socket is ready.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1601943 13f79535-47bb-0310-9956-ffa450edef68
2014-06-11 16:39:34 +00:00
Yann Ylavic
ff0963e3f7 mpm_event[opt]: Send the SSL close notify alert when the KeepAliveTimeout
expires. PR54998.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1601185 13f79535-47bb-0310-9956-ffa450edef68
2014-06-07 22:57:08 +00:00
Yann Ylavic
899a843490 -MPMs event & eventopt: child listeners are used in ONE_PROCESS mode too.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1601171 13f79535-47bb-0310-9956-ffa450edef68
2014-06-07 22:24:59 +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
f3fbdef650 fold in performance hack from eventopt
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1599625 13f79535-47bb-0310-9956-ffa450edef68
2014-06-03 15:49:25 +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
Eric Covener
fba67798ed PR56333: Add an API to resume a connection that a handler has previously suspended.
Submitted by: Artem <artemciy gmail.com>, Edward Lu <Chaosed0 gmail.com>
Committed by: covener


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1593860 13f79535-47bb-0310-9956-ffa450edef68
2014-05-11 20:52:32 +00:00
Eric Covener
d758951456 Extend the socket callbacks in event to allow a timeout on the I/O callback.
When a socket callback has a timeout, an associated timer event is used to 
remove the sockets from the pollset and call a timeout function.

* This includes a noteworthy change to the main event loop. Previously,
we would call epoll, then process the timer events, then iterate through the
poll results. After this patch, the timer events are processed before the poll()
a _non-queued_ action can change the pollset conents (a users timed callback
function conversely could easily sit in a queue while the main thread continues
down into epoll)

* timer events can now have sockets associated with them, those sockets are 
removed from the pollset when the timer event fires w/o a queue to the worker.

* timer events now have a canceled flag that can be toggled without locking
the timer list. 

* Drop the severity of some wstunnel messages from DEBUG to TRACE1

* Lift the restriction on using asynchronous websockets connections but having
an idle timeout



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1593857 13f79535-47bb-0310-9956-ffa450edef68
2014-05-11 20:41:45 +00:00
Eric Covener
360c8f35f5 r1494157 from eventopt for event, per sf's review comments.
use a subpool of pchild since skiplist allocations will
happen across threads and are only protected from
other skiplist operations.



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1588806 13f79535-47bb-0310-9956-ffa450edef68
2014-04-20 17:53:38 +00:00
Jeff Trawick
5b4178100c follow-up to r1546759: remove an inadvertently committed testcase
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1546760 13f79535-47bb-0310-9956-ffa450edef68
2013-11-30 18:00:59 +00:00
Jeff Trawick
540be85c46 Add suspend_connection and resume_connection hooks to notify modules
when the thread/connection relationship changes.  (Currently implemented
only for the Event MPM; should be implemented for all async MPMs.)


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1546759 13f79535-47bb-0310-9956-ffa450edef68
2013-11-30 17:56:25 +00:00
Jeff Trawick
2571d1f90c fix whitespace in a debug message
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1546730 13f79535-47bb-0310-9956-ffa450edef68
2013-11-30 14:06:55 +00:00
Jeff Trawick
88e5f7cc40 Follow-up to r1538490:
Ensure that conn_rec->sbh is always cleared when returning from process_socket().


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1545736 13f79535-47bb-0310-9956-ffa450edef68
2013-11-26 17:11:51 +00:00
Jim Jagielski
a6b32ed9a4 Consistent types
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1545411 13f79535-47bb-0310-9956-ffa450edef68
2013-11-25 21:24:18 +00:00
Jim Jagielski
d21042e2a8 naming suggestion re: trawick
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1545408 13f79535-47bb-0310-9956-ffa450edef68
2013-11-25 21:10:05 +00:00
Jim Jagielski
43625092ad Use offset which is smack dab in the middle.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1545364 13f79535-47bb-0310-9956-ffa450edef68
2013-11-25 18:28:53 +00:00
Jim Jagielski
cc4921ed2f Use correct type...
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1545325 13f79535-47bb-0310-9956-ffa450edef68
2013-11-25 15:40:16 +00:00