You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by wr...@apache.org on 2005/10/07 08:41:28 UTC

svn commit: r307031 - in /httpd/httpd/branches/2.2.x: CHANGES include/ap_mmn.h include/http_core.h modules/http/http_core.c server/core.c server/core_filters.c server/protocol.c

Author: wrowe
Date: Thu Oct  6 23:41:23 2005
New Revision: 307031

URL: http://svn.apache.org/viewcvs?rev=307031&view=rev
Log:
Backport Revision: 306495

  NET_TIME, as a standalone feature, was a horrid idea, so eliminate it.

  The core filter will NOT operate correctly across platforms 
  (even between Linux/Solaris) without setting up the conn->timeout,
  so always apply the timeout when establishing the core filter.

  The keep-alive-timeout is entirely an HTTP-ism, and needs to
  move to the http protocol handler.  This isn't triggered in the 
  event mpm, but the event mpm introspects s->keep_alive_timeout
  directly adding it to the pollset, so this is a non-sequitor.

  Finally, once the headers are read, the named virtual host may
  have a different (more/less permissive) timeout for the remainder
  of the request body.  This http-centric patch picks up that subtle
  detail and can switch to a named-vhost timeout.


Modified:
    httpd/httpd/branches/2.2.x/CHANGES
    httpd/httpd/branches/2.2.x/include/ap_mmn.h
    httpd/httpd/branches/2.2.x/include/http_core.h
    httpd/httpd/branches/2.2.x/modules/http/http_core.c
    httpd/httpd/branches/2.2.x/server/core.c
    httpd/httpd/branches/2.2.x/server/core_filters.c
    httpd/httpd/branches/2.2.x/server/protocol.c

Modified: httpd/httpd/branches/2.2.x/CHANGES
URL: http://svn.apache.org/viewcvs/httpd/httpd/branches/2.2.x/CHANGES?rev=307031&r1=307030&r2=307031&view=diff
==============================================================================
--- httpd/httpd/branches/2.2.x/CHANGES [utf-8] (original)
+++ httpd/httpd/branches/2.2.x/CHANGES [utf-8] Thu Oct  6 23:41:23 2005
@@ -1,6 +1,12 @@
                                                         -*- coding: utf-8 -*-
 Changes with Apache 2.1.9
 
+  *) Elimiated the NET_TIME filter, restructuring the timeout logic.
+     This provides a working mod_echo on all platforms, and ensures any
+     custom protocol module is at least given an initial timeout value
+     based on the <VirtualHost > context's Timeout directive.
+     [William Rowe]
+
   *) mod_proxy: Run the request_status hook also if there are no free workers
      or all workers are in error state.
      [Ruediger Pluem, Brian Akins <brian.akins turner.com>]

Modified: httpd/httpd/branches/2.2.x/include/ap_mmn.h
URL: http://svn.apache.org/viewcvs/httpd/httpd/branches/2.2.x/include/ap_mmn.h?rev=307031&r1=307030&r2=307031&view=diff
==============================================================================
--- httpd/httpd/branches/2.2.x/include/ap_mmn.h (original)
+++ httpd/httpd/branches/2.2.x/include/ap_mmn.h Thu Oct  6 23:41:23 2005
@@ -105,14 +105,15 @@
  * 20050701.1 (2.1.7-dev) trace_enable member added to core server_config
  * 20050708.0 (2.1.7-dev) Bump MODULE_MAGIC_COOKIE to "AP22"!
  * 20050708.1 (2.1.7-dev) add proxy request_status hook (minor)
-  */
+ * 20051006.0 (2.1.8-dev) NET_TIME filter eliminated
+ */
 
 #define MODULE_MAGIC_COOKIE 0x41503232UL /* "AP22" */
 
 #ifndef MODULE_MAGIC_NUMBER_MAJOR
-#define MODULE_MAGIC_NUMBER_MAJOR 20050708
+#define MODULE_MAGIC_NUMBER_MAJOR 20051006
 #endif
-#define MODULE_MAGIC_NUMBER_MINOR 1                     /* 0...n */
+#define MODULE_MAGIC_NUMBER_MINOR 0                     /* 0...n */
 
 /**
  * Determine if the server's current MODULE_MAGIC_NUMBER is at least a

Modified: httpd/httpd/branches/2.2.x/include/http_core.h
URL: http://svn.apache.org/viewcvs/httpd/httpd/branches/2.2.x/include/http_core.h?rev=307031&r1=307030&r2=307031&view=diff
==============================================================================
--- httpd/httpd/branches/2.2.x/include/http_core.h (original)
+++ httpd/httpd/branches/2.2.x/include/http_core.h Thu Oct  6 23:41:23 2005
@@ -600,9 +600,6 @@
 AP_CORE_DECLARE_NONSTD(const char *) ap_limit_section(cmd_parms *cmd, void *dummy, const char *arg);
 
 /* Core filters; not exported. */
