]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
event: Add AP_MPM_CAN_AGAIN and AGAIN to signal to the MPM that
authorGraham Leggett <minfrin@apache.org>
Mon, 24 Jan 2022 16:14:42 +0000 (16:14 +0000)
committerGraham Leggett <minfrin@apache.org>
Mon, 24 Jan 2022 16:14:42 +0000 (16:14 +0000)
non blocking behaviour is requested.

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

CHANGES
include/ap_mmn.h
include/ap_mpm.h
include/httpd.h
modules/ssl/mod_ssl.c
server/mpm/event/event.c

diff --git a/CHANGES b/CHANGES
index 233319563af7db386285582d132173cc61393b59..044de2ae07d3d85217046381ef605472bc0bd046 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -3,8 +3,9 @@ Changes with Apache 2.5.1
 
   *) event: Add support for non blocking behaviour in the
      CONN_STATE_READ_REQUEST_LINE phase, in addition to the existing
-     CONN_STATE_WRITE_COMPLETION phase. Update mod_ssl to perform non blocking
-     TLS handshakes. [Graham Leggett]
+     CONN_STATE_WRITE_COMPLETION phase. Add AP_MPM_CAN_AGAIN and AGAIN to
+     signal to the MPM that non blocking behaviour is requested. Update
+     mod_ssl to perform non blocking TLS handshakes. [Graham Leggett]
 
   *) http: Enforce that fully qualified uri-paths not to be forward-proxied
      have an http(s) scheme, and that the ones to be forward proxied have a
index 6dbbe5e27ca7a05824ea685f3100ccc16f940d1e..25709472db5bc93fbf6946dc251909bdb7a28f49 100644 (file)
  * 20211221.0 (2.5.1-dev)  Bump PROXY_WORKER_MAX_NAME_SIZE from 256 to 384,
  *                         add PROXY_WORKER_UDS_PATH_SIZE.
  * 20211221.1 (2.5.1-dev)  Add read_line to scoreboard.
+ * 20211221.2 (2.5.1-dev)  Add AGAIN, AP_MPMQ_CAN_AGAIN.
  * 
  */
 
 #ifndef MODULE_MAGIC_NUMBER_MAJOR
 #define MODULE_MAGIC_NUMBER_MAJOR 20211221
 #endif
-#define MODULE_MAGIC_NUMBER_MINOR 1             /* 0...n */
+#define MODULE_MAGIC_NUMBER_MINOR 2             /* 0...n */
 
 /**
  * Determine if the server's current MODULE_MAGIC_NUMBER is at least a
index 6698d0e7c6069ecef0c7c55a14472ac2efa4a01f..82075a4488b31916ca754c3b7ee804af38cab834 100644 (file)
@@ -182,6 +182,8 @@ AP_DECLARE(apr_status_t) ap_os_create_privileged_process(
 #define AP_MPMQ_CAN_SUSPEND          17
 /** MPM supports additional pollfds */
 #define AP_MPMQ_CAN_POLL             18
+/** MPM reacts to AGAIN response */
+#define AP_MPMQ_CAN_AGAIN            19
 /** @} */
 
 /**
index e5375d77c225c8b94c36acc34781baaea1b3d797..f9f36fee5b97e3deebdd77ec170bdb03ed7cf518 100644 (file)
@@ -464,6 +464,9 @@ AP_DECLARE(const char *) ap_get_server_built(void);
                                  */
 #define SUSPENDED -3 /**< Module will handle the remainder of the request.
                       * The core will never invoke the request again, */
+#define AGAIN -4                /**< Module wants to be called again when
+                                  *  more data is availble.
+                                  */
 
 /** Returned by the bottom-most filter if no data was written.
  *  @see ap_pass_brigade(). */
index 0faed73af7921122d98dce143074b99631b566d9..40b83a8709f1cde7d80dc5c05f95a0d646e15b93 100644 (file)
@@ -701,15 +701,15 @@ static int ssl_hook_process_connection(conn_rec* c)
          */
         apr_bucket_brigade* temp;
 
-        int async_mpm = 0;
+        int again_mpm = 0;
 
         temp = apr_brigade_create(c->pool, c->bucket_alloc);
 
-        if (ap_mpm_query(AP_MPMQ_IS_ASYNC, &async_mpm) != APR_SUCCESS) {
-            async_mpm = 0;
+        if (ap_mpm_query(AP_MPMQ_CAN_AGAIN, &again_mpm) != APR_SUCCESS) {
+            again_mpm = 0;
         }
 
-        if (async_mpm) {
+        if (again_mpm) {
 
             /* Take advantage of an async MPM. If we see an EAGAIN,
              * loop round and don't block.
@@ -735,7 +735,7 @@ static int ssl_hook_process_connection(conn_rec* c)
                 ap_log_cerror(APLOG_MARK, APLOG_DEBUG, 0, c, APLOGNO(10371)
                               "SSL handshake in progress, continuing");
 
-               status = OK;
+               status = AGAIN;
             }
             else if (rv == AP_FILTER_ERROR) {
                 /* handshake error, but mod_ssl handled it */
index 44943aef6931ab7a9329b5fb5bd3af1a90f0e2d6..11443dea7ac34d1359edc51338a5aeabaaaaa305 100644 (file)
@@ -734,6 +734,9 @@ static int event_query(int query_code, int *result, apr_status_t *rv)
     case AP_MPMQ_CAN_POLL:
         *result = 1;
         break;
+    case AP_MPMQ_CAN_AGAIN:
+        *result = 1;
+        break;
     default:
         *rv = APR_ENOTIMPL;
         break;
@@ -1122,6 +1125,8 @@ read_request:
     /*
      * The process_connection hooks above should set the connection state
      * appropriately upon return, for event MPM to either:
+     * - call the hooks again after waiting for a read or write, or react to an
+     *   overridden CONN_SENSE_WANT_READ / CONN_SENSE_WANT_WRITE.
      * - do lingering close (CONN_STATE_LINGER),
      * - wait for readability of the next request with respect to the keepalive
      *   timeout (state CONN_STATE_CHECK_REQUEST_LINE_READABLE),
@@ -1147,12 +1152,12 @@ read_request:
      * while this was expected to do lingering close unconditionally with
      * worker or prefork MPMs for instance.
      */
-    if (rc != OK || (cs->pub.state >= CONN_STATE_NUM)
+    if (rc != AGAIN && (
+        rc != OK || (cs->pub.state >= CONN_STATE_NUM)
                  || (cs->pub.state < CONN_STATE_LINGER
-                     && cs->pub.state != CONN_STATE_READ_REQUEST_LINE
                      && cs->pub.state != CONN_STATE_WRITE_COMPLETION
                      && cs->pub.state != CONN_STATE_CHECK_REQUEST_LINE_READABLE
-                     && cs->pub.state != CONN_STATE_SUSPENDED)) {
+                     && cs->pub.state != CONN_STATE_SUSPENDED))) {
         ap_log_cerror(APLOG_MARK, APLOG_DEBUG, 0, c, APLOGNO(10111)
                       "process_socket: connection processing %s: closing",
                       rc ? apr_psprintf(c->pool, "returned error %i", rc)