httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s.@apache.org
Subject svn commit: r917211 - in /httpd/httpd/branches/2.2.x: ./ build/ docs/manual/mod/ modules/filters/ os/win32/
Date Sun, 28 Feb 2010 17:25:44 GMT
Author: sf
Date: Sun Feb 28 17:25:44 2010
New Revision: 917211

URL: http://svn.apache.org/viewvc?rev=917211&view=rev
Log:
Backport mod_reqtimeout from trunk.

Reviewed by: sf, jorton, rjung

To take trawick's comment into account, I have changed enabled=yes into
enabled=most.

Added:
    httpd/httpd/branches/2.2.x/docs/manual/mod/mod_reqtimeout.xml   (with props)
    httpd/httpd/branches/2.2.x/docs/manual/mod/mod_reqtimeout.xml.meta   (with props)
    httpd/httpd/branches/2.2.x/modules/filters/mod_reqtimeout.c   (with props)
    httpd/httpd/branches/2.2.x/modules/filters/mod_reqtimeout.dsp   (with props)
Modified:
    httpd/httpd/branches/2.2.x/Apache.dsw
    httpd/httpd/branches/2.2.x/CHANGES
    httpd/httpd/branches/2.2.x/Makefile.win
    httpd/httpd/branches/2.2.x/STATUS
    httpd/httpd/branches/2.2.x/build/installwinconf.awk
    httpd/httpd/branches/2.2.x/docs/manual/mod/allmodules.xml
    httpd/httpd/branches/2.2.x/modules/filters/config.m4
    httpd/httpd/branches/2.2.x/os/win32/BaseAddr.ref

Modified: httpd/httpd/branches/2.2.x/Apache.dsw
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.2.x/Apache.dsw?rev=917211&r1=917210&r2=917211&view=diff
==============================================================================
--- httpd/httpd/branches/2.2.x/Apache.dsw (original)
+++ httpd/httpd/branches/2.2.x/Apache.dsw Sun Feb 28 17:25:44 2010
@@ -249,6 +249,9 @@
     Project_Dep_Name mod_proxy_http
     End Project Dependency
     Begin Project Dependency
+    Project_Dep_Name mod_reqtimeout
+    End Project Dependency
+    Begin Project Dependency
     Project_Dep_Name mod_rewrite
     End Project Dependency
     Begin Project Dependency
@@ -2181,6 +2184,27 @@
 
 ###############################################################################
 
+Project: "mod_reqtimeout"=.\modules\filters\mod_reqtimeout.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+    Begin Project Dependency
+    Project_Dep_Name libapr
+    End Project Dependency
+    Begin Project Dependency
+    Project_Dep_Name libaprutil
+    End Project Dependency
+    Begin Project Dependency
+    Project_Dep_Name libhttpd
+    End Project Dependency
+}}}
+
+###############################################################################
+
 Project: "mod_rewrite"=.\modules\mappers\mod_rewrite.dsp - Package Owner=<4>
 
 Package=<5>

Modified: httpd/httpd/branches/2.2.x/CHANGES
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.2.x/CHANGES?rev=917211&r1=917210&r2=917211&view=diff
==============================================================================
--- httpd/httpd/branches/2.2.x/CHANGES [utf-8] (original)
+++ httpd/httpd/branches/2.2.x/CHANGES [utf-8] Sun Feb 28 17:25:44 2010
@@ -9,6 +9,9 @@
      access control is still vulnerable, unless using OpenSSL >= 0.9.8l.
      [Joe Orton, Ruediger Pluem, Hartmut Keil <Hartmut.Keil adnovum.ch>]
 
+  *) mod_reqtimeout: New module to set timeouts and minimum data rates for
+     receiving requests from the client. [Stefan Fritsch]
+
   *) mod_proxy_ajp: Really regard the operation a success, when the client
      aborted the connection. In addition adjust the log message if the client
      aborted the connection. [Ruediger Pluem]

Modified: httpd/httpd/branches/2.2.x/Makefile.win
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.2.x/Makefile.win?rev=917211&r1=917210&r2=917211&view=diff
==============================================================================
--- httpd/httpd/branches/2.2.x/Makefile.win (original)
+++ httpd/httpd/branches/2.2.x/Makefile.win Sun Feb 28 17:25:44 2010
@@ -355,6 +355,7 @@
 	 $(MAKE) $(MAKEOPT) -f mod_ext_filter.mak  CFG="mod_ext_filter - Win32 $(LONG)" RECURSE=0
$(CTARGET)
 	 $(MAKE) $(MAKEOPT) -f mod_filter.mak      CFG="mod_filter - Win32 $(LONG)" RECURSE=0 $(CTARGET)
 	 $(MAKE) $(MAKEOPT) -f mod_include.mak     CFG="mod_include - Win32 $(LONG)" RECURSE=0 $(CTARGET)