-int ap_net_time_filter(ap_filter_t *f, apr_bucket_brigade *b,
-                       ap_input_mode_t mode, apr_read_type_e block,
-                       apr_off_t readbytes);
 int ap_core_input_filter(ap_filter_t *f, apr_bucket_brigade *b,
                          ap_input_mode_t mode, apr_read_type_e block,
                          apr_off_t readbytes);
@@ -641,7 +638,6 @@
 extern AP_DECLARE_DATA ap_filter_rec_t *ap_subreq_core_filter_handle;
 extern AP_DECLARE_DATA ap_filter_rec_t *ap_core_output_filter_handle;
 extern AP_DECLARE_DATA ap_filter_rec_t *ap_content_length_filter_handle;
-extern AP_DECLARE_DATA ap_filter_rec_t *ap_net_time_filter_handle;
 extern AP_DECLARE_DATA ap_filter_rec_t *ap_core_input_filter_handle;
 
 /**

Modified: httpd/httpd/branches/2.2.x/modules/http/http_core.c
URL: http://svn.apache.org/viewcvs/httpd/httpd/branches/2.2.x/modules/http/http_core.c?rev=307031&r1=307030&r2=307031&view=diff
==============================================================================
--- httpd/httpd/branches/2.2.x/modules/http/http_core.c (original)
+++ httpd/httpd/branches/2.2.x/modules/http/http_core.c Thu Oct  6 23:41:23 2005
@@ -181,11 +181,13 @@
  
         if (ap_graceful_stop_signalled())
             break;
-        /* Go straight to select() to wait for the next request */
+
         if (!csd) {
             csd = ap_get_module_config(c->conn_config, &core_module);
         }
         apr_socket_opt_set(csd, APR_INCOMPLETE_READ, 1);
+        apr_socket_timeout_set(csd, c->base_server->keep_alive_timeout);
+        /* Go straight to select() to wait for the next request */
     }
  
     return OK;

Modified: httpd/httpd/branches/2.2.x/server/core.c
URL: http://svn.apache.org/viewcvs/httpd/httpd/branches/2.2.x/server/core.c?rev=307031&r1=307030&r2=307031&view=diff
==============================================================================
--- httpd/httpd/branches/2.2.x/server/core.c (original)
+++ httpd/httpd/branches/2.2.x/server/core.c Thu Oct  6 23:41:23 2005
@@ -91,7 +91,6 @@
 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_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;
 
 /* magic pointer for ErrorDocument xxx "default" */
@@ -3759,10 +3758,6 @@
     }
     else {
         req_cfg->bb = apr_brigade_create(r->pool, r->connection->bucket_alloc);
-        if (!r->prev) {
-            ap_add_input_filter_handle(ap_net_time_filter_handle,
-                                       NULL, r, r->connection);
-        }
     }
 
     ap_set_module_config(r->request_config, &core_module, req_cfg);
