]> granicus.if.org Git - apache/commitdiff
core: axe data_in_in/output_filter from conn_rec.
authorYann Ylavic <ylavic@apache.org>
Fri, 20 Jul 2018 15:47:16 +0000 (15:47 +0000)
committerYann Ylavic <ylavic@apache.org>
Fri, 20 Jul 2018 15:47:16 +0000 (15:47 +0000)
They were superseded by ap_filter_should_yield() and ap_run_in/output_pending()
in r1706669 and had poor semantics since then (we can't maintain pending
semantics both by filter and for the whole connection).

Register ap_filter_input_pending() as the default input_pending hook (which
seems to have been forgotten in the first place).

On the MPM event side, we don't need to flush pending output data when the
connection has just been processed, ap_filter_should_yield() is lightweight and
enough to determine whether we should really enter write completion state or go
straight to reading. ap_run_output_pending() is used only when write completion
is in place and needs to be completed before more processing.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1836364 13f79535-47bb-0310-9956-ffa450edef68

include/ap_mmn.h
include/httpd.h
modules/http/http_request.c
modules/http2/h2_conn.c
server/core.c
server/mpm/event/event.c
server/util_filter.c

index 98f1c3bae5a5d73b1a8b3ec9ad3abaea434296d4..03dd7e7c24f18e83d81ad5ddd76578467008a8a7 100644 (file)
  * 20180716.2 (2.5.1-dev)  Add read_buf_size member to core_dir_config,
  *                         flush_max_threshold and flush_max_pipelined to
  *                         core_server_config, and ap_get_read_buf_size().
+ * 20180720.1 (2.5.1-dev)  Axe data_in_{in,out}put_filter from conn_rec.
  */
 
 #define MODULE_MAGIC_COOKIE 0x41503235UL /* "AP25" */
 
 #ifndef MODULE_MAGIC_NUMBER_MAJOR
-#define MODULE_MAGIC_NUMBER_MAJOR 20180716
+#define MODULE_MAGIC_NUMBER_MAJOR 20180720
 #endif
-#define MODULE_MAGIC_NUMBER_MINOR 2                 /* 0...n */
+#define MODULE_MAGIC_NUMBER_MINOR 1                 /* 0...n */
 
 /**
  * Determine if the server's current MODULE_MAGIC_NUMBER is at least a
index 33c73619916a1da3fba3e2c231087c94a8104078..45ad9765b1877dbd3d86732275690bab69fb3d27 100644 (file)
@@ -1163,16 +1163,6 @@ struct conn_rec {
     struct apr_bucket_alloc_t *bucket_alloc;
     /** The current state of this connection; may be NULL if not used by MPM */
     conn_state_t *cs;
-    /** Used internally to force ap_filter_input_pending() decision,
-     *  the public interface is ap_filter_should_yield(c->input_filters)
-     *  or ap_filter_input_pending().
-     */
-    int data_in_input_filters;
-    /** Used internally to force ap_filter_output_pending() decision,
-     *  the public interface is ap_filter_should_yield(c->output_filters)
-     *  or ap_filter_output_pending().
-     */
-    int data_in_output_filters;
 
     /** Are there any filters that clogg/buffer the input stream, breaking
      *  the event mpm.
index f8022e892afa04ef741e86902e810dd499f69654..1413a20c93122f4fc9dd577cc0798de8ecc21366 100644 (file)
@@ -350,7 +350,6 @@ AP_DECLARE(void) ap_process_request_after_handler(request_rec *r)
     apr_bucket_brigade *bb;
     apr_bucket *b;
     conn_rec *c = r->connection;
-    apr_status_t rv;
     ap_filter_t *f;
 
     /* Send an EOR bucket through the output filter chain.  When
@@ -399,8 +398,7 @@ AP_DECLARE(void) ap_process_request_after_handler(request_rec *r)
      * without flushing data, and hence possibly delay pending response(s)
      * until the next/real request comes in or the keepalive timeout expires.
      */