+	 $(MAKE) $(MAKEOPT) -f mod_reqtimeout.mak  CFG="mod_reqtimeout - Win32 $(LONG)" RECURSE=0
$(CTARGET)
 	 $(MAKE) $(MAKEOPT) -f mod_substitute.mak  CFG="mod_substitute - Win32 $(LONG)" RECURSE=0
$(CTARGET)
 	cd ..\..
 	cd modules\generators
@@ -542,6 +543,7 @@
 	copy modules\filters\$(LONG)\mod_ext_filter.$(src_so) 	"$(inst_so)" <.y
 	copy modules\filters\$(LONG)\mod_filter.$(src_so) 	"$(inst_so)" <.y
 	copy modules\filters\$(LONG)\mod_include.$(src_so) 	"$(inst_so)" <.y
+	copy modules\filters\$(LONG)\mod_reqtimeout.$(src_so) 	"$(inst_so)" <.y
 	copy modules\filters\$(LONG)\mod_substitute.$(src_so)	"$(inst_so)" <.y
 	copy modules\generators\$(LONG)\mod_asis.$(src_so) 	"$(inst_so)" <.y
 	copy modules\generators\$(LONG)\mod_autoindex.$(src_so) "$(inst_so)" <.y

Modified: httpd/httpd/branches/2.2.x/STATUS
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.2.x/STATUS?rev=917211&r1=917210&r2=917211&view=diff
==============================================================================
--- httpd/httpd/branches/2.2.x/STATUS (original)
+++ httpd/httpd/branches/2.2.x/STATUS Sun Feb 28 17:25:44 2010
@@ -101,32 +101,6 @@
    sf:        Couldn't the linux 2.4 bug be worked around by calling access
               twice? Once with R_OK and once with X_OK.
 
-  * mod_reqtimeout: New module to limit time waiting for requests from clients.
-    Backport current version from trunk.
-    Trunk Patch: http://svn.apache.org/viewvc?rev=821591&view=rev
-                 http://svn.apache.org/viewvc?rev=821792&view=rev
-                 http://svn.apache.org/viewvc?rev=821990&view=rev
-                 http://svn.apache.org/viewvc?rev=822509&view=rev
-                 http://svn.apache.org/viewvc?rev=822857&view=rev
-                 http://svn.apache.org/viewvc?rev=825177&view=rev
-                 http://svn.apache.org/viewvc?rev=834499&view=rev
-                 http://svn.apache.org/viewvc?rev=885121&view=rev
-                 http://svn.apache.org/viewvc?rev=900018&view=rev
-                 http://svn.apache.org/viewvc?rev=902434&view=rev
-                 http://svn.apache.org/viewvc?rev=902593&view=rev
-                 http://svn.apache.org/viewvc?rev=916866&view=rev
-                 http://svn.apache.org/viewvc?rev=917151&view=rev
-    2.2.x Patch: http://people.apache.org/~sf/mod_reqtimeout.2.2-v2.patch
-                 http://people.apache.org/~sf/mod_reqtimeout.2.2-windows-build.patch
-                 http://svn.apache.org/viewvc?rev=917151&view=rev
-    +1: sf, jorton, rjung
-    trawick: combo of Status=Experimental/enabled=yes seems strange,
-    sf: I am fine with any other combination of Status/enabled.
-    rjung: mod_substitute as another recent example started its 2.2.x
-    life with status "Extension" and enabled "most" and an additional
-    docs comment about being experimental (see r602738). I'm fine with
-    either result.
-
   * Ensure each subrequest has a shallow copy of headers_in so that the
     parent request headers are not corrupted.  Eliminates a problematic
     optimization in the case of no request body.  PR 48359 

Modified: httpd/httpd/branches/2.2.x/build/installwinconf.awk
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.2.x/build/installwinconf.awk?rev=917211&r1=917210&r2=917211&view=diff
==============================================================================
--- httpd/httpd/branches/2.2.x/build/installwinconf.awk (original)
+++ httpd/httpd/branches/2.2.x/build/installwinconf.awk Sun Feb 28 17:25:44 2010
@@ -147,6 +147,7 @@
 	  print "#LoadModule proxy_connect_module modules/mod_proxy_connect.so" > dstfl;
 	  print "#LoadModule proxy_ftp_module modules/mod_proxy_ftp.so" > dstfl;
 	  print "#LoadModule proxy_http_module modules/mod_proxy_http.so" > dstfl;
+	  print "#LoadModule reqtimeout_module modules/mod_reqtimeout.so" > dstfl;
 	  print "#LoadModule rewrite_module modules/mod_rewrite.so" > dstfl;
 	  print "LoadModule setenvif_module modules/mod_setenvif.so" > dstfl;
 	  print "#LoadModule speling_module modules/mod_speling.so" > dstfl;

