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
processing is completed, avoiding orphaned callback pointers.
[Brett Gervasoni <brettg senseofsecurity.com>, Jeff Trawick]
+ *) core: Filter init functions are now run strictly once per request
+ before handler invocation. The init functions are no longer run
+ for connection filters. PR 49328. [Joe Orton]
+
*) core: Adjust the output filter chain correctly in an internal
redirect from a subrequest, preserving filters from the main
request as necessary. PR 17629. [Joe Orton]
/** The function to call when this filter is invoked. */
ap_filter_func filter_func;
- /** The function to call before the handlers are invoked. Notice
- * that this function is called only for filters participating in
- * the http protocol. Filters for other protocols are to be
- * initialized by the protocols themselves.
+ /** The function to call directly before the handlers are invoked
+ * for a request. The init function is called once directly
+ * before running the handlers for a request or subrequest. The
+ * init function is never called for a connection filter (with
+ * ftype >= AP_FTYPE_CONNECTION). Any use of this function for
+ * filters for protocols other than HTTP is specified by the
+ * module supported that protocol.
*/
ap_init_filter_func filter_init_func;
return create_empty_config(p);
}
-static int ap_invoke_filter_init(ap_filter_t *filters)
+/* Invoke the filter_init_func for all filters with FILTERS where f->r
+ * matches R. Restricting to a matching R avoids re-running init
+ * functions for filters configured for r->main where r is a
+ * subrequest. */
+static int invoke_filter_init(request_rec *r, ap_filter_t *filters)
{
while (filters) {
- if (filters->frec->filter_init_func) {
+ if (filters->frec->filter_init_func && filters->r == r) {
int result = filters->frec->filter_init_func(filters);
if (result != OK) {
return result;
* run their init function to let them do any magic before we could
* start generating data.
*/
- result = ap_invoke_filter_init(r->input_filters);
+ result = invoke_filter_init(r, r->input_filters);
if (result != OK) {
return result;
}
- result = ap_invoke_filter_init(r->output_filters);
+ result = invoke_filter_init(r, r->output_filters);
if (result != OK) {
return result;
}