-    rv = ap_check_pipeline(c, bb, DEFAULT_LIMIT_BLANK_LINES);
-    c->data_in_input_filters = (rv == APR_SUCCESS);
+    (void)ap_check_pipeline(c, bb, DEFAULT_LIMIT_BLANK_LINES);
     apr_brigade_cleanup(bb);
 
     if (c->cs) {
@@ -413,7 +411,6 @@ AP_DECLARE(void) ap_process_request_after_handler(request_rec *r)
              * to not try another useless/stressful one but to go straight to
              * POLLOUT.
             */
-            c->data_in_output_filters = ap_filter_should_yield(c->output_filters);
             c->cs->state = CONN_STATE_WRITE_COMPLETION;
         }
     }
index 68233641a4cdcfb957f95010c69bd165f614d7de..97831fd36621857d1a74d5db8334cf81c73317f8 100644 (file)
@@ -314,8 +314,6 @@ conn_rec *h2_slave_create(conn_rec *master, int slave_id, apr_pool_t *parent)
     c->input_filters          = NULL;
     c->output_filters         = NULL;
     c->bucket_alloc           = apr_bucket_alloc_create(pool);
-    c->data_in_input_filters  = 0;
-    c->data_in_output_filters = 0;
     /* prevent mpm_event from making wrong assumptions about this connection,
      * like e.g. using its socket for an async read check. */
     c->clogging_input_filters = 1;
index d70acc369ccf849fb640a5454eafac91b0094414..7fc2c35ec0eb822563845670c9141c8509c70802 100644 (file)
@@ -5850,8 +5850,11 @@ 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_input_pending(ap_filter_input_pending, NULL, NULL,
+                          APR_HOOK_MIDDLE);
     ap_hook_output_pending(ap_filter_output_pending, NULL, NULL,
-            APR_HOOK_MIDDLE);
+                           APR_HOOK_MIDDLE);
 
     /* register the core's insert_filter hook and register core-provided
      * filters
index fcc42a64c95620eb30886a2e908b01ddd7b40df9..27071b1e374217e58be967ef777e24d0e7fccf66 100644 (file)
@@ -992,7 +992,7 @@ static void process_socket(apr_thread_t *thd, apr_pool_t * p, apr_socket_t * soc
 {
     conn_rec *c;
     long conn_id = ID_FROM_CHILD_THREAD(my_child_num, my_thread_num);
-    int clogging = 0;
+    int clogging = 0, from_wc_q = 0;
     apr_status_t rv;
     int rc = OK;
 
@@ -1094,6 +1094,9 @@ read_request:
                 rc = OK;
             }
         }
+        else if (cs->pub.state == CONN_STATE_WRITE_COMPLETION) {
+            from_wc_q = 1;
+        }
     }
     /*
      * The process_connection hooks above should set the connection state
@@ -1137,11 +1140,17 @@ read_request:
     }
 
     if (cs->pub.state == CONN_STATE_WRITE_COMPLETION) {
-        int pending;
+        int pending = DECLINED;
 
         ap_update_child_status(cs->sbh, SERVER_BUSY_WRITE, NULL);
 
-        pending = ap_run_output_pending(c);
+        if (from_wc_q) {
+            from_wc_q = 0; /* one shot */
+            pending = ap_run_output_pending(c);
+        }
+        else if (ap_filter_should_yield(c->output_filters)) {
+            pending = OK;
+        }
         if (pending == OK) {
             /* Still in WRITE_COMPLETION_STATE:
              * Set a write timeout for this connection, and let the
index b1cfb0769ab3b3c0639a51de67070ec4d2af975c..e38a5af8e6a5b28cde82e61641d9bde97ba9e727 100644 (file)
@@ -998,10 +998,6 @@ AP_DECLARE_NONSTD(int) ap_filter_output_pending(conn_rec *c)
     apr_bucket_brigade *bb;
     ap_filter_t *f;
 
-    if (c->data_in_output_filters) {
-        return OK;
-    }
-
     if (!c->pending_filters) {
         return DECLINED;
     }
@@ -1038,10 +1034,6 @@ AP_DECLARE_NONSTD(int) ap_filter_input_pending(conn_rec *c)
 {
     ap_filter_t *f;
 
-    if (c->data_in_input_filters) {
-        return OK;
-    }
-
     if (!c->pending_filters) {
         return DECLINED;
     }