Commit Graph

132 Commits

Author SHA1 Message Date
324ae13e8e core: follow up to r1891148: WC bucket defaulting to FLUSH bucket.
Define WC bucket semantics as:
/**
 * @brief Write Completion (WC) bucket
 *
 * A WC bucket is a FLUSH bucket with special ->data == &ap_bucket_wc_data,
 * still both AP_BUCKET_IS_WC() and APR_BUCKET_IS_FLUSH() hold for them so
 * they have the same semantics for most filters, namely:
 *   Everything produced before shall be passed to the next filter, including
 *   the WC/FLUSH bucket itself.
 * The distinction between WC and FLUSH buckets is only for filters that care
 * about write completion (calling ap_filter_reinstate_brigade() with non-NULL
 * flush_upto), those can setaside WC buckets and the preceding data provided
 * they have first determined that the next filter(s) have pending data
 * already, usually by calling ap_filter_should_yield(f->next).
 */

The only filters that care about write completion for now are
ap_core_output_filter() and ssl_io_filter_output(), which try to fill
in the pipe as much as possible, using ap_filter_reinstate_brigade(&flush_upto)
to determine whether they should flush (blocking) or setaside their remaining
data.

So ap_filter_reinstate_brigade() is made to not treat WC as FLUSH buckets and
keep the above filters working as before (and correctly w.r.t. above WC bucket
semantics).

* include/ap_mmn.h, include/util_filter.h:
  Axe specific ap_bucket_type_wc and define global &ap_bucket_wc_data address to
  mark WC buckets checked by AP_BUCKET_IS_WC().

* server/util_filter.c (ap_filter_reinstate_brigade):
  Don't treat WC buckets as FLUSH buckets.



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1892468 13f79535-47bb-0310-9956-ffa450edef68
2021-08-20 09:36:19 +00:00
891c3237d4 core: Write Completion (WC) bucket type.
A WC bucket is meant to prevent buffering/coalescing filters from retaining
data, but unlike a FLUSH bucket it won't cause the core output filter to
block trying to flush anything before.

It can be passed by async handlers which want to never block, followed by
ap_filter_should_yield() to check for pending data and eventually suspend
processing until MPM/asynchronous write completion finishes.

In this commit it's used that way by the tunneling loop of mod_proxy to
prevent SSL coaslescing.

gh: closes #200


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1891148 13f79535-47bb-0310-9956-ffa450edef68
2021-06-29 21:16:21 +00:00
3c6b925a2a util_filter: export ap_filter_adopt_brigade() since mod_ssl uses it.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1877548 13f79535-47bb-0310-9956-ffa450edef68
2020-05-10 12:34:53 +00:00
1b59b52292 Follow up to r1840265: really privatize ap_filter_{recycle,adopt_brigade}().
Move ap_filter_adopt_brigade()'s declaration to "server/core.h" (private).

For ap_filter_recycle(), make it static/internal to util_filter (renamed to
recycle_dead_filters() which better fits what it does). It's now also called
unconditionally from ap_filter_input_pending() which itself is always called
after the request processing and from MPM event (as input_pending hook).


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1840611 13f79535-47bb-0310-9956-ffa450edef68
2018-09-11 21:21:40 +00:00
5ab81a73c1 Follow up to r1840149: core input filter pending data.
Since r1840149 ap_core_input_filter() can't use use f->[priv->]bb directly, so
ap_filter_input_pending() stopped accounting for its pending data.

But ap_core_input_filter() can't (and doesn't need to) setaside its socket
bucket, so ap_filter_setaside_brigade() is not an option. This commit adds
ap_filter_adopt_brigade() which simply moves the given buckets (brigade) into
f->priv->bb, and since this is not something to be done blindly (the buckets
need to have c->pool/bucket_alloc lifetime, which is the case in the core
filter) the function is not AP_DECLAREd/exported thus can be used in core only.

With ap_filter_adopt_brigade() and ap_filter_reinstate_brigade(), the core
input is now ap_filter_input_pending() friendly.

Also, ap_filter_recycle() is no more part of the API (AP_DECLARE removed too),
there really is no point to call it outside core code. MAJOR bumped once again
because of this.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1840265 13f79535-47bb-0310-9956-ffa450edef68
2018-09-06 22:48:28 +00:00
e70b8bfbcd util_filter: protect ap_filter_t private fields from external (ab)use.
Introduce opaque struct ap_filter_private to move ap_filter_t "pending", "bb"
and "deferred_pool" fields to the "priv" side of things.

