httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bri...@apache.org
Subject svn commit: r306541 - in /httpd/httpd/branches/async-dev: include/ap_mmn.h include/http_core.h modules/http/http_core.c server/core.c server/core_filters.c server/protocol.c
Date Thu, 06 Oct 2005 06:19:16 GMT
Author: brianp
Date: Wed Oct  5 23:19:12 2005
New Revision: 306541

URL: http://svn.apache.org/viewcvs?rev=306541&view=rev
Log:
Forward-port of wrowe's NET_TIME filter removal/refactor into
the async-dev branch, in preparation for developing async write
completion in this branch on top of the new timeout design.
http://svn.apache.org/viewcvs.cgi?rev=306495&view=rev

Modified:
    httpd/httpd/branches/async-dev/include/ap_mmn.h
    httpd/httpd/branches/async-dev/include/http_core.h
    httpd/httpd/branches/async-dev/modules/http/http_core.c
    httpd/httpd/branches/async-dev/server/core.c
    httpd/httpd/branches/async-dev/server/core_filters.c
    httpd/httpd/branches/async-dev/server/protocol.c

Modified: httpd/httpd/branches/async-dev/include/ap_mmn.h
URL: http://svn.apache.org/viewcvs/httpd/httpd/branches/async-dev/include/ap_mmn.h?rev=306541&r1=306540&r2=306541&view=diff
==============================================================================
--- httpd/httpd/branches/async-dev/include/ap_mmn.h (original)
+++ httpd/httpd/branches/async-dev/include/ap_mmn.h Wed Oct  5 23:19:12 2005
@@ -105,14 +105,16 @@
  * 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)
-  */
+ * 20050919.0 (2.1.8-dev) mod_ssl ssl_ext_list optional function added
+ * 20051005.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 20051005
 #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/async-dev/include/http_core.h
URL: http://svn.apache.org/viewcvs/httpd/httpd/branches/async-dev/include/http_core.h?rev=306541&r1=306540&r2=306541&view=diff
==============================================================================
--- httpd/httpd/branches/async-dev/include/http_core.h (original)
+++ httpd/httpd/branches/async-dev/include/http_core.h Wed Oct  5 23:19:12 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/async-dev/modules/http/http_core.c
URL: http://svn.apache.org/viewcvs/httpd/httpd/branches/async-dev/modules/http/http_core.c?rev=306541&r1=306540&r2=306541&view=diff
==============================================================================
--- httpd/httpd/branches/async-dev/modules/http/http_core.c (original)
+++ httpd/httpd/branches/async-dev/modules/http/http_core.c Wed Oct  5 23:19:12 2005
@@ -157,7 +157,6 @@
 static int ap_process_http_connection(conn_rec *c)
 {
     request_rec *r;
-    int csd_set = 0;
     apr_socket_t *csd = NULL;
 
     /*
@@ -186,12 +185,13 @@
  
         if (ap_graceful_stop_signalled())
             break;
-        /* Go straight to select() to wait for the next request */
-        if (!csd_set) {
+
+        if (!csd) {
             csd = ap_get_module_config(c->conn_config, &core_module);
-            csd_set = 1;
         }
         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/async-dev/server/core.c
URL: http://svn.apache.org/viewcvs/httpd/httpd/branches/async-dev/server/core.c?rev=306541&r1=306540&r2=306541&view=diff
==============================================================================
--- httpd/httpd/branches/async-dev/server/core.c (original)
+++ httpd/httpd/branches/async-dev/server/core.c Wed Oct  5 23:19:12 2005
@@ -21,7 +21,6 @@
 #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
@@ -49,7 +48,6 @@
 #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 */
 
@@ -92,13 +90,9 @@
 /* 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;
 
@@ -3681,25 +3675,9 @@
 
 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;
@@ -3780,19 +3758,10 @@
     }
     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);
 
-    /* Begin by presuming any module can make its own path_info assumptions,
-     * until some module interjects and changes the value.
-     */
-    r->used_path_info = AP_REQ_DEFAULT_PATH_INFO;
-
     return OK;
 }
 
@@ -3840,7 +3809,7 @@
 
     c->id = id;
     c->bucket_alloc = alloc;
-    
+
     c->cs = (conn_state_t *)apr_pcalloc(ptrans, sizeof(conn_state_t));
     APR_RING_INIT(&(c->cs->timeout_list), conn_state_t, timeout_list);
     c->cs->expiration_time = 0;
@@ -3855,10 +3824,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
@@ -3875,6 +3843,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;
@@ -3882,10 +3864,7 @@
 
     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;
 }
 
@@ -3924,14 +3903,12 @@
     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);
-
-
+    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);

Modified: httpd/httpd/branches/async-dev/server/core_filters.c
URL: http://svn.apache.org/viewcvs/httpd/httpd/branches/async-dev/server/core_filters.c?rev=306541&r1=306540&r2=306541&view=diff
==============================================================================
--- httpd/httpd/branches/async-dev/server/core_filters.c (original)
+++ httpd/httpd/branches/async-dev/server/core_filters.c Wed Oct  5 23:19:12 2005
@@ -60,41 +60,6 @@
 #define AP_MIN_SENDFILE_BYTES           (256)
 // #define APR_HAS_SENDFILE 0
 
-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/async-dev/server/protocol.c
URL: http://svn.apache.org/viewcvs/httpd/httpd/branches/async-dev/server/protocol.c?rev=306541&r1=306540&r2=306541&view=diff
==============================================================================
--- httpd/httpd/branches/async-dev/server/protocol.c (original)
+++ httpd/httpd/branches/async-dev/server/protocol.c Wed Oct  5 23:19:12 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");
@@ -869,6 +871,11 @@
     r->status          = HTTP_REQUEST_TIME_OUT;  /* Until we get a request */
     r->the_request     = NULL;
 
+    /* Begin by presuming any module can make its own path_info assumptions,
+     * until some module interjects and changes the value.
+     */
+    r->used_path_info = AP_REQ_DEFAULT_PATH_INFO;
+
     tmp_bb = apr_brigade_create(r->pool, r->connection->bucket_alloc);
 
     /* Get the request... */
@@ -887,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) {
@@ -936,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;



Mime
View raw message