@@ -3821,10 +3816,9 @@
 static int core_pre_connection(conn_rec *c, void *csd)
 {
     core_net_rec *net = apr_palloc(c->pool, sizeof(*net));
-
-#ifdef AP_MPM_DISABLE_NAGLE_ACCEPTED_SOCK
     apr_status_t rv;
 
+#ifdef AP_MPM_DISABLE_NAGLE_ACCEPTED_SOCK
     /* The Nagle algorithm says that we should delay sending partial
      * packets in hopes of getting more data.  We don't want to do
      * this; we are not telnet.  There are bad interactions between
@@ -3841,6 +3835,20 @@
                       "apr_socket_opt_set(APR_TCP_NODELAY)");
     }
 #endif
+
+    /* The core filter requires the timeout mode to be set, which
+     * incidentally sets the socket to be nonblocking.  If this
+     * is not initialized correctly, Linux - for example - will
+     * be initially blocking, while Solaris will be non blocking
+     * and any initial read will fail.
+     */
+    rv = apr_socket_timeout_set(csd, c->base_server->timeout);
+    if (rv != APR_SUCCESS) {
+        /* expected cause is that the client disconnected already */
+        ap_log_cerror(APLOG_MARK, APLOG_DEBUG, rv, c,
+                      "apr_socket_timeout_set");
+    }
+
     net->c = c;
     net->in_ctx = NULL;
     net->out_ctx = NULL;
@@ -3887,9 +3895,6 @@
     ap_core_input_filter_handle =
         ap_register_input_filter("CORE_IN", ap_core_input_filter,
                                  NULL, AP_FTYPE_NETWORK);
-    ap_net_time_filter_handle =
-        ap_register_input_filter("NET_TIME", ap_net_time_filter,
-                                 NULL, AP_FTYPE_PROTOCOL);
     ap_content_length_filter_handle =
         ap_register_output_filter("CONTENT_LENGTH", ap_content_length_filter,
                                   NULL, AP_FTYPE_PROTOCOL);

Modified: httpd/httpd/branches/2.2.x/server/core_filters.c
URL: http://svn.apache.org/viewcvs/httpd/httpd/branches/2.2.x/server/core_filters.c?rev=307031&r1=307030&r2=307031&view=diff
==============================================================================
--- httpd/httpd/branches/2.2.x/server/core_filters.c (original)
+++ httpd/httpd/branches/2.2.x/server/core_filters.c Thu Oct  6 23:41:23 2005
@@ -58,41 +58,6 @@
 
 #define AP_MIN_SENDFILE_BYTES           (256)
 
-typedef struct net_time_filter_ctx {
-    apr_socket_t *csd;
-    int           first_line;
-} net_time_filter_ctx_t;
-
-int ap_net_time_filter(ap_filter_t *f, apr_bucket_brigade *b,
-                       ap_input_mode_t mode, apr_read_type_e block,
-                       apr_off_t readbytes)
-{
-    net_time_filter_ctx_t *ctx = f->ctx;
-    int keptalive = f->c->keepalive == AP_CONN_KEEPALIVE;
-
-    if (!ctx) {
-        f->ctx = ctx = apr_palloc(f->r->pool, sizeof(*ctx));
-        ctx->first_line = 1;
-        ctx->csd = ap_get_module_config(f->c->conn_config, &core_module);        
-    }
-
-    if (mode != AP_MODE_INIT && mode != AP_MODE_EATCRLF) {
-        if (ctx->first_line) {
-            apr_socket_timeout_set(ctx->csd, 
-                                   keptalive
-                                      ? f->c->base_server->keep_alive_timeout
-                                      : f->c->base_server->timeout);
-            ctx->first_line = 0;
-        }
-        else {
-            if (keptalive) {
-                apr_socket_timeout_set(ctx->csd, f->c->base_server->timeout);
-            }
-        }
-    }
-    return ap_get_brigade(f->next, b, mode, block, readbytes);
-}
-
 /**
  * Remove all zero length buckets from the brigade.
  */

Modified: httpd/httpd/branches/2.2.x/server/protocol.c
URL: http://svn.apache.org/viewcvs/httpd/httpd/branches/2.2.x/server/protocol.c?rev=307031&r1=307030&r2=307031&view=diff
==============================================================================
--- httpd/httpd/branches/2.2.x/server/protocol.c (original)
+++ httpd/httpd/branches/2.2.x/server/protocol.c Thu Oct  6 23:41:23 2005
@@ -832,6 +832,8 @@
     const char *expect;
     int access_status;
     apr_bucket_brigade *tmp_bb;
+    apr_socket_t *csd;
+    apr_interval_time_t cur_timeout;
 
     apr_pool_create(&p, conn->pool);
     apr_pool_tag(p, "request");
@@ -892,6 +894,17 @@
         return NULL;
     }
 
+    /* We may have been in keep_alive_timeout mode, so toggle back
+     * to the normal timeout mode as we fetch the header lines,
+     * as necessary.
+     */
+    csd = ap_get_module_config(conn->conn_config, &core_module);
+    apr_socket_timeout_get(csd, &cur_timeout);
+    if (cur_timeout != conn->base_server->timeout) {
+        apr_socket_timeout_set(csd, conn->base_server->timeout);
+        cur_timeout = conn->base_server->timeout;
+    }
+
     if (!r->assbackwards) {
         ap_get_mime_headers_core(r, tmp_bb);
         if (r->status != HTTP_REQUEST_TIME_OUT) {
@@ -941,6 +954,14 @@
      * now read. may update status.
      */
     ap_update_vhost_from_headers(r);
+
+    /* Toggle to the Host:-based vhost's timeout mode to fetch the 
+     * request body and send the response body, if needed.
+     */
+    if (cur_timeout != r->server->timeout) {
+        apr_socket_timeout_set(csd, r->server->timeout);
+        cur_timeout = r->server->timeout;
+    }
 
     /* we may have switched to another server */
     r->per_dir_config = r->server->lookup_defaults;



[Patch 2.0.x] Re: svn commit: r307031 - in /httpd/httpd/branches/2.2.x: CHANGES include/ap_mmn.h include/http_core.h modules/http/http_core.c server/core.c server/core_filters.c server/protocol.c

Posted by "William A. Rowe, Jr." <wr...@rowe-clan.net>.
Folks,

the patch below cannot be literally backported to 2.0.x.  Everyone would
agree that the echo filter is inherently a DoS attack even when it's
working as expected.  But other protocol module authors have based their
code on this module; and it was dangerous precident to never establish
any timeout.

We could, obviously, throw the same hack as mod_ftp's code in mod_echo,
prior to the first get_brigade invocation;

      client_socket = ap_get_module_config(cdata->conn_config,
                                           &core_module);
      apr_socket_timeout_set(client_socket, cdata->base_server->timeout);

but that's hackish, and truly does nothing for any existing borked
protocol module out there, written by unsuspecting authors.

Here's a proposed patch for 2.0 that would move the -initial- timeout
setting from underneath NET_TIME.  Yet it would retain the NET_TIME
filter for managing keep-alive time outs, thus maintaining all binary
and nearly identical behavior compatibility in the 2.0.x branch.

Comments?


Re: MMN and branches (was Re: svn commit: r307031)

Posted by "William A. Rowe, Jr." <wr...@rowe-clan.net>.
Joe Orton wrote:
> 
> c) don't backport ABI changes to branches; a branch much fork from a 
> specific MODULE_MAGIC_NUMBER_MAJOR and must be rebased entirely to move 
> to a new major
> 
>  -> avoids the problem entirely

It's always this way on even branches, but we are talking about odd #'ed
branches, here.

> d) drop the requirement that the MMN must reflect every single ABI 
> change and make some more fundamental change