This allows to trust values set internally (only!) in util_filter code, and
make useful assertions between the different functions calls, along with the
usual nice extensibility property.

Likewise, the private struct ap_filter_conn_ctx in conn_rec (from r1839997)
allows now to implement the new ap_acquire_brigade() and ap_release_brigade()
functions useful to get a brigade with c->pool's lifetime. They obsolete
ap_reuse_brigade_from_pool() which is replaced where previously used.

Some comments added in ap_request_core_filter() regarding the lifetime of the
data it plays with, up to EOR...

MAJOR bumped (once again).


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1840149 13f79535-47bb-0310-9956-ffa450edef68
2018-09-05 17:27:43 +00:00
0093e3ad22 core: follow up to r1839997: some runtime optimizations.
We don't mind about cleaning up a connection filter when its pool is being
cleaned up already. For request filters, let pending_filter_cleanup() do
nothing if the given filter is not pending (anymore), which allows to save a
cleanup kill when the filter is removed.

Clear (zero) the reused filters (ap_filter_t) on reuse rather than cleanup,
then a single APR_RING_CONCAT() can be used to recycle dead_filters in a one
go.

Always call ap_filter_recycle() in ap_filter_output_pending(), even if no
filter is pending, and while at it fix s/ap_filter_recyle/ap_filter_recycle/
silly typo.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1840028 13f79535-47bb-0310-9956-ffa450edef68
2018-09-04 10:32:10 +00:00
5262e7e73a core: follow up to r1839997: recycle request filters to a delayed ring first.
We want not only ap_filter_output_pending() to be able to access each pending
filter's *f after the EOR is destroyed, but also each request filter to do
the same until it returns.

So request filters are now always cleaned up into a dead_filters ring which is
merged into spare_filters only when ap_filter_recycle() is called explicitely,
that is in ap_process_request_after_handler() and ap_filter_output_pending().

The former takes care of recycling at the end of the request, with any MPM,
while the latter keeps recycling during MPM event's write completion.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1840002 13f79535-47bb-0310-9956-ffa450edef68
2018-09-04 02:40:49 +00:00
0a61dd979a core: always allocate filters (ap_filter_t) on f->c->pool.
When filters are allocated on f->r->pool, they may be destroyed any time
underneath themselves which makes it hard for them to be passed the EOR and
forward it (*f can't be dereferenced anymore when the EOR is destroyed, thus
before request filters return).

On the util_filter side, it also makes it impossible to flush pending request
filters when they have set aside the EOR, since f->bb can't be accessed after
it's passed to the f->next.

So we always use f->c->pool to allocate filters and pending brigades, and to
avoid leaks with keepalive requests (long living connections handling multiple
requests), filters and brigades are recycled with a cleanup on f->r->pool.

Recycling is done (generically) with a spare data ring (void pointers), and a
filter(s) context struct is associated with the conn_rec to maintain the rings
by connection, that is:

    struct ap_filter_conn_ctx {
        struct ap_filter_ring *pending_input_filters;
        struct ap_filter_ring *pending_output_filters;

        struct ap_filter_spare_ring *spare_containers,
                                    *spare_brigades,
                                    *spare_filters,
                                    *spare_flushes;
        int flushing;
    };

MMN major bumped (again).


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1839997 13f79535-47bb-0310-9956-ffa450edef68
2018-09-03 23:49:46 +00:00
ee0e1be9c3 util_filter: split pending filters ring in two: input and output ones.
Pending input and output are now maintained separately in respectively
c->pending_input_filters and c->pending_output_filters, which improves
both performances and debug-ability.

Also, struct ap_filter_ring is made opaque, it's only used by util_filter
and this will allow us to later change it e.g. to a dual ring+apr_hash to
avoid quadratic search in ap_filter_prepare_brigade().

MMN major bumped due to the change in conn_rec (this is trunk only code
anyway for now).


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1839933 13f79535-47bb-0310-9956-ffa450edef68
2018-09-03 10:27:40 +00:00
abab1d4cc1 util_filter: keep filters with aside buckets in order.
Read or write of filter's pending data must happen in the same order as the
filter chain, thus we can't use an apr_hash_t to maintain the pending filters
since it provides no garantee on this matter.

