You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Jeff Trawick <tr...@gmail.com> on 2015/10/07 14:26:07 UTC

Re: svn commit: r1707161 - in /httpd/httpd/trunk: docs/manual/mod/core.xml include/ap_mmn.h include/http_core.h include/httpd.h server/core.c server/request.c server/util_filter.c

On Tue, Oct 6, 2015 at 6:33 PM, <mi...@apache.org> wrote:

> Author: minfrin
> Date: Tue Oct  6 22:33:03 2015
> New Revision: 1707161
>
> URL: http://svn.apache.org/viewvc?rev=1707161&view=rev
> Log:
> Add the AsyncFilter directive that allows the asynchronous filter
> functionality to be switched off for certain classes of filters.
>
> Modified:
>     httpd/httpd/trunk/docs/manual/mod/core.xml
>     httpd/httpd/trunk/include/ap_mmn.h
>     httpd/httpd/trunk/include/http_core.h
>     httpd/httpd/trunk/include/httpd.h
>     httpd/httpd/trunk/server/core.c
>     httpd/httpd/trunk/server/request.c
>     httpd/httpd/trunk/server/util_filter.c
>
> Modified: httpd/httpd/trunk/docs/manual/mod/core.xml
> URL:
> http://svn.apache.org/viewvc/httpd/httpd/trunk/docs/manual/mod/core.xml?rev=1707161&r1=1707160&r2=1707161&view=diff
>
> ==============================================================================
> --- httpd/httpd/trunk/docs/manual/mod/core.xml (original)
> +++ httpd/httpd/trunk/docs/manual/mod/core.xml Tue Oct  6 22:33:03 2015
> @@ -552,6 +552,32 @@ AllowOverrideList CookieTracking CookieN
>  </directivesynopsis>
>
>  <directivesynopsis>
> +    <name>AsyncFilter</name>
> +    <description>Set the minimum filter type eligible for asynchronous
> handling</description>
> +    <syntax>AsyncFilter request|connection|network</syntax>
> +    <default>AsyncFilter request</default>
> +    <contextlist><context>server config</context><context>virtual
> host</context></contextlist>
> +    <compatibility>Only available from Apache 2.5.0 and
> later.</compatibility>
> +
> +    <usage>
> +        <p>This directive controls the minimum filter levels that are
> eligible
> +        for asynchronous handling. This may be necessary to support
> legacy external
> +        filters that did not handle meta buckets correctly.</p>
> +
> +        <p>If set to "network", asynchronous handling will be limited to
> the network
> +        filter only. If set to "connection", all connection and network
> filters
> +        will be eligible for asynchronous handling, including
> <module>mod_ssl</module>.
> +        If set to "request", all filters will be eligible for
> asynchronous handling.</p>
> +
> +        <p>With <directive>ProtocolsHonorOrder</directive> set to
> <code>on</code>
> +            (default), the client ordering does not matter and only the
> ordering
> +            in the server settings influences the outcome of the protocol
> +            negotiation.</p>
> +
> +    </usage>
> +</directivesynopsis>
> +
> +<directivesynopsis>
>  <name>CGIMapExtension</name>
>  <description>Technique for locating the interpreter for CGI
>  scripts</description>
>
> Modified: httpd/httpd/trunk/include/ap_mmn.h
> URL:
> http://svn.apache.org/viewvc/httpd/httpd/trunk/include/ap_mmn.h?rev=1707161&r1=1707160&r2=1707161&view=diff
>
> ==============================================================================
> --- httpd/httpd/trunk/include/ap_mmn.h (original)
> +++ httpd/httpd/trunk/include/ap_mmn.h Tue Oct  6 22:33:03 2015
> @@ -494,6 +494,7 @@
>   *                         ap_filter_reinstate_brigade() and
>   *                         ap_filter_should_yield(). Add empty and
> filters to
>   *                         conn_rec.
> + * 20150222.6 (2.5.0-dev)  Add async_filter to conn_rec.
>   */
>
>  #define MODULE_MAGIC_COOKIE 0x41503235UL /* "AP25" */
> @@ -501,7 +502,7 @@
>  #ifndef MODULE_MAGIC_NUMBER_MAJOR
>  #define MODULE_MAGIC_NUMBER_MAJOR 20150222
>  #endif
> -#define MODULE_MAGIC_NUMBER_MINOR 5                 /* 0...n */
> +#define MODULE_MAGIC_NUMBER_MINOR 6                 /* 0...n */
>
>  /**
>   * Determine if the server's current MODULE_MAGIC_NUMBER is at least a
>
> Modified: httpd/httpd/trunk/include/http_core.h
> URL:
> http://svn.apache.org/viewvc/httpd/httpd/trunk/include/http_core.h?rev=1707161&r1=1707160&r2=1707161&view=diff
>
> ==============================================================================
> --- httpd/httpd/trunk/include/http_core.h (original)
> +++ httpd/httpd/trunk/include/http_core.h Tue Oct  6 22:33:03 2015
> @@ -711,6 +711,8 @@ typedef struct {
>
>      apr_array_header_t *protocols;
>      int protocols_honor_order;
> +    int async_filter;
> +    int async_filter_set:1;
>

"unsigned"  is a better choice for this; I think we fixed all of the signed
bit fields in httpd, some out of necessity IIRC

 } core_server_config;
>
>  /* for AddOutputFiltersByType in core.c */
>
> Modified: httpd/httpd/trunk/include/httpd.h
> URL:
> http://svn.apache.org/viewvc/httpd/httpd/trunk/include/httpd.h?rev=1707161&r1=1707160&r2=1707161&view=diff
>
> ==============================================================================
> --- httpd/httpd/trunk/include/httpd.h (original)
> +++ httpd/httpd/trunk/include/httpd.h Tue Oct  6 22:33:03 2015
> @@ -1198,6 +1198,9 @@ struct conn_rec {
>
>      /** Hashtable of filters with setaside buckets for write completion */
>      apr_hash_t *filters;
> +
> +    /** The minimum level of filter type to allow setaside buckets */
> +    int async_filter;
>  };
>
>  struct conn_slave_rec {
>
> Modified: httpd/httpd/trunk/server/core.c
> URL:
> http://svn.apache.org/viewvc/httpd/httpd/trunk/server/core.c?rev=1707161&r1=1707160&r2=1707161&view=diff
>
> ==============================================================================
> --- httpd/httpd/trunk/server/core.c (original)
> +++ httpd/httpd/trunk/server/core.c Tue Oct  6 22:33:03 2015
> @@ -481,7 +481,8 @@ static void *create_core_server_config(a
>
>      conf->protocols = apr_array_make(a, 5, sizeof(const char *));
>      conf->protocols_honor_order = -1;
> -
> +    conf->async_filter = 0;
> +
>      return (void *)conf;
>  }
>
> @@ -555,12 +556,16 @@ static void *merge_core_server_configs(a
>                             ? virt->merge_trailers
>                             : base->merge_trailers;
>
> -    conf->protocols = ((virt->protocols->nelts > 0)?
> +    conf->protocols = ((virt->protocols->nelts > 0) ?
>                         virt->protocols : base->protocols);
> -    conf->protocols_honor_order = ((virt->protocols_honor_order < 0)?
> +    conf->protocols_honor_order = ((virt->protocols_honor_order < 0) ?
>                                         base->protocols_honor_order :
>                                         virt->protocols_honor_order);
> -
> +    conf->async_filter = ((virt->async_filter_set) ?
> +                                       virt->async_filter :
> +                                       base->async_filter);
> +    conf->async_filter_set = base->async_filter_set ||
> virt->async_filter_set;
> +
>      return conf;
>  }
>
> @@ -3887,6 +3892,34 @@ static const char *set_http_protocol(cmd
>      return NULL;
>  }
>
> +static const char *set_async_filter(cmd_parms *cmd, void *dummy,
> +                                             const char *arg)
> +{
> +    core_server_config *conf =
> +    ap_get_core_module_config(cmd->server->module_config);
> +    const char *err = ap_check_cmd_context(cmd, NOT_IN_DIR_LOC_FILE);
> +
> +    if (err) {
> +        return err;
> +    }
> +
> +    if (strcasecmp(arg, "network") == 0) {
> +        conf->async_filter = AP_FTYPE_NETWORK;
> +    }
> +    else if (strcasecmp(arg, "connection") == 0) {
> +        conf->async_filter = AP_FTYPE_CONNECTION;
> +    }
> +    else if (strcasecmp(arg, "request") == 0) {
> +        conf->async_filter = 0;
> +    }
> +    else {
> +        return "AsyncFilter must be 'network', 'connection' or 'request'";
> +    }
> +    conf->async_filter_set = 1;
> +
> +    return NULL;
> +}
> +
>  static const char *set_http_method(cmd_parms *cmd, void *conf, const char
> *arg)
>  {
>      const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
> @@ -4502,6 +4535,9 @@ AP_INIT_ITERATE("Protocols", set_protoco
>  AP_INIT_TAKE1("ProtocolsHonorOrder", set_protocols_honor_order, NULL,
> RSRC_CONF,
>                "'off' (default) or 'on' to respect given order of
> protocols, "
>                "by default the client specified order determines
> selection"),
> +AP_INIT_TAKE1("AsyncFilter", set_async_filter, NULL, RSRC_CONF,
> +              "'network', 'connection' (default) or 'request' to limit
> the "
> +              "types of filters that support asynchronous handling"),
>  { NULL }
>  };
>
> @@ -5010,6 +5046,7 @@ static conn_rec *core_create_conn(apr_po
>      c->bucket_alloc = alloc;
>      c->empty = apr_brigade_create(c->pool, c->bucket_alloc);
>      c->filters = apr_hash_make(c->pool);
> +    c->async_filter = sconf->async_filter;
>
>      c->clogging_input_filters = 0;
>
>
> Modified: httpd/httpd/trunk/server/request.c
> URL:
> http://svn.apache.org/viewvc/httpd/httpd/trunk/server/request.c?rev=1707161&r1=1707160&r2=1707161&view=diff
>
> ==============================================================================
> --- httpd/httpd/trunk/server/request.c (original)
> +++ httpd/httpd/trunk/server/request.c Tue Oct  6 22:33:03 2015
> @@ -2043,6 +2043,15 @@ AP_CORE_DECLARE_NONSTD(apr_status_t) ap_
>      apr_status_t status = APR_SUCCESS;
>      apr_bucket_brigade *tmp_bb = f->ctx;
>
> +    /*
> +     * Handle the AsyncFilter directive. We limit the filters that are
> +     * eligible for asynchronous handling here.
> +     */
> +    if (f->frec->ftype < f->c->async_filter) {
> +        ap_remove_output_filter(f);
> +        return ap_pass_brigade(f->next, bb);
> +    }
> +
>      if (!tmp_bb) {
>          tmp_bb = f->ctx = apr_brigade_create(f->r->pool,
> f->c->bucket_alloc);
>      }
>
> Modified: httpd/httpd/trunk/server/util_filter.c
> URL:
> http://svn.apache.org/viewvc/httpd/httpd/trunk/server/util_filter.c?rev=1707161&r1=1707160&r2=1707161&view=diff
>
> ==============================================================================
> --- httpd/httpd/trunk/server/util_filter.c (original)
> +++ httpd/httpd/trunk/server/util_filter.c Tue Oct  6 22:33:03 2015
> @@ -894,6 +894,14 @@ AP_DECLARE(apr_status_t) ap_filter_reins
>  AP_DECLARE(int) ap_filter_should_yield(ap_filter_t *f)
>  {
>      /*
> +     * Handle the AsyncFilter directive. We limit the filters that are
> +     * eligible for asynchronous handling here.
> +     */
> +    if (f->frec->ftype < f->c->async_filter) {
> +        return 0;
> +    }
> +
> +    /*
>       * This function decides whether a filter should yield due to buffered
>       * data in a downstream filter. If a downstream filter buffers we
>       * must back off so we don't overwhelm the server. If this function
>
>
>


-- 
Born in Roswell... married an alien...
http://emptyhammock.com/