]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
Backport Revision: 306495
authorWilliam A. Rowe Jr <wrowe@apache.org>
Fri, 7 Oct 2005 06:41:23 +0000 (06:41 +0000)
committerWilliam A. Rowe Jr <wrowe@apache.org>
Fri, 7 Oct 2005 06:41:23 +0000 (06:41 +0000)
  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.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.2.x@307031 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
include/ap_mmn.h
include/http_core.h
modules/http/http_core.c
server/core.c
server/core_filters.c
server/protocol.c

diff --git a/CHANGES b/CHANGES
index 65c62b1ee2b94c527ac527678fff4f52664a348d..7a3d6258a9ad5d54b081d56e61850ef9e33426c9 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -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>]
index 84dfebeb863d462f4935cad54aa8115bc3e6c710..443449e9e3fdbddaddaf19391988a73f310c0aa2 100644 (file)
  * 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
index ecf7b9d0374a0d7124e822b4cf6245f7c9e9910a..9060cb7a4e6ec6dba0527190750b0e66f88a909f 100644 (file)
@@ -600,9 +600,6 @@ AP_CORE_DECLARE(void) ap_add_file_conf(core_dir_config *conf, void *url_config);
 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 @@ typedef struct {
 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;
 
 /**
index 58a268fe7b51dfa2ab30194b44fd3d3bf1b92ea7..db0dc4fd158b56a7b8acc458d09fd80f280a137a 100644 (file)
@@ -181,11 +181,13 @@ static int ap_process_http_connection(conn_rec *c)
  
         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;
index e6b9169ac98cec235ac25ce1a2ce880f698d8c03..188bdab45e549a43b831bfb1a758292199c8681e 100644 (file)
@@ -91,7 +91,6 @@ AP_IMPLEMENT_HOOK_RUN_ALL(int, get_mgmt_items,
 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 @@ static int core_create_req(request_rec *r)
     }
     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 conn_rec *core_create_conn(apr_pool_t *ptrans, server_rec *server,
 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 @@ static int core_pre_connection(conn_rec *c, void *csd)
                       "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 @@ static void register_hooks(apr_pool_t *p)
     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);
index 0a2f4880baafd4011c83f3b95243e3f053a85e6d..9006c0a806940ab00834d81c278034ea6e372d91 100644 (file)
 
 #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.
  */
index 327adb63b83628fd78822d7f1d86b63078cd636a..e440ced1742c215548ec206fdd77fbbf201a789a 100644 (file)
@@ -832,6 +832,8 @@ request_rec *ap_read_request(conn_rec *conn)
     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 @@ request_rec *ap_read_request(conn_rec *conn)
         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) {
@@ -942,6 +955,14 @@ request_rec *ap_read_request(conn_rec *conn)
      */
     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;