Instead use an APR_RING maintained in c->pending_filters, and since both the
name (was c->filters) and the type changed, MAJOR is bumped (trunk only code
anyway so far).



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1835640 13f79535-47bb-0310-9956-ffa450edef68
2018-07-11 13:03:35 +00:00
29c346e09e Guess at fixing win32 build regression on trunk introduced by r1734656
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1829381 13f79535-47bb-0310-9956-ffa450edef68
2018-04-17 17:57:13 +00:00
36552743a7 Off by one "make dox" warning
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1746206 13f79535-47bb-0310-9956-ffa450edef68
2016-05-30 21:08:56 +00:00
64eaf888e9 core: Extend support for setting aside data from the network input filter
to any connection or request input filter.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1734656 13f79535-47bb-0310-9956-ffa450edef68
2016-03-12 00:43:58 +00:00
84051c1c9f mpm: Add a complete_connection hook that confirms whether an MPM is allowed
to leave the WRITE_COMPLETION phase. Move filter code out of the MPMs.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1731253 13f79535-47bb-0310-9956-ffa450edef68
2016-02-19 15:00:05 +00:00
615f97f933 core: Extend support for asynchronous write completion from the
network filter to any connection or request filter.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1706669 13f79535-47bb-0310-9956-ffa450edef68
2015-10-04 10:10:51 +00:00
42829738d9 Useful extensions...
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1458456 13f79535-47bb-0310-9956-ffa450edef68
2013-03-19 19:09:40 +00:00
d275f854fa Add some __attribute__ for automatic format checking.
Correct one catch in sed0.c.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1418556 13f79535-47bb-0310-9956-ffa450edef68
2012-12-07 23:39:05 +00:00
6a25b57e0d Give the opportunity to the compiler to compute at compile time the strlen of the given
string. Most of the calls to ap_fputs are done with constant strings.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1409437 13f79535-47bb-0310-9956-ffa450edef68
2012-11-14 21:41:19 +00:00
75dad9d44f Rename ap_func_attr_* macros to AP_FN_ATTR_*
Add macro for attribute alloc_size on newer gcc's


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1229134 13f79535-47bb-0310-9956-ffa450edef68
2012-01-09 13:06:18 +00:00
f66d79b8b2 Use varargs...
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1205894 13f79535-47bb-0310-9956-ffa450edef68
2011-11-24 15:53:16 +00:00
d2342460fd Add ap_pass_brigade_fchk() which does a Filter CHecK on the
brigade pass.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1205419 13f79535-47bb-0310-9956-ffa450edef68
2011-11-23 14:52:43 +00:00
103f776c25 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@1174748 13f79535-47bb-0310-9956-ffa450edef68
2011-09-23 13:38:09 +00:00
20633f6349 Avoid "`sentinel' attribute directive ignored" warning with gcc 3.x
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1134906 13f79535-47bb-0310-9956-ffa450edef68
2011-06-12 10:40:17 +00:00
ce6e4de41a Fix some doxygen warnings
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1043710 13f79535-47bb-0310-9956-ffa450edef68
2010-12-08 21:59:46 +00:00
dbd0f3d74a Tweak some doxygen comments to get these functions to show up in
the right places in the generated doc.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1032275 13f79535-47bb-0310-9956-ffa450edef68
2010-11-07 13:36:48 +00:00
ed451e94d1 re-order many struct members for better alignment on 64bit
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@959464 13f79535-47bb-0310-9956-ffa450edef68
2010-06-30 22:34:05 +00:00
7189b776db Run filter "init" functions exactly once per request. No longer run
init functions for connection filters (doing an "init" once per
handler invocation makes no sense for a connection filter).  No longer 
run init functions multiple times per request if a subrequest is used.

* include/util_filter.h (ap_filter_rec_t): Clarify use of the init
  function pointer.

* server/config.c (invoke_filter_init): Drop ap_ prefix for private
  function; take a request_rec pointer and only invoke filters with
  matching request.
  (ap_invoke_handler): Adjust accordingly.

PR: 49328
Reviewed by: rpluem


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@953311 13f79535-47bb-0310-9956-ffa450edef68
2010-06-10 12:52:49 +00:00
04fd4abf90 Fix a lot of doxygen warnings. Thanks to Brad Hards for the patch.
I added a few more fixes, and there are still more that might
need a doxygen expert.

PR: 48061
Submitted by: Brad Hards
Reviewed by: poirier


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@830527 13f79535-47bb-0310-9956-ffa450edef68
2009-10-28 13:25:49 +00:00
db9af5a634 Update comments in util_filter.h about bucket and brigade ownership to reflect
current practice and the advice from manual/developer/output-filters.xml.

