httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From minf...@apache.org
Subject svn commit: r1731253 - in /httpd/httpd/trunk: CHANGES include/ap_mmn.h include/mpm_common.h include/util_filter.h server/core.c server/mpm/event/event.c server/mpm/motorz/motorz.c server/mpm/simple/simple_io.c server/mpm_common.c server/util_filter.c
Date Fri, 19 Feb 2016 15:00:05 GMT
Author: minfrin
Date: Fri Feb 19 15:00:05 2016
New Revision: 1731253

URL: http://svn.apache.org/viewvc?rev=1731253&view=rev
Log:
mpm: Add a complete_connection hook that confirms whether an MPM is allowed
to leave the WRITE_COMPLETION phase. Move filter code out of the MPMs.

Modified:
    httpd/httpd/trunk/CHANGES
    httpd/httpd/trunk/include/ap_mmn.h
    httpd/httpd/trunk/include/mpm_common.h
    httpd/httpd/trunk/include/util_filter.h
    httpd/httpd/trunk/server/core.c
    httpd/httpd/trunk/server/mpm/event/event.c
    httpd/httpd/trunk/server/mpm/motorz/motorz.c
    httpd/httpd/trunk/server/mpm/simple/simple_io.c
    httpd/httpd/trunk/server/mpm_common.c
    httpd/httpd/trunk/server/util_filter.c

Modified: httpd/httpd/trunk/CHANGES
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/CHANGES?rev=1731253&r1=1731252&r2=1731253&view=diff
==============================================================================
--- httpd/httpd/trunk/CHANGES [utf-8] (original)
+++ httpd/httpd/trunk/CHANGES [utf-8] Fri Feb 19 15:00:05 2016
@@ -1,6 +1,10 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache 2.5.0
 
+  *) mpm: Add a complete_connection hook that confirms whether an MPM is allowed
+     to leave the WRITE_COMPLETION phase. Move filter code out of the MPMs.
+     [Graham Leggett]
+
   *) mod_proxy_http2: using single connection for several requests *if*
      master connection uses HTTP/2 itself. Not yet hardened under load.
      [Stefan Eissing]

Modified: httpd/httpd/trunk/include/ap_mmn.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/include/ap_mmn.h?rev=1731253&r1=1731252&r2=1731253&view=diff
==============================================================================
--- httpd/httpd/trunk/include/ap_mmn.h (original)
+++ httpd/httpd/trunk/include/ap_mmn.h Fri Feb 19 15:00:05 2016
@@ -504,6 +504,8 @@
  *                         ap_prep_lingering_close().
  * 20150222.11 (2.5.0-dev) Split useragent_host from the conn_rec into
  *                         the request_rec, with ap_get_useragent_host()
+ * 20150222.12 (2.5.0-dev) Add complete_connection hook,
+ *                         ap_filter_complete_connection().
  */
 
 #define MODULE_MAGIC_COOKIE 0x41503235UL /* "AP25" */
@@ -511,7 +513,7 @@
 #ifndef MODULE_MAGIC_NUMBER_MAJOR
 #define MODULE_MAGIC_NUMBER_MAJOR 20150222
 #endif