I've always considered the possibility that we only bump MMN major, by
date, exactly once when we roll rev x.y.n <shrug>.

Better idea; let's refactor the whole MMN magic in httpd 3.0?

(It's already looking, from the scope of the experimental asynch branch,
that it's likely to become 3.0.)

Bill

MMN and branches (was Re: svn commit: r307031)

Posted by Joe Orton <jo...@redhat.com>.
On Sat, Oct 08, 2005 at 04:51:51PM -0500, William Rowe wrote:
> Joe Orton wrote:
> >I'd suggest just incrementing the MMN by one rather than bumping it by 
> >date on the branch unless and until the API is the same as the trunk.
> 
> I previously considered that.  Although you are right; they are out of 
> sync, I think it's inevitable with two branches following different
> history, no?

It's not inevitable but it is the status quo ;)

> This is why the MODULE_MAGIC_COOKIE is now AP24 on svn head, because the
> two branches can't remain binary compatible, at least not except for
> some very short periods of time.
>
> Perhaps you are right, perhaps it's time to drop date stamps as the 
> MODULE_MAGIC_NUMBER_MAJOR signature?

Maintaining an MMN which is intended to reflect every single ABI change 
and multiple branches with independent ABIs is going to be a tricky 
problem.

Alternatives I can see:

a) partition the MMN major by MODULE_MAGIC_COOKIE, so modules
must test an (MODULE_MAGIC_COOKIE, MODULE_MAGIC_NUMBER_MAJOR) pair to 
target a particular API

 -> results are then reliable across history and across branches
 -> icky

b) stop bumping the MMN by date on branches, just increment by one and 
hope that enough gap is left

 -> results are then reliable across branches but not across history

c) don't backport ABI changes to branches; a branch much fork from a 
specific MODULE_MAGIC_NUMBER_MAJOR and must be rebased entirely to move 
to a new major

 -> avoids the problem entirely

d) drop the requirement that the MMN must reflect every single ABI 
change and make some more fundamental change

joe

Re: svn commit: r307031 - in /httpd/httpd/branches/2.2.x: CHANGES include/ap_mmn.h include/http_core.h modules/http/http_core.c server/core.c server/core_filters.c server/protocol.c

Posted by "William A. Rowe, Jr." <wr...@rowe-clan.net>.
Joe Orton wrote:
> I'd suggest just incrementing the MMN by one rather than bumping it by 
> date on the branch unless and until the API is the same as the trunk.

I previously considered that.  Although you are right; they are out of 
sync, I think it's inevitable with two branches following different
history, no?

This is why the MODULE_MAGIC_COOKIE is now AP24 on svn head, because the
two branches can't remain binary compatible, at least not except for
some very short periods of time.

Perhaps you are right, perhaps it's time to drop date stamps as the 
MODULE_MAGIC_NUMBER_MAJOR signature?

Bill

Re: svn commit: r307031 - in /httpd/httpd/branches/2.2.x: CHANGES include/ap_mmn.h include/http_core.h modules/http/http_core.c server/core.c server/core_filters.c server/protocol.c

Posted by Joe Orton <jo...@redhat.com>.
On Fri, Oct 07, 2005 at 06:41:28AM -0000, William Rowe wrote:
> Author: wrowe
> Date: Thu Oct  6 23:41:23 2005
> New Revision: 307031
> 
> URL: http://svn.apache.org/viewcvs?rev=307031&view=rev
> Log:
> Backport Revision: 306495
> 
> Modified: httpd/httpd/branches/2.2.x/include/ap_mmn.h
> URL: http://svn.apache.org/viewcvs/httpd/httpd/branches/2.2.x/include/ap_mmn.h?rev=307031&r1=307030&r2=307031&view=diff
> ==============================================================================
> --- httpd/httpd/branches/2.2.x/include/ap_mmn.h (original)
> +++ httpd/httpd/branches/2.2.x/include/ap_mmn.h Thu Oct  6 23:41:23 2005
> @@ -105,14 +105,15 @@
>   * 20050701.1 (2.1.7-dev) trace_enable member added to core server_config
>   * 20050708.0 (2.1.7-dev) Bump MODULE_MAGIC_COOKIE to "AP22"!
>   * 20050708.1 (2.1.7-dev) add proxy request_status hook (minor)
> -  */
> + * 20051006.0 (2.1.8-dev) NET_TIME filter eliminated
> + */
>  
>  #define MODULE_MAGIC_COOKIE 0x41503232UL /* "AP22" */
>  
>  #ifndef MODULE_MAGIC_NUMBER_MAJOR
> -#define MODULE_MAGIC_NUMBER_MAJOR 20050708
> +#define MODULE_MAGIC_NUMBER_MAJOR 20051006

