Commit f34ac2e9 authored by Paul Querna's avatar Paul Querna
Browse files

*) Create an optional function and MPM Query to replace the core output filter.

*) Put an example of using it into the Event MPM, which just calls the original core output filter.  


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/async-dev@278652 13f79535-47bb-0310-9956-ffa450edef68
parent f6d71b73
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -2,6 +2,9 @@
Changes with Apache 2.3.0
  [Remove entries to the current 2.0 and 2.2 section below, when backported]
  *) Enable MPMs to easily override the core output filter.
     [Paul Querna]
  *) httpd.exe/apachectl -V: display the DYNAMIC_MODULE_LIMIT setting, as
     in 1.3.  [Jeff Trawick]
+1 −0
Original line number Diff line number Diff line
@@ -146,6 +146,7 @@ AP_DECLARE(apr_status_t) ap_os_create_privileged_process(
#define AP_MPMQ_MAX_DAEMONS          12  /* Max # of daemons by config   */
#define AP_MPMQ_MPM_STATE            13  /* starting, running, stopping  */
#define AP_MPMQ_IS_ASYNC             14  /* MPM can process async connections  */
#define AP_MPMQ_CUSTOM_WRITE         15  /* MPM uses a custom output filter */

/**
 * Query a property of the current MPM.  
+4 −0
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@

#include "apr.h"
#include "apr_buckets.h"
#include "apr_optional.h"

#include "httpd.h"

@@ -587,6 +588,9 @@ AP_DECLARE(void) ap_filter_protocol(ap_filter_t* f, unsigned int proto_flags);
/** Filter is incompatible with "Cache-Control: no-transform" */
#define AP_FILTER_PROTO_TRANSFORM 0x20

APR_DECLARE_OPTIONAL_FN(apr_status_t, ap_mpm_custom_write_filter,
                        (ap_filter_t *f, apr_bucket_brigade *b)); 

#ifdef __cplusplus
}
#endif
+27 −4
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@
#include "apr_hash.h"
#include "apr_thread_proc.h"    /* for RLIMIT stuff */
#include "apr_hooks.h"
#include "apr_optional.h"

#define APR_WANT_IOVEC
#define APR_WANT_STRFUNC
@@ -48,6 +49,7 @@
#include "mod_core.h"
#include "mod_proxy.h"
#include "ap_listen.h"
#include "ap_mpm.h"

#include "mod_so.h" /* for ap_find_loaded_module_symbol */

@@ -90,10 +92,13 @@ AP_IMPLEMENT_HOOK_RUN_ALL(int, get_mgmt_items,
/* Handles for core filters */
AP_DECLARE_DATA ap_filter_rec_t *ap_subreq_core_filter_handle;
AP_DECLARE_DATA ap_filter_rec_t *ap_core_output_filter_handle;
AP_DECLARE_DATA ap_filter_rec_t *ap_core_mpm_write_filter_handle;
AP_DECLARE_DATA ap_filter_rec_t *ap_content_length_filter_handle;
AP_DECLARE_DATA ap_filter_rec_t *ap_net_time_filter_handle;
AP_DECLARE_DATA ap_filter_rec_t *ap_core_input_filter_handle;

static APR_OPTIONAL_FN_TYPE(ap_mpm_custom_write_filter) *mpm_write_func;

/* magic pointer for ErrorDocument xxx "default" */
static char errordocument_default;

@@ -3676,9 +3681,25 @@ APR_OPTIONAL_FN_TYPE(ap_logio_add_bytes_out) *logio_add_bytes_out;

static int core_post_config(apr_pool_t *pconf, apr_pool_t *plog, apr_pool_t *ptemp, server_rec *s)
{
    int mpm_write = 0;

    logio_add_bytes_out = APR_RETRIEVE_OPTIONAL_FN(ap_logio_add_bytes_out);
    ident_lookup = APR_RETRIEVE_OPTIONAL_FN(ap_ident_lookup);

    if (ap_mpm_query(AP_MPMQ_CUSTOM_WRITE, &mpm_write) == APR_SUCCESS
        && mpm_write == 1) {
        mpm_write_func = APR_RETRIEVE_OPTIONAL_FN(ap_mpm_custom_write_filter);

        ap_core_output_filter_handle =
            ap_register_output_filter("CORE", mpm_write_func,
                                      NULL, AP_FTYPE_NETWORK);
    }
    else {
        ap_core_output_filter_handle =
            ap_register_output_filter("CORE", ap_core_output_filter,
                                      NULL, AP_FTYPE_NETWORK);
    }

    ap_set_version(pconf);
    ap_setup_make_content_type(pconf);
    return OK;
@@ -3853,7 +3874,10 @@ static int core_pre_connection(conn_rec *c, void *csd)

    ap_set_module_config(net->c->conn_config, &core_module, csd);
    ap_add_input_filter_handle(ap_core_input_filter_handle, net, NULL, net->c);
    ap_add_output_filter_handle(ap_core_output_filter_handle, net, NULL, net->c);

    ap_add_output_filter_handle(ap_core_output_filter_handle, net, 
                                NULL, net->c);

    return DONE;
}

@@ -3898,9 +3922,8 @@ static void register_hooks(apr_pool_t *p)
    ap_content_length_filter_handle =
        ap_register_output_filter("CONTENT_LENGTH", ap_content_length_filter,
                                  NULL, AP_FTYPE_PROTOCOL);
    ap_core_output_filter_handle =
        ap_register_output_filter("CORE", ap_core_output_filter,
                                  NULL, AP_FTYPE_NETWORK);


    ap_subreq_core_filter_handle =
        ap_register_output_filter("SUBREQ_CORE", ap_sub_req_output_filter,
                                  NULL, AP_FTYPE_CONTENT_SET);
+1 −1
Original line number Diff line number Diff line

LTLIBRARY_NAME    = libevent.la
LTLIBRARY_SOURCES = event.c fdqueue.c pod.c
LTLIBRARY_SOURCES = event.c event_filters.c fdqueue.c pod.c

include $(top_srcdir)/build/ltlib.mk
Loading