-#define MODULE_MAGIC_NUMBER_MINOR 11                 /* 0...n */
+#define MODULE_MAGIC_NUMBER_MINOR 12                 /* 0...n */
 
 /**
  * Determine if the server's current MODULE_MAGIC_NUMBER is at least a

Modified: httpd/httpd/trunk/include/mpm_common.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/include/mpm_common.h?rev=1731253&r1=1731252&r2=1731253&view=diff
==============================================================================
--- httpd/httpd/trunk/include/mpm_common.h (original)
+++ httpd/httpd/trunk/include/mpm_common.h Fri Feb 19 15:00:05 2016
@@ -458,6 +458,16 @@ AP_DECLARE_HOOK(apr_status_t, mpm_resume
 AP_DECLARE_HOOK(const char *,mpm_get_name,(void))
 
 /**
+ * Hook called to determine whether we should stay within the write completion
+ * phase.
+ * @param c The current connection
+ * @return OK if write completion should continue, DECLINED if write completion
+ * should end gracefully, or a positive error if we should begin to linger.
+ * @ingroup hooks
+ */
+AP_DECLARE_HOOK(int, complete_connection, (conn_rec *c))
+
+/**
  * Notification that connection handling is suspending (disassociating from the
  * current thread)
  * @param c The current connection

Modified: httpd/httpd/trunk/include/util_filter.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/include/util_filter.h?rev=1731253&r1=1731252&r2=1731253&view=diff
==============================================================================
--- httpd/httpd/trunk/include/util_filter.h (original)
+++ httpd/httpd/trunk/include/util_filter.h Fri Feb 19 15:00:05 2016
@@ -590,6 +590,18 @@ AP_DECLARE(apr_status_t) ap_filter_reins
 AP_DECLARE(int) ap_filter_should_yield(ap_filter_t *f);
 
 /**
+ * This function determines whether there is unwritten data in the output
+ * filters, and if so, attempts to make a single write to each filter
+ * with unwritten data.
+ *
+ * @param c The connection.
+ * @return If no unwritten data remains, this function returns DECLINED.
+ * If some unwritten data remains, this function returns OK. If any
+ * attempt to write data failed, this functions returns a positive integer.
+ */
+AP_DECLARE(int) ap_filter_complete_connection(conn_rec *c);
+
+/**
  * Flush function for apr_brigade_* calls.  This calls ap_pass_brigade
  * to flush the brigade if the brigade buffer overflows.
  * @param bb The brigade to flush

Modified: httpd/httpd/trunk/server/core.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/core.c?rev=1731253&r1=1731252&r2=1731253&view=diff
==============================================================================
--- httpd/httpd/trunk/server/core.c (original)
+++ httpd/httpd/trunk/server/core.c Fri Feb 19 15:00:05 2016
@@ -5559,7 +5559,9 @@ static void register_hooks(apr_pool_t *p
     ap_hook_open_htaccess(ap_open_htaccess, NULL, NULL, APR_HOOK_REALLY_LAST);
     ap_hook_optional_fn_retrieve(core_optional_fn_retrieve, NULL, NULL,
                                  APR_HOOK_MIDDLE);
-    
+    ap_hook_complete_connection(ap_filter_complete_connection, NULL, NULL,
+                           APR_HOOK_MIDDLE);
+
     /* register the core's insert_filter hook and register core-provided
      * filters
      */