Submitted by: Rici Lake <rici ricilake.net>
Reviewed by: Stefan Fritsch, Joe Orton


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@822870 13f79535-47bb-0310-9956-ffa450edef68
2009-10-07 19:35:09 +00:00
d494d1c1f5 * include/util_filter.h (ap_fputstrs): Mark with sentinel attribute
for gcc >= 4.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@726060 13f79535-47bb-0310-9956-ffa450edef68
2008-12-12 15:57:39 +00:00
51c4443fcc Prevent AP_FILTER_ERROR from being misinterpreted as SUSPENDED when checking
the status code returned by a handler by updating the values of the filter
error macros and consolidating them in httpd.h 



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@721677 13f79535-47bb-0310-9956-ffa450edef68
2008-11-29 12:57:42 +00:00
8026ae5889 Further to r599711; document new API guarantee for handling non-NULL
request_rec pointer when adding connection filters; minor MMN bump:

* server/util_filter.c (add_any_filter_handle): Set f->r for
  connection filters even if passed-in r is non-NULL.  Style nit fix
  also.

* include/util_filter.h (ap_add_output_filter,
  ap_add_output_filter_handle): Document new API guarantee.

* include/ap_mmn.h: Minor MMN bump.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@600473 13f79535-47bb-0310-9956-ffa450edef68
2007-12-03 10:55:58 +00:00
de659cbed0 update license header text
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@420983 13f79535-47bb-0310-9956-ffa450edef68
2006-07-11 20:33:53 +00:00
948d14fd23 Fix comment
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@412721 13f79535-47bb-0310-9956-ffa450edef68
2006-06-08 10:56:22 +00:00
dd95d7c37c Update the copyright year in all .c, .h and .xml files
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@395228 13f79535-47bb-0310-9956-ffa450edef68
2006-04-19 12:11:27 +00:00
f193cbabee Make ap_register_output_filter back into a function (*sigh*)
but update its API doc


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@315041 13f79535-47bb-0310-9956-ffa450edef68
2005-10-12 20:43:25 +00:00
5134335bee Make ap_register_output_filter a #define
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@315024 13f79535-47bb-0310-9956-ffa450edef68
2005-10-12 20:18:33 +00:00
8c1e315d3f Doxygen fixup / cleanup
submited by: Neale Ranns neale ranns.org
reviewed by: Ian Holsman



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@263931 13f79535-47bb-0310-9956-ffa450edef68
2005-08-28 23:03:59 +00:00
905cdf9f0b Update copyright year to 2005 and standardize on current copyright owner line.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@151408 13f79535-47bb-0310-9956-ffa450edef68
2005-02-04 20:28:49 +00:00
62f6d3d6bd Change FilterDeclare/FilterProvider semantics as discussed in
http://marc.theaimsgroup.com/?l=apache-httpd-dev&m=109899588616670&w=2


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@105646 13f79535-47bb-0310-9956-ffa450edef68
2004-10-31 18:00:43 +00:00
a5278a9c0b Fixup broken handling of range header.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@105613 13f79535-47bb-0310-9956-ffa450edef68
2004-10-28 13:21:08 +00:00
ae6b8dcb99 Move ap_filter_provider_t back out of public API
(suggested by nd; makes sense to niq)


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@105603 13f79535-47bb-0310-9956-ffa450edef68
2004-10-27 09:20:33 +00:00
a9a11aab67 allow <= and >= for filter dispatcher
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@105507 13f79535-47bb-0310-9956-ffa450edef68
2004-10-17 18:31:44 +00:00
551b03d1fb use more speaking names
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@105501 13f79535-47bb-0310-9956-ffa450edef68
2004-10-17 15:44:21 +00:00
c3e84f509a more style
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@105500 13f79535-47bb-0310-9956-ffa450edef68
2004-10-17 15:18:56 +00:00
59d38e22e1 save spaces! Soon in future we're going to run out of spaces!!!
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@105499 13f79535-47bb-0310-9956-ffa450edef68
2004-10-17 14:25:04 +00:00
72fb770d1a Merge mod_filter with util_filter structs; add API for protocol stuff.
Rename FilterDebug directive to FilterTrace.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@105226 13f79535-47bb-0310-9956-ffa450edef68
2004-09-21 10:14:40 +00:00
75fe3d7ce2 PR: 19688
Fix incorrect (and important) comments


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@105089 13f79535-47bb-0310-9956-ffa450edef68
2004-09-12 15:50:43 +00:00
eeb57c17ad fix name of The Apache Software Foundation
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@102619 13f79535-47bb-0310-9956-ffa450edef68
2004-02-09 20:40:53 +00:00