Modified: httpd/httpd/branches/2.2.x/docs/manual/mod/allmodules.xml
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.2.x/docs/manual/mod/allmodules.xml?rev=917211&r1=917210&r2=917211&view=diff
==============================================================================
--- httpd/httpd/branches/2.2.x/docs/manual/mod/allmodules.xml (original)
+++ httpd/httpd/branches/2.2.x/docs/manual/mod/allmodules.xml Sun Feb 28 17:25:44 2010
@@ -64,6 +64,7 @@
   <modulefile>mod_proxy_ftp.xml</modulefile>
   <modulefile>mod_proxy_http.xml</modulefile>
   <modulefile>mod_proxy_scgi.xml</modulefile>
+  <modulefile>mod_reqtimeout.xml</modulefile>
   <modulefile>mod_rewrite.xml</modulefile>
   <modulefile>mod_setenvif.xml</modulefile>
   <modulefile>mod_so.xml</modulefile>

Added: httpd/httpd/branches/2.2.x/docs/manual/mod/mod_reqtimeout.xml
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.2.x/docs/manual/mod/mod_reqtimeout.xml?rev=917211&view=auto
==============================================================================
--- httpd/httpd/branches/2.2.x/docs/manual/mod/mod_reqtimeout.xml (added)
+++ httpd/httpd/branches/2.2.x/docs/manual/mod/mod_reqtimeout.xml Sun Feb 28 17:25:44 2010
@@ -0,0 +1,141 @@
+<?xml version="1.0"?>
+<!DOCTYPE modulesynopsis SYSTEM "../style/modulesynopsis.dtd">
+<?xml-stylesheet type="text/xsl" href="../style/manual.en.xsl"?>
+<!-- $LastChangedRevision$ -->
+
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements.  See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License.  You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<modulesynopsis metafile="mod_reqtimeout.xml.meta">
+
+<name>mod_reqtimeout</name>
+<description>Set timeout and minimum data rate for receiving requests
+</description>
+<status>Experimental</status>
+<sourcefile>mod_reqtimeout.c</sourcefile>
+<identifier>reqtimeout_module</identifier>
+<compatibility>Available in Apache 2.2.15 and later</compatibility>
+
+<section id="examples"><title>Examples</title>
+
+    <ol>
+      <li>
+        Allow 10 seconds to receive the request including the headers and
+        30 seconds for receiving the request body:
+
+        <example>
+          RequestReadTimeout header=10 body=30
+        </example>
+      </li>
+
+      <li>
+        Allow at least 10 seconds to receive the request body.
+        If the client sends data, increase the timeout by 1 second for every
+        1000 bytes received, with no upper limit for the timeout (exept for
+        the limit given indirectly by
+        <directive module="core">LimitRequestBody</directive>):
+
+        <example>
+          RequestReadTimeout body=10,MinRate=1000
+        </example>
+      </li>
+
+      <li>
+        Allow at least 10 seconds to receive the request including the headers.
+        If the client sends data, increase the timeout by 1 second for every
+        500 bytes received. But do not allow more than 30 seconds for the
+        request including the headers:
+
+        <example>
+          RequestReadTimeout header=10-30,MinRate=500
+        </example>
+      </li>
+
+    </ol>
+</section>
+
+<directivesynopsis>
+<name>RequestReadTimeout</name>
+<description>Set timeout values for receiving request headers and body from client.
+</description>
+<syntax>RequestReadTimeout
+[header=<var>timeout</var>[[-<var>maxtimeout</var>],MinRate=<var>rate</var>]
+[body=<var>timeout</var>[[-<var>maxtimeout</var>],MinRate=<var>rate</var>]
+</syntax>
+<default>Unset; no limit</default>
+<contextlist><context>server config</context><context>virtual host</context>
+</contextlist>
+
+<usage>
+    <p>This directive can set various timeouts for receiving the request headers
+    and the request body from the client. If the client fails to send headers or
+    body within the configured time, a <code>408 REQUEST TIME OUT</code> error
+    is sent.</p>
+
+    <p>For SSL virtual hosts, the header timeout values include the time needed
+    to do the initial SSL handshake. The body timeout values include the time
+    needed for SSL renegotiation (if necessary).</p>
+
+    <p>When an <directive module="core">AcceptFilter</directive> is in
use
+    (usually the case on Linux and FreeBSD), the socket is not sent to the
+    server process before at least one byte (or the whole request for
+    <code>httpready</code>) is received. The header timeout configured with
+    <code>RequestReadTimeout</code> is only effective after the server process
has
+    received the socket.</p>
+
+    <p>For each of the two timeout types (header or body), there are three ways
+    to specify the timeout:
+    </p>
+
+    <ul>
+
+    <li><strong>Fixed timeout value</strong>:<br />
+
+    <example><var>type</var>=<var>timeout</var></example>
+
+    <p>The time in seconds allowed for reading all of the request headers or
+    body, respectively. A value of 0 means no limit.</p>
+    </li>
+
+    <li><strong>Timeout value that is increased when data is
+    received</strong>:<br />
+    <example>
+    <var>type</var>=<var>timeout</var>,MinRate=<var>data_rate</var>
+    </example>
+
+    <p>Same as above, but whenever data is received, the timeout value is
+    increased according to the specified minimum data rate (in bytes per
+    second).</p>
+    </li>
+
+    <li><strong>Timeout value that is increased when data is received, with an
+    upper bound</strong>:<br />
+    <example>
+    <var>type</var>=<var>timeout</var>-<var>maxtimeout</var>,MinRate=<var>data_rate</var>
+    </example>
+
+    <p>Same as above, but the timeout will not be increased above the second
+    value of the specified timeout range.</p>
+    </li>
+
+    </ul>
+
+</usage>
+
+</directivesynopsis>
+
+</modulesynopsis>

Propchange: httpd/httpd/branches/2.2.x/docs/manual/mod/mod_reqtimeout.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: httpd/httpd/branches/2.2.x/docs/manual/mod/mod_reqtimeout.xml.meta
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.2.x/docs/manual/mod/mod_reqtimeout.xml.meta?rev=917211&view=auto
==============================================================================
--- httpd/httpd/branches/2.2.x/docs/manual/mod/mod_reqtimeout.xml.meta (added)
+++ httpd/httpd/branches/2.2.x/docs/manual/mod/mod_reqtimeout.xml.meta Sun Feb 28 17:25:44
2010
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!-- GENERATED FROM XML: DO NOT EDIT -->
+
+<metafile>
+  <basename>mod_reqtimeout</basename>
+  <path>/mod/</path>
+  <relpath>..</relpath>
+
+  <variants>
+    <variant>en</variant>
+  </variants>
+</metafile>

Propchange: httpd/httpd/branches/2.2.x/docs/manual/mod/mod_reqtimeout.xml.meta
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: httpd/httpd/branches/2.2.x/modules/filters/config.m4
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.2.x/modules/filters/config.m4?rev=917211&r1=917210&r2=917211&view=diff
==============================================================================
--- httpd/httpd/branches/2.2.x/modules/filters/config.m4 (original)
+++ httpd/httpd/branches/2.2.x/modules/filters/config.m4 Sun Feb 28 17:25:44 2010
@@ -4,6 +4,7 @@
 
 APACHE_MODPATH_INIT(filters)
 
+APACHE_MODULE(reqtimeout, Limit time waiting for request from client, , , most)
 APACHE_MODULE(ext_filter, external filter module, , , most)
 APACHE_MODULE(include, Server Side Includes, , , yes)
 APACHE_MODULE(filter, Smart Filtering, , , yes)

Added: httpd/httpd/branches/2.2.x/modules/filters/mod_reqtimeout.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.2.x/modules/filters/mod_reqtimeout.c?rev=917211&view=auto
==============================================================================
--- httpd/httpd/branches/2.2.x/modules/filters/mod_reqtimeout.c (added)
+++ httpd/httpd/branches/2.2.x/modules/filters/mod_reqtimeout.c Sun Feb 28 17:25:44 2010
@@ -0,0 +1,431 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "httpd.h"
+#include "http_config.h"
+#include "http_request.h"
+#include "http_connection.h"
+#include "http_protocol.h"
+#include "http_log.h"
+#include "util_filter.h"
+#define APR_WANT_STRFUNC
+#include "apr_strings.h"
+
+module AP_MODULE_DECLARE_DATA reqtimeout_module;
+
+typedef struct
+{
+    int header_timeout;     /* timeout for reading the req hdrs in secs */
+    int header_max_timeout; /* max timeout for req hdrs in secs */
+    int header_min_rate;    /* min rate for reading req hdrs in bytes/s */
+    apr_time_t header_rate_factor;
+    int body_timeout;       /* timeout for reading the req body in secs */
+    int body_max_timeout;   /* max timeout for req body in secs */
+    int body_min_rate;      /* timeout for reading the req body in secs */
+    apr_time_t body_rate_factor;
+} reqtimeout_srv_cfg;
+
+typedef struct
+{
+    apr_time_t timeout_at;
+    apr_time_t max_timeout_at;
+    int min_rate;
+    int new_timeout;
+    int new_max_timeout;
+    int in_keep_alive;
+    char *type;
+    apr_time_t rate_factor;
+} reqtimeout_con_cfg;
+
+typedef struct
+{
+    apr_socket_t *socket;
+} reqtimeout_ctx;
+
+static const char *const reqtimeout_filter_name = "reqtimeout";
+
+static void extend_timeout(reqtimeout_con_cfg *ccfg, apr_bucket_brigade *bb)
+{
+    apr_off_t len;
+    apr_time_t new_timeout_at;
+
+    if (apr_brigade_length(bb, 0, &len) != APR_SUCCESS || len <= 0)
+        return;
+
+    new_timeout_at = ccfg->timeout_at + len * ccfg->rate_factor;
+    if (ccfg->max_timeout_at > 0 && new_timeout_at > ccfg->max_timeout_at)
{
+        ccfg->timeout_at = ccfg->max_timeout_at;
+    }
+    else {
+        ccfg->timeout_at = new_timeout_at;
+    }
+}
+
+static apr_status_t reqtimeout_filter(ap_filter_t *f,
+                                      apr_bucket_brigade *bb,
+                                      ap_input_mode_t mode,
+                                      apr_read_type_e block,
+                                      apr_off_t readbytes)
+{
+    reqtimeout_ctx *ctx;
+    apr_time_t time_left;
+    apr_time_t now;
+    apr_status_t rv;
+    apr_interval_time_t saved_sock_timeout = -1;
+    reqtimeout_con_cfg *ccfg;
+
+    ctx = f->ctx;
+    AP_DEBUG_ASSERT(ctx != NULL);
+
+    ccfg = ap_get_module_config(f->c->conn_config, &reqtimeout_module);
+    AP_DEBUG_ASSERT(ccfg != NULL);
+
+    if (ccfg->in_keep_alive) {
+        /* For this read, the normal keep-alive timeout must be used */
+        ccfg->in_keep_alive = 0;
+        return ap_get_brigade(f->next, bb, mode, block, readbytes);
+    }
+
+    now = apr_time_now();
+    if (ccfg->new_timeout > 0) {
+        /* set new timeout */
+        ccfg->timeout_at = now + apr_time_from_sec(ccfg->new_timeout);
+        ccfg->new_timeout = 0;
+        if (ccfg->new_max_timeout > 0) {
+            ccfg->max_timeout_at = now + apr_time_from_sec(ccfg->new_max_timeout);
+            ccfg->new_max_timeout = 0;
+        }
+    }
+    else if (ccfg->timeout_at == 0) {
+        /* no timeout set */
+        return ap_get_brigade(f->next, bb, mode, block, readbytes);
+    }
+
+    time_left = ccfg->timeout_at - now;
+    if (time_left <= 0) {
+        ap_log_cerror(APLOG_MARK, APLOG_INFO, 0, f->c,
+                      "Request %s read timeout", ccfg->type);
+        return APR_TIMEUP;
+    }
+
+    if (block == APR_NONBLOCK_READ || mode == AP_MODE_INIT
+        || mode == AP_MODE_EATCRLF) {
+        rv = ap_get_brigade(f->next, bb, mode, block, readbytes);
+        if (ccfg->min_rate > 0 && rv == APR_SUCCESS) {
+            extend_timeout(ccfg, bb);
+        }
+        return rv;
+    }
+
+    if (time_left < apr_time_from_sec(1)) {
+        time_left = apr_time_from_sec(1);
+    }
+
+    rv = apr_socket_timeout_get(ctx->socket, &saved_sock_timeout);
+    AP_DEBUG_ASSERT(rv == APR_SUCCESS);
+
+    if (saved_sock_timeout >= time_left) {
+        rv = apr_socket_timeout_set(ctx->socket, time_left);
+        AP_DEBUG_ASSERT(rv == APR_SUCCESS);
+    }
+    else {
+        saved_sock_timeout = -1;
+    }
+
+    rv = ap_get_brigade(f->next, bb, mode, block, readbytes);
+
+    if (saved_sock_timeout != -1) {
+        apr_socket_timeout_set(ctx->socket, saved_sock_timeout);
+    }
+
+    if (ccfg->min_rate > 0 && rv == APR_SUCCESS) {
+        extend_timeout(ccfg, bb);
+    }
+
+    if (rv == APR_TIMEUP) {
+        ap_log_cerror(APLOG_MARK, APLOG_INFO, 0, f->c,
+                      "Request %s read timeout", ccfg->type);
+    }
+    return rv;
+}
+
+static int reqtimeout_pre_conn(conn_rec *c, void *csd)
+{
+    reqtimeout_ctx *ctx;
+    reqtimeout_con_cfg *ccfg;
+    reqtimeout_srv_cfg *cfg;
+
+    cfg = ap_get_module_config(c->base_server->module_config,
+                               &reqtimeout_module);
+    AP_DEBUG_ASSERT(cfg != NULL);
+    if (cfg->header_timeout <= 0 && cfg->body_timeout <= 0) {
+        /* not configured for this vhost */
+        return OK;
+    }
+
+    ctx = apr_pcalloc(c->pool, sizeof(reqtimeout_ctx));
+    ctx->socket = csd;
+
+    ccfg = apr_pcalloc(c->pool, sizeof(reqtimeout_con_cfg));
+    ccfg->new_timeout = cfg->header_timeout;
+    ccfg->new_max_timeout = cfg->header_max_timeout;
+    ccfg->type = "header";
+    ccfg->min_rate = cfg->header_min_rate;
+    ccfg->rate_factor = cfg->header_rate_factor;
+    ap_set_module_config(c->conn_config, &reqtimeout_module, ccfg);
+
+    ap_add_input_filter("reqtimeout", ctx, NULL, c);
+    return OK;
+}
+
+static int reqtimeout_after_headers(request_rec *r)
+{
+    reqtimeout_srv_cfg *cfg;
+    reqtimeout_con_cfg *ccfg =
+        ap_get_module_config(r->connection->conn_config, &reqtimeout_module);
+
+    if (ccfg == NULL) {
+        /* not configured for this vhost */
+        return OK;
+    }
+
+    cfg = ap_get_module_config(r->connection->base_server->module_config,
+                               &reqtimeout_module);
+    AP_DEBUG_ASSERT(cfg != NULL);
+
+    ccfg->timeout_at = 0;
+    ccfg->max_timeout_at = 0;
+    ccfg->new_timeout = cfg->body_timeout;
+    ccfg->new_max_timeout = cfg->body_max_timeout;
+    ccfg->min_rate = cfg->body_min_rate;
+    ccfg->rate_factor = cfg->body_rate_factor;
+    ccfg->type = "body";
+
+    return OK;
+}
+
+static int reqtimeout_after_body(request_rec *r)
+{
+    reqtimeout_srv_cfg *cfg;
+    reqtimeout_con_cfg *ccfg =
+        ap_get_module_config(r->connection->conn_config, &reqtimeout_module);
+
+    if (ccfg == NULL) {
+        /* not configured for this vhost */
+        return OK;
+    }
+
+    cfg = ap_get_module_config(r->connection->base_server->module_config,
+                               &reqtimeout_module);
+    AP_DEBUG_ASSERT(cfg != NULL);
+
+    ccfg->timeout_at = 0;
+    ccfg->max_timeout_at = 0;
+    ccfg->in_keep_alive = 1;
+    ccfg->new_timeout = cfg->header_timeout;
+    ccfg->new_max_timeout = cfg->header_max_timeout;
+    ccfg->min_rate = cfg->header_min_rate;
+    ccfg->rate_factor = cfg->header_rate_factor;
+    
+    ccfg->type = "header";
+
+    return OK;
+}
+
+static void *reqtimeout_create_srv_config(apr_pool_t *p, server_rec *s)
+{
+    reqtimeout_srv_cfg *cfg = apr_pcalloc(p, sizeof(reqtimeout_srv_cfg));
+
+    cfg->header_timeout = -1;
+    cfg->header_max_timeout = -1;
+    cfg->header_min_rate = -1;
+    cfg->body_timeout = -1;
+    cfg->body_max_timeout = -1;
+    cfg->body_min_rate = -1;
+
+    return cfg;
+}
+
+#define MERGE_INT(cfg, b, a, val) cfg->val = (a->val == -1) ? b->val : a->val;
+static void *reqtimeout_merge_srv_config(apr_pool_t *p, void *base_, void *add_)
+{
+    reqtimeout_srv_cfg *base = base_;
+    reqtimeout_srv_cfg *add  = add_;
+    reqtimeout_srv_cfg *cfg  = apr_pcalloc(p, sizeof(reqtimeout_srv_cfg));
+
+    MERGE_INT(cfg, base, add, header_timeout);
+    MERGE_INT(cfg, base, add, header_max_timeout);
+    MERGE_INT(cfg, base, add, header_min_rate);
+    MERGE_INT(cfg, base, add, body_timeout);
+    MERGE_INT(cfg, base, add, body_max_timeout);
+    MERGE_INT(cfg, base, add, body_min_rate);
+
+    cfg->header_rate_factor = (cfg->header_min_rate == -1) ? base->header_rate_factor
:
+                              add->header_rate_factor;
+    cfg->body_rate_factor = (cfg->body_min_rate == -1) ? base->body_rate_factor
:
+    			     add->body_rate_factor;
+
+    return cfg;
+}
+
+static const char *parse_int(apr_pool_t *p, const char *arg, int *val) {
+    char *endptr;
+    *val = strtol(arg, &endptr, 10);
+
+    if (arg == endptr) {
+        return apr_psprintf(p, "Value '%s' not numerical", endptr);
+    }
+    if (*endptr != '\0') {
+        return apr_psprintf(p, "Cannot parse '%s'", endptr);
+    }
+    if (*val < 0) {
+        return "Value must be non-negative";
+    }
+    return NULL;
+}
+
+static const char *set_reqtimeout_param(reqtimeout_srv_cfg *conf,
+                                      apr_pool_t *p,
+                                      const char *key,
+                                      const char *val)
+{
+    const char *ret = NULL;
+    char *rate_str = NULL, *initial_str, *max_str = NULL;
+    int rate = 0, initial = 0, max = 0;
+    enum { PARAM_HEADER, PARAM_BODY } type;
+
+    if (!strcasecmp(key, "header")) {
+        type = PARAM_HEADER;
+    }
+    else if (!strcasecmp(key, "body")) {
+        type = PARAM_BODY;
+    }
+    else {
+        return "Unknown RequestReadTimeout parameter";
+    }
+    
+    if ((rate_str = ap_strcasestr(val, ",minrate="))) {
+        initial_str = apr_pstrndup(p, val, rate_str - val);
+        rate_str += strlen(",minrate=");
+        ret = parse_int(p, rate_str, &rate);
+        if (ret)
+            return ret;
+
+        if (rate == 0)
+            return "Minimum data rate must be larger than 0";
+
+        if ((max_str = strchr(initial_str, '-'))) {
+            *max_str++ = '\0';
+            ret = parse_int(p, max_str, &max);
+            if (ret)
+                return ret;
+        }
+        
+        ret = parse_int(p, initial_str, &initial);
+    }
+    else {
+        if (ap_strchr_c(val, '-'))
+            return "Must set MinRate option if using timeout range";
+        ret = parse_int(p, val, &initial);
+    }
+        
+    if (ret)
+        return ret;
+
+    if (max && initial >= max) {
+        return "Maximum timeout must be larger than initial timeout";
+    }
+
+    if (type == PARAM_HEADER) {
+        conf->header_timeout = initial;
+        conf->header_max_timeout = max;
+        conf->header_min_rate = rate;
+        if (rate)
+            conf->header_rate_factor = apr_time_from_sec(1) / rate;
+    }
+    else {
+        conf->body_timeout = initial;
+        conf->body_max_timeout = max;
+        conf->body_min_rate = rate;
+        if (rate)
+            conf->body_rate_factor = apr_time_from_sec(1) / rate;
+    }
+    return ret;
+}
+
+static const char *set_reqtimeouts(cmd_parms *cmd, void *mconfig,
+                                   const char *arg)
+{
+    reqtimeout_srv_cfg *conf =
+    ap_get_module_config(cmd->server->module_config,
+                         &reqtimeout_module);
+    
+    while (*arg) {
+        char *word, *val;
+        const char *err;
+        
+        word = ap_getword_conf(cmd->pool, &arg);
+        val = strchr(word, '=');
+        if (!val) {
+            return "Invalid RequestReadTimeout parameter. Parameter must be "
+            "in the form 'key=value'";
+        }
+        else
+            *val++ = '\0';
+
+        err = set_reqtimeout_param(conf, cmd->pool, word, val);
+        
+        if (err)
+            return apr_psprintf(cmd->temp_pool, "RequestReadTimeout: %s=%s: %s",
+                               word, val, err);
+    }
+    
+    return NULL;
+    
+}
+
+static void reqtimeout_hooks(apr_pool_t *pool)
+{
+    /*
+     * mod_ssl is AP_FTYPE_CONNECTION + 5 and mod_reqtimeout needs to
+     * be called before mod_ssl. Otherwise repeated reads during the ssl
+     * handshake can prevent the timeout from triggering.
+     */
+    ap_register_input_filter(reqtimeout_filter_name, reqtimeout_filter, NULL,
+                             AP_FTYPE_CONNECTION + 8);
+    ap_hook_pre_connection(reqtimeout_pre_conn, NULL, NULL, APR_HOOK_MIDDLE);
+    ap_hook_post_read_request(reqtimeout_after_headers, NULL, NULL,
+                              APR_HOOK_MIDDLE);
+    ap_hook_log_transaction(reqtimeout_after_body, NULL, NULL,
+                            APR_HOOK_MIDDLE);
+}
+
+static const command_rec reqtimeout_cmds[] = {
+    AP_INIT_RAW_ARGS("RequestReadTimeout", set_reqtimeouts, NULL, RSRC_CONF,
+                     "Set various timeout parameters for reading request "
+                     "headers and body"),
+    {NULL}
+};
+
+module AP_MODULE_DECLARE_DATA reqtimeout_module = {
+    STANDARD20_MODULE_STUFF,
+    NULL,                           /* create per-dir config structures */
+    NULL,                           /* merge  per-dir config structures */
+    reqtimeout_create_srv_config,   /* create per-server config structures */
+    reqtimeout_merge_srv_config,    /* merge per-server config structures */
+    reqtimeout_cmds,                /* table of config file commands */
+    reqtimeout_hooks
+};

Propchange: httpd/httpd/branches/2.2.x/modules/filters/mod_reqtimeout.c
------------------------------------------------------------------------------
    svn:eol-style = native

Added: httpd/httpd/branches/2.2.x/modules/filters/mod_reqtimeout.dsp
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.2.x/modules/filters/mod_reqtimeout.dsp?rev=917211&view=auto
==============================================================================
--- httpd/httpd/branches/2.2.x/modules/filters/mod_reqtimeout.dsp (added)
+++ httpd/httpd/branches/2.2.x/modules/filters/mod_reqtimeout.dsp Sun Feb 28 17:25:44 2010
@@ -0,0 +1,111 @@
+# Microsoft Developer Studio Project File - Name="mod_reqtimeout" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
+
+CFG=mod_reqtimeout - Win32 Release
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE 
+!MESSAGE NMAKE /f "mod_reqtimeout.mak".
+!MESSAGE 
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE 
+!MESSAGE NMAKE /f "mod_reqtimeout.mak" CFG="mod_reqtimeout - Win32 Release"
+!MESSAGE 
+!MESSAGE Possible choices for configuration are:
+!MESSAGE 
+!MESSAGE "mod_reqtimeout - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "mod_reqtimeout - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE 
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+MTL=midl.exe
+RSC=rc.exe
+
+!IF  "$(CFG)" == "mod_reqtimeout - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /FD /c
+# ADD CPP /nologo /MD /W3 /O2 /Oy- /Zi /I "../../include" /I "../../srclib/apr/include" /I
"../../srclib/apr-util/include" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "AP_RL_DECLARE_EXPORT"
/Fd"Release\mod_reqtimeout_src" /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /fo"Release/mod_reqtimeout.res" /i "../../include" /i "../../srclib/apr/include"
/d "NDEBUG" /d BIN_NAME="mod_reqtimeout.so" /d LONG_NAME="reqtimeout_module for Apache"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib /nologo /subsystem:windows /dll /out:".\Release\mod_reqtimeout.so"
/base:@..\..\os\win32\BaseAddr.ref,mod_reqtimeout.so
+# ADD LINK32 kernel32.lib /nologo /subsystem:windows /dll /incremental:no /debug /out:".\Release\mod_reqtimeout.so"
/base:@..\..\os\win32\BaseAddr.ref,mod_reqtimeout.so /opt:ref
+# Begin Special Build Tool
+TargetPath=.\Release\mod_reqtimeout.so
+SOURCE="$(InputPath)"
+PostBuild_Desc=Embed .manifest
+PostBuild_Cmds=if exist $(TargetPath).manifest mt.exe -manifest $(TargetPath).manifest -outputresource:$(TargetPath);2
+# End Special Build Tool
+
+!ELSEIF  "$(CFG)" == "mod_reqtimeout - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MDd /W3 /EHsc /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FD /c
+# ADD CPP /nologo /MDd /W3 /EHsc /Zi /Od /I "../../include" /I "../../srclib/apr/include"
/I "../../srclib/apr-util/include" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "AP_RL_DECLARE_EXPORT"
/Fd"Debug\mod_reqtimeout_src" /FD /c
+# ADD BASE MTL /nologo /D "_DEBUG" /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /fo"Debug/mod_reqtimeout.res" /i "../../include" /i "../../srclib/apr/include"
/d "_DEBUG" /d BIN_NAME="mod_reqtimeout.so" /d LONG_NAME="reqtimeout_module for Apache"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib /nologo /subsystem:windows /dll /incremental:no /debug /out:".\Debug\mod_reqtimeout.so"
/base:@..\..\os\win32\BaseAddr.ref,mod_reqtimeout.so
+# ADD LINK32 kernel32.lib /nologo /subsystem:windows /dll /incremental:no /debug /out:".\Debug\mod_reqtimeout.so"
/base:@..\..\os\win32\BaseAddr.ref,mod_reqtimeout.so
+# Begin Special Build Tool
+TargetPath=.\Debug\mod_reqtimeout.so
+SOURCE="$(InputPath)"
+PostBuild_Desc=Embed .manifest
+PostBuild_Cmds=if exist $(TargetPath).manifest mt.exe -manifest $(TargetPath).manifest -outputresource:$(TargetPath);2
+# End Special Build Tool
+
+!ENDIF 
+
+# Begin Target
+
+# Name "mod_reqtimeout - Win32 Release"
+# Name "mod_reqtimeout - Win32 Debug"
+# Begin Source File
+
+SOURCE=.\mod_reqtimeout.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\build\win32\httpd.rc
+# End Source File
+# End Target
+# End Project

Propchange: httpd/httpd/branches/2.2.x/modules/filters/mod_reqtimeout.dsp
------------------------------------------------------------------------------
    svn:eol-style = CRLF

Modified: httpd/httpd/branches/2.2.x/os/win32/BaseAddr.ref
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.2.x/os/win32/BaseAddr.ref?rev=917211&r1=917210&r2=917211&view=diff
==============================================================================
--- httpd/httpd/branches/2.2.x/os/win32/BaseAddr.ref (original)
+++ httpd/httpd/branches/2.2.x/os/win32/BaseAddr.ref Sun Feb 28 17:25:44 2010
@@ -81,3 +81,4 @@
 mod_filter.so           0x6F9A0000    0x00010000
 mod_dav_lock.so         0x6F990000    0x00010000
 mod_substitute.so       0x6F980000    0x00010000
+mod_reqtimeout.so       0x6F970000    0x00010000



Mime
View raw message