Modified: httpd/httpd/trunk/server/mpm/event/event.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/mpm/event/event.c?rev=1731253&r1=1731252&r2=1731253&view=diff
==============================================================================
--- httpd/httpd/trunk/server/mpm/event/event.c (original)
+++ httpd/httpd/trunk/server/mpm/event/event.c Fri Feb 19 15:00:05 2016
@@ -1147,38 +1147,16 @@ read_request:
     }
 
     if (cs->pub.state == CONN_STATE_WRITE_COMPLETION) {
-        apr_hash_index_t *rindex;
-        apr_status_t rv = APR_SUCCESS;
-        int data_in_output_filters = 0;
-        ap_update_child_status_from_conn(sbh, SERVER_BUSY_WRITE, c);
-
-        rindex = apr_hash_first(NULL, c->filters);
-        while (rindex) {
-            ap_filter_t *f = apr_hash_this_val(rindex);
-
-            if (!APR_BRIGADE_EMPTY(f->bb)) {
+        int not_complete_yet;
 
-                rv = ap_pass_brigade(f, c->empty);
-                apr_brigade_cleanup(c->empty);
-                if (APR_SUCCESS != rv) {
-                    ap_log_cerror(
-                            APLOG_MARK, APLOG_DEBUG, rv, c, APLOGNO(00470)
-                            "write failure in '%s' output filter", f->frec->name);
-                    break;
-                }
-
-                if (ap_filter_should_yield(f)) {
-                    data_in_output_filters = 1;
-                }
-            }
+        ap_update_child_status_from_conn(sbh, SERVER_BUSY_WRITE, c);
 
-            rindex = apr_hash_next(rindex);
-        }
+        not_complete_yet = ap_run_complete_connection(c);
 
-        if (rv != APR_SUCCESS) {
+        if (not_complete_yet > OK) {
             cs->pub.state = CONN_STATE_LINGER;
         }
-        else if (data_in_output_filters) {
+        else if (not_complete_yet == OK) {
             /* Still in WRITE_COMPLETION_STATE:
              * Set a write timeout for this connection, and let the
              * event thread poll for writeability.

Modified: httpd/httpd/trunk/server/mpm/motorz/motorz.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/mpm/motorz/motorz.c?rev=1731253&r1=1731252&r2=1731253&view=diff
==============================================================================
--- httpd/httpd/trunk/server/mpm/motorz/motorz.c (original)
+++ httpd/httpd/trunk/server/mpm/motorz/motorz.c Fri Feb 19 15:00:05 2016
@@ -395,42 +395,19 @@ read_request:
         }
 
         if (scon->cs.state == CONN_STATE_WRITE_COMPLETION) {
-            apr_hash_index_t *rindex;
-            apr_status_t rv = APR_SUCCESS;
-            int data_in_output_filters = 0;
+            int not_complete_yet;
 
             ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, ap_server_conf, APLOGNO()
                                   "motorz_io_process(): CONN_STATE_WRITE_COMPLETION");
 
             ap_update_child_status_from_conn(scon->sbh, SERVER_BUSY_WRITE, c);
 
-            rindex = apr_hash_first(NULL, c->filters);
-            while (rindex) {
-                ap_filter_t *f = apr_hash_this_val(rindex);
+            not_complete_yet = ap_run_complete_connection(c);
 
-                if (!APR_BRIGADE_EMPTY(f->bb)) {
-
-                    rv = ap_pass_brigade(f, c->empty);
-                    apr_brigade_cleanup(c->empty);
-                    if (APR_SUCCESS != rv) {
-                        ap_log_cerror(
-                                APLOG_MARK, APLOG_DEBUG, rv, c, APLOGNO(02848)
-                                "write failure in '%s' output filter", f->frec->name);
-                        break;
-                    }
-
-                    if (ap_filter_should_yield(f)) {
-                        data_in_output_filters = 1;
-                    }
-                }
-
-                rindex = apr_hash_next(rindex);
-            }
-
-            if (rv != APR_SUCCESS) {
+            if (not_complete_yet > OK) {
                 scon->cs.state = CONN_STATE_LINGER;
             }
-            else if (data_in_output_filters) {
+            else if (not_complete_yet == OK) {
                 /* Still in WRITE_COMPLETION_STATE:
                  * Set a write timeout for this connection, and let the
                  * event thread poll for writeability.

Modified: httpd/httpd/trunk/server/mpm/simple/simple_io.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/mpm/simple/simple_io.c?rev=1731253&r1=1731252&r2=1731253&view=diff
==============================================================================
--- httpd/httpd/trunk/server/mpm/simple/simple_io.c (original)
+++ httpd/httpd/trunk/server/mpm/simple/simple_io.c Fri Feb 19 15:00:05 2016
@@ -92,37 +92,15 @@ static apr_status_t simple_io_process(si
         }
 
         if (scon->cs.state == CONN_STATE_WRITE_COMPLETION) {
-            apr_hash_index_t *rindex;
-            apr_status_t rv = APR_SUCCESS;
-            int data_in_output_filters = 0;
+            int not_complete_yet;
 
-            rindex = apr_hash_first(NULL, c->filters);
-            while (rindex) {
-                ap_filter_t *f = apr_hash_this_val(rindex);
+            ap_update_child_status_from_conn(sbh, SERVER_BUSY_WRITE, c);
+            not_complete_yet = ap_run_complete_connection(c);
 
-                if (!APR_BRIGADE_EMPTY(f->bb)) {
-
-                    rv = ap_pass_brigade(f, c->empty);
-                    apr_brigade_cleanup(c->empty);
-                    if (APR_SUCCESS != rv) {
-                        ap_log_cerror(
-                                APLOG_MARK, APLOG_DEBUG, rv, c, APLOGNO(00249)
-                                "write failure in '%s' output filter", f->frec->name);
-                        break;
-                    }
-
-                    if (ap_filter_should_yield(f)) {
-                        data_in_output_filters = 1;
-                    }
-                }
-
-                rindex = apr_hash_next(rindex);
-            }
-
-            if (rv != APR_SUCCESS) {
+            if (not_complete_yet > OK) {
                 scon->cs.state = CONN_STATE_LINGER;
             }
-            else if (data_in_output_filters) {
+            else if (not_complete_yet == OK) {
                 /* Still in WRITE_COMPLETION_STATE:
                  * Set a write timeout for this connection, and let the
                  * event thread poll for writeability.

Modified: httpd/httpd/trunk/server/mpm_common.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/mpm_common.c?rev=1731253&r1=1731252&r2=1731253&view=diff
==============================================================================
--- httpd/httpd/trunk/server/mpm_common.c (original)
+++ httpd/httpd/trunk/server/mpm_common.c Fri Feb 19 15:00:05 2016
@@ -75,6 +75,7 @@
     APR_HOOK_LINK(mpm_resume_suspended) \
     APR_HOOK_LINK(end_generation) \
     APR_HOOK_LINK(child_status) \
+    APR_HOOK_LINK(complete_connection) \
     APR_HOOK_LINK(suspend_connection) \
     APR_HOOK_LINK(resume_connection)
 
@@ -95,6 +96,7 @@ AP_IMPLEMENT_HOOK_RUN_ALL(int, monitor,
 AP_IMPLEMENT_HOOK_RUN_ALL(int, drop_privileges,
                           (apr_pool_t * pchild, server_rec * s),
                           (pchild, s), OK, DECLINED)
+
 AP_IMPLEMENT_HOOK_RUN_FIRST(int, mpm,
                             (apr_pool_t *pconf, apr_pool_t *plog, server_rec *s),
                             (pconf, plog, s), DECLINED)
@@ -116,6 +118,8 @@ AP_IMPLEMENT_HOOK_RUN_FIRST(apr_status_t
 AP_IMPLEMENT_HOOK_RUN_FIRST(apr_status_t, mpm_unregister_socket_callback,
                             (apr_socket_t **s, apr_pool_t *p),
                             (s, p), APR_ENOTIMPL)
+AP_IMPLEMENT_HOOK_RUN_FIRST(int, complete_connection,
+                            (conn_rec *c), (c), DECLINED)
 
 AP_IMPLEMENT_HOOK_VOID(end_generation,
                        (server_rec *s, ap_generation_t gen),

Modified: httpd/httpd/trunk/server/util_filter.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/util_filter.c?rev=1731253&r1=1731252&r2=1731253&view=diff
==============================================================================
--- httpd/httpd/trunk/server/util_filter.c (original)
+++ httpd/httpd/trunk/server/util_filter.c Fri Feb 19 15:00:05 2016
@@ -953,6 +953,39 @@ AP_DECLARE(int) ap_filter_should_yield(a
     return 0;
 }
 
+AP_DECLARE(int) ap_filter_complete_connection(conn_rec *c)
+{
+    apr_hash_index_t *rindex;
+    int data_in_output_filters = DECLINED;
+
+    rindex = apr_hash_first(NULL, c->filters);
+    while (rindex) {
+        ap_filter_t *f = apr_hash_this_val(rindex);
+
+        if (!APR_BRIGADE_EMPTY(f->bb)) {
+
+            apr_status_t rv;
+
+            rv = ap_pass_brigade(f, c->empty);
+            apr_brigade_cleanup(c->empty);
+            if (APR_SUCCESS != rv) {
+                ap_log_cerror(
+                        APLOG_MARK, APLOG_DEBUG, rv, c, APLOGNO(00470)
+                        "write failure in '%s' output filter", f->frec->name);
+                return rv;
+            }
+
+            if (ap_filter_should_yield(f)) {
+                data_in_output_filters = OK;
+            }
+        }
+
+        rindex = apr_hash_next(rindex);
+    }
+
+    return data_in_output_filters;
+}
+
 AP_DECLARE_NONSTD(apr_status_t) ap_filter_flush(apr_bucket_brigade *bb,
                                                 void *ctx)
 {



Mime
View raw message