The MMN major is now higher on the 2.2.x branch than on the trunk, which 
makes little sense; there are features present on the trunk which are 
missing from the branch.

I'd suggest just incrementing the MMN by one rather than bumping it by 
date on the branch unless and until the API is the same as the trunk.

joe

Re: svn commit: r307031 - in /httpd/httpd/branches/2.2.x: CHANGES include/ap_mmn.h include/http_core.h modules/http/http_core.c server/core.c server/core_filters.c server/protocol.c

Posted by "William A. Rowe, Jr." <wr...@rowe-clan.net>.
William A. Rowe, Jr. wrote:
> Brian J. France wrote:
> 
>> Will this patch allow the removal of this code from mod_ftp  
>> ftp_ssl_init function:
>>
>>     /* This is handled in the NET_TIME filter, which unfortunately
>>      * ignores the timeout for the purpose of AP_MODE_INIT.
>>      * Fix a timeout so the core read filter will behave.
>>      */
>>     client_socket = ap_get_module_config(cdata->conn_config,
>>                                          &core_module);
>>     apr_socket_timeout_set(client_socket, cdata->base_server->timeout);
> 
> 
> Yup.
> 
> mod_ftp has a number of timeouts, itself, and might possibly benefit
> some administrators if we shift to cdata->base_server->keepalive_timeout
> after the first request line is read.  This way, one could have a very
> short (e.g. 10 sec) timeout to begin processing the USER command, while
> providing the user a more generous (e.g. 180 sec) timeout between cmds.
> The more that I think about it, that shift should only happen once the
> user is authenticated.

Oh, I should point out that there was always a hack (a different one,
however) in mod_ftp - this one I came up with fixing mod_echo.  Prior to
this patch, mod_echo would succeed on Linux and Win32 (blocking forever)
and consume massive cycles on Solaris and AIX (nonblocking, and spinning
through brigade_gets perpetually.)  When mod_ssl is added to mod_echo,
it would fail outright on Solaris and AIX because the BLOCK mode would
always fail to set up the timeout.  And invoking AP_MODE_INIT always
failed as well, because the NET_TIME filter ignored it (and it was the
single most criticial get_brigade call before the protocol would reply
with an immediate write.)

So this patch had more to do with Apache, mod_echo and most protocols
(other than http) than with mod_ftp specifically.

Bill

Re: svn commit: r307031 - in /httpd/httpd/branches/2.2.x: CHANGES include/ap_mmn.h include/http_core.h modules/http/http_core.c server/core.c server/core_filters.c server/protocol.c

Posted by "William A. Rowe, Jr." <wr...@rowe-clan.net>.
Brian J. France wrote:
> Will this patch allow the removal of this code from mod_ftp  
> ftp_ssl_init function:
> 
>     /* This is handled in the NET_TIME filter, which unfortunately
>      * ignores the timeout for the purpose of AP_MODE_INIT.
>      * Fix a timeout so the core read filter will behave.
>      */
>     client_socket = ap_get_module_config(cdata->conn_config,
>                                          &core_module);
>     apr_socket_timeout_set(client_socket, cdata->base_server->timeout);

Yup.

mod_ftp has a number of timeouts, itself, and might possibly benefit
some administrators if we shift to cdata->base_server->keepalive_timeout
after the first request line is read.  This way, one could have a very
short (e.g. 10 sec) timeout to begin processing the USER command, while
providing the user a more generous (e.g. 180 sec) timeout between cmds.
The more that I think about it, that shift should only happen once the
user is authenticated.

> BTW, did subversion lose the annotate web feature?

I understand it's crippled due to being a massive memory hog, but that
the command line flavor of the same would work.

Re: svn commit: r307031 - in /httpd/httpd/branches/2.2.x: CHANGES include/ap_mmn.h include/http_core.h modules/http/http_core.c server/core.c server/core_filters.c server/protocol.c

Posted by "Brian J. France" <li...@firehawksystems.com>.
Will this patch allow the removal of this code from mod_ftp  
ftp_ssl_init function:

     /* This is handled in the NET_TIME filter, which unfortunately
      * ignores the timeout for the purpose of AP_MODE_INIT.
      * Fix a timeout so the core read filter will behave.
      */
     client_socket = ap_get_module_config(cdata->conn_config,
                                          &core_module);
     apr_socket_timeout_set(client_socket, cdata->base_server->timeout);

http://svn.apache.org/viewcvs.cgi/incubator/mod_ftp/trunk/src/ 
ftp_connection.c?view=markup

Thanks,

Brian

BTW, did subversion lose the annotate web feature?

On Oct 7, 2005, at 1:41 AM, wrowe@apache.org wrote:
> Author: wrowe
> Date: Thu Oct  6 23:41:23 2005
> New Revision: 307031
>
> URL: http://svn.apache.org/viewcvs?rev=307031&view=rev
> Log:
> Backport Revision: 306495
>
>   NET_TIME, as a standalone feature, was a horrid idea, so eliminate  
> it.
>
>   The core filter will NOT operate correctly across platforms
>   (even between Linux/Solaris) without setting up the conn->timeout,
>   so always apply the timeout when establishing the core filter.
>
>   The keep-alive-timeout is entirely an HTTP-ism, and needs to
>   move to the http protocol handler.  This isn't triggered in the
>   event mpm, but the event mpm introspects s->keep_alive_timeout
>   directly adding it to the pollset, so this is a non-sequitor.
>
>   Finally, once the headers are read, the named virtual host may
>   have a different (more/less permissive) timeout for the remainder
>   of the request body.  This http-centric patch picks up that subtle
>   detail and can switch to a named-vhost timeout.
>
>
> Modified:
>     httpd/httpd/branches/2.2.x/CHANGES
>     httpd/httpd/branches/2.2.x/include/ap_mmn.h
>     httpd/httpd/branches/2.2.x/include/http_core.h
>     httpd/httpd/branches/2.2.x/modules/http/http_core.c
>     httpd/httpd/branches/2.2.x/server/core.c
>     httpd/httpd/branches/2.2.x/server/core_filters.c
>     httpd/httpd/branches/2.2.x/server/protocol.c
>
> Modified: httpd/httpd/branches/2.2.x/CHANGES
> URL:  
> http://svn.apache.org/viewcvs/httpd/httpd/branches/2.2.x/CHANGES? 
> rev=307031&r1=307030&r2=307031&view=diff
> ======================================================================= 
> =======
> --- httpd/httpd/branches/2.2.x/CHANGES [utf-8] (original)
> +++ httpd/httpd/branches/2.2.x/CHANGES [utf-8] Thu Oct  6 23:41:23 2005
> @@ -1,6 +1,12 @@
>                                                          -*- coding:  
> utf-8 -*-
>  Changes with Apache 2.1.9
>
> +  *) Elimiated the NET_TIME filter, restructuring the timeout logic.
> +     This provides a working mod_echo on all platforms, and ensures  
> any
> +     custom protocol module is at least given an initial timeout value
> +     based on the <VirtualHost > context's Timeout directive.
> +     [William Rowe]
> +
>    *) mod_proxy: Run the request_status hook also if there are no free  
> workers
>       or all workers are in error state.
>       [Ruediger Pluem, Brian Akins <brian.akins turner.com>]
>
> Modified: httpd/httpd/branches/2.2.x/include/ap_mmn.h
> URL:  
> http://svn.apache.org/viewcvs/httpd/httpd/branches/2.2.x/include/ 
> ap_mmn.h?rev=307031&r1=307030&r2=307031&view=diff
> ======================================================================= 
> =======
> --- httpd/httpd/branches/2.2.x/include/ap_mmn.h (original)
> +++ httpd/httpd/branches/2.2.x/include/ap_mmn.h Thu Oct  6 23:41:23  
> 2005
> @@ -105,14 +105,15 @@
>   * 20050701.1 (2.1.7-dev) trace_enable member added to core  
> server_config
>   * 20050708.0 (2.1.7-dev) Bump MODULE_MAGIC_COOKIE to "AP22"!
>   * 20050708.1 (2.1.7-dev) add proxy request_status hook (minor)
> -  */
> + * 20051006.0 (2.1.8-dev) NET_TIME filter eliminated
> + */
>
>  #define MODULE_MAGIC_COOKIE 0x41503232UL /* "AP22" */
>
>  #ifndef MODULE_MAGIC_NUMBER_MAJOR
> -#define MODULE_MAGIC_NUMBER_MAJOR 20050708
> +#define MODULE_MAGIC_NUMBER_MAJOR 20051006
>  #endif
> -#define MODULE_MAGIC_NUMBER_MINOR 1                     /* 0...n */
> +#define MODULE_MAGIC_NUMBER_MINOR 0                     /* 0...n */
>
>  /**
>   * Determine if the server's current MODULE_MAGIC_NUMBER is at least a
>
> Modified: httpd/httpd/branches/2.2.x/include/http_core.h
> URL:  
> http://svn.apache.org/viewcvs/httpd/httpd/branches/2.2.x/include/ 
> http_core.h?rev=307031&r1=307030&r2=307031&view=diff
> ======================================================================= 
> =======
> --- httpd/httpd/branches/2.2.x/include/http_core.h (original)
> +++ httpd/httpd/branches/2.2.x/include/http_core.h Thu Oct  6 23:41:23  
> 2005
> @@ -600,9 +600,6 @@
>  AP_CORE_DECLARE_NONSTD(const char *) ap_limit_section(cmd_parms *cmd,  
> void *dummy, const char *arg);
>
>  /* Core filters; not exported. */
> -int ap_net_time_filter(ap_filter_t *f, apr_bucket_brigade *b,
> -                       ap_input_mode_t mode, apr_read_type_e block,
> -                       apr_off_t readbytes);
>  int ap_core_input_filter(ap_filter_t *f, apr_bucket_brigade *b,
>                           ap_input_mode_t mode, apr_read_type_e block,
>                           apr_off_t readbytes);
> @@ -641,7 +638,6 @@
>  extern AP_DECLARE_DATA ap_filter_rec_t *ap_subreq_core_filter_handle;
>  extern AP_DECLARE_DATA ap_filter_rec_t *ap_core_output_filter_handle;
>  extern AP_DECLARE_DATA ap_filter_rec_t  
> *ap_content_length_filter_handle;
> -extern AP_DECLARE_DATA ap_filter_rec_t *ap_net_time_filter_handle;
>  extern AP_DECLARE_DATA ap_filter_rec_t *ap_core_input_filter_handle;
>
>  /**
>
> Modified: httpd/httpd/branches/2.2.x/modules/http/http_core.c
> URL:  
> http://svn.apache.org/viewcvs/httpd/httpd/branches/2.2.x/modules/http/ 
> http_core.c?rev=307031&r1=307030&r2=307031&view=diff
> ======================================================================= 
> =======
> --- httpd/httpd/branches/2.2.x/modules/http/http_core.c (original)
> +++ httpd/httpd/branches/2.2.x/modules/http/http_core.c Thu Oct  6  
> 23:41:23 2005
> @@ -181,11 +181,13 @@
>
>          if (ap_graceful_stop_signalled())
>              break;
> -        /* Go straight to select() to wait for the next request */
> +
>          if (!csd) {
>              csd = ap_get_module_config(c->conn_config, &core_module);
>          }
>          apr_socket_opt_set(csd, APR_INCOMPLETE_READ, 1);
> +        apr_socket_timeout_set(csd,  
> c->base_server->keep_alive_timeout);
> +        /* Go straight to select() to wait for the next request */
>      }
>
>      return OK;
>
> Modified: httpd/httpd/branches/2.2.x/server/core.c
> URL:  
> http://svn.apache.org/viewcvs/httpd/httpd/branches/2.2.x/server/ 
> core.c?rev=307031&r1=307030&r2=307031&view=diff
> ======================================================================= 
> =======
> --- httpd/httpd/branches/2.2.x/server/core.c (original)
> +++ httpd/httpd/branches/2.2.x/server/core.c Thu Oct  6 23:41:23 2005
> @@ -91,7 +91,6 @@
>  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_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;
>
>  /* magic pointer for ErrorDocument xxx "default" */
> @@ -3759,10 +3758,6 @@
>      }
>      else {
>          req_cfg->bb = apr_brigade_create(r->pool,  
> r->connection->bucket_alloc);
> -        if (!r->prev) {
> -            ap_add_input_filter_handle(ap_net_time_filter_handle,
> -                                       NULL, r, r->connection);
> -        }
>      }
>
>      ap_set_module_config(r->request_config, &core_module, req_cfg);
> @@ -3821,10 +3816,9 @@
>  static int core_pre_connection(conn_rec *c, void *csd)
>  {
>      core_net_rec *net = apr_palloc(c->pool, sizeof(*net));
> -
> -#ifdef AP_MPM_DISABLE_NAGLE_ACCEPTED_SOCK
>      apr_status_t rv;
>
> +#ifdef AP_MPM_DISABLE_NAGLE_ACCEPTED_SOCK
>      /* The Nagle algorithm says that we should delay sending partial
>       * packets in hopes of getting more data.  We don't want to do
>       * this; we are not telnet.  There are bad interactions between
> @@ -3841,6 +3835,20 @@
>                        "apr_socket_opt_set(APR_TCP_NODELAY)");
>      }
>  #endif
> +
> +    /* The core filter requires the timeout mode to be set, which
> +     * incidentally sets the socket to be nonblocking.  If this
> +     * is not initialized correctly, Linux - for example - will
> +     * be initially blocking, while Solaris will be non blocking
> +     * and any initial read will fail.
> +     */
> +    rv = apr_socket_timeout_set(csd, c->base_server->timeout);
> +    if (rv != APR_SUCCESS) {
> +        /* expected cause is that the client disconnected already */
> +        ap_log_cerror(APLOG_MARK, APLOG_DEBUG, rv, c,
> +                      "apr_socket_timeout_set");
> +    }
> +
>      net->c = c;
>      net->in_ctx = NULL;
>      net->out_ctx = NULL;
> @@ -3887,9 +3895,6 @@
>      ap_core_input_filter_handle =
>          ap_register_input_filter("CORE_IN", ap_core_input_filter,
>                                   NULL, AP_FTYPE_NETWORK);
> -    ap_net_time_filter_handle =
> -        ap_register_input_filter("NET_TIME", ap_net_time_filter,
> -                                 NULL, AP_FTYPE_PROTOCOL);
>      ap_content_length_filter_handle =
>          ap_register_output_filter("CONTENT_LENGTH",  
> ap_content_length_filter,
>                                    NULL, AP_FTYPE_PROTOCOL);
>
> Modified: httpd/httpd/branches/2.2.x/server/core_filters.c
> URL:  
> http://svn.apache.org/viewcvs/httpd/httpd/branches/2.2.x/server/ 
> core_filters.c?rev=307031&r1=307030&r2=307031&view=diff
> ======================================================================= 
> =======
> --- httpd/httpd/branches/2.2.x/server/core_filters.c (original)
> +++ httpd/httpd/branches/2.2.x/server/core_filters.c Thu Oct  6  
> 23:41:23 2005
> @@ -58,41 +58,6 @@
>
>  #define AP_MIN_SENDFILE_BYTES           (256)
>
> -typedef struct net_time_filter_ctx {
> -    apr_socket_t *csd;
> -    int           first_line;
> -} net_time_filter_ctx_t;
> -
> -int ap_net_time_filter(ap_filter_t *f, apr_bucket_brigade *b,
> -                       ap_input_mode_t mode, apr_read_type_e block,
> -                       apr_off_t readbytes)
> -{
> -    net_time_filter_ctx_t *ctx = f->ctx;
> -    int keptalive = f->c->keepalive == AP_CONN_KEEPALIVE;
> -
> -    if (!ctx) {
> -        f->ctx = ctx = apr_palloc(f->r->pool, sizeof(*ctx));
> -        ctx->first_line = 1;
> -        ctx->csd = ap_get_module_config(f->c->conn_config,  
> &core_module);
> -    }
> -
> -    if (mode != AP_MODE_INIT && mode != AP_MODE_EATCRLF) {
> -        if (ctx->first_line) {
> -            apr_socket_timeout_set(ctx->csd,
> -                                   keptalive
> -                                      ?  
> f->c->base_server->keep_alive_timeout
> -                                      : f->c->base_server->timeout);
> -            ctx->first_line = 0;
> -        }
> -        else {
> -            if (keptalive) {
> -                apr_socket_timeout_set(ctx->csd,  
> f->c->base_server->timeout);
> -            }
> -        }
> -    }
> -    return ap_get_brigade(f->next, b, mode, block, readbytes);
> -}
> -
>  /**
>   * Remove all zero length buckets from the brigade.
>   */
>
> Modified: httpd/httpd/branches/2.2.x/server/protocol.c
> URL:  
> http://svn.apache.org/viewcvs/httpd/httpd/branches/2.2.x/server/ 
> protocol.c?rev=307031&r1=307030&r2=307031&view=diff
> ======================================================================= 
> =======
> --- httpd/httpd/branches/2.2.x/server/protocol.c (original)
> +++ httpd/httpd/branches/2.2.x/server/protocol.c Thu Oct  6 23:41:23  
> 2005
> @@ -832,6 +832,8 @@
>      const char *expect;
>      int access_status;
>      apr_bucket_brigade *tmp_bb;
> +    apr_socket_t *csd;
> +    apr_interval_time_t cur_timeout;
>
>      apr_pool_create(&p, conn->pool);
>      apr_pool_tag(p, "request");
> @@ -892,6 +894,17 @@
>          return NULL;
>      }
>
> +    /* We may have been in keep_alive_timeout mode, so toggle back
> +     * to the normal timeout mode as we fetch the header lines,
> +     * as necessary.
> +     */
> +    csd = ap_get_module_config(conn->conn_config, &core_module);
> +    apr_socket_timeout_get(csd, &cur_timeout);
> +    if (cur_timeout != conn->base_server->timeout) {
> +        apr_socket_timeout_set(csd, conn->base_server->timeout);
> +        cur_timeout = conn->base_server->timeout;
> +    }
> +
>      if (!r->assbackwards) {
>          ap_get_mime_headers_core(r, tmp_bb);
>          if (r->status != HTTP_REQUEST_TIME_OUT) {
> @@ -941,6 +954,14 @@
>       * now read. may update status.
>       */
>      ap_update_vhost_from_headers(r);
> +
> +    /* Toggle to the Host:-based vhost's timeout mode to fetch the
> +     * request body and send the response body, if needed.
> +     */
> +    if (cur_timeout != r->server->timeout) {
> +        apr_socket_timeout_set(csd, r->server->timeout);
> +        cur_timeout = r->server->timeout;
> +    }
>
>      /* we may have switched to another server */
>      r->per_dir_config = r->server->lookup_defaults;
>
>