You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by mi...@apache.org on 2022/01/24 16:14:42 UTC

svn commit: r1897423 - in /httpd/httpd/trunk: CHANGES include/ap_mmn.h include/ap_mpm.h include/httpd.h modules/ssl/mod_ssl.c server/mpm/event/event.c

Author: minfrin
Date: Mon Jan 24 16:14:42 2022
New Revision: 1897423

URL: http://svn.apache.org/viewvc?rev=1897423&view=rev
Log:
event: Add AP_MPM_CAN_AGAIN and AGAIN to signal to the MPM that
non blocking behaviour is requested.

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

Modified: httpd/httpd/trunk/CHANGES
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/CHANGES?rev=1897423&r1=1897422&r2=1897423&view=diff
==============================================================================
--- httpd/httpd/trunk/CHANGES [utf-8] (original)
+++ httpd/httpd/trunk/CHANGES [utf-8] Mon Jan 24 16:14:42 2022
@@ -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

Modified: httpd/httpd/trunk/include/ap_mmn.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/include/ap_mmn.h?rev=1897423&r1=1897422&r2=1897423&view=diff
==============================================================================
--- httpd/httpd/trunk/include/ap_mmn.h (original)
+++ httpd/httpd/trunk/include/ap_mmn.h Mon Jan 24 16:14:42 2022
@@ -699,6 +699,7 @@
  * 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.
  * 
  */
 
@@ -707,7 +708,7 @@
 #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

Modified: httpd/httpd/trunk/include/ap_mpm.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/include/ap_mpm.h?rev=1897423&r1=1897422&r2=1897423&view=diff
==============================================================================
--- httpd/httpd/trunk/include/ap_mpm.h (original)
+++ httpd/httpd/trunk/include/ap_mpm.h Mon Jan 24 16:14:42 2022
@@ -182,6 +182,8 @@ AP_DECLARE(apr_status_t) ap_os_create_pr
 #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
 /** @} */
 
 /**

Modified: httpd/httpd/trunk/include/httpd.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/include/httpd.h?rev=1897423&r1=1897422&r2=1897423&view=diff
==============================================================================
--- httpd/httpd/trunk/include/httpd.h (original)
+++ httpd/httpd/trunk/include/httpd.h Mon Jan 24 16:14:42 2022
@@ -464,6 +464,9 @@ AP_DECLARE(const char *) ap_get_server_b
                                  */
 #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(). */

Modified: httpd/httpd/trunk/modules/ssl/mod_ssl.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/ssl/mod_ssl.c?rev=1897423&r1=1897422&r2=1897423&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/ssl/mod_ssl.c (original)
+++ httpd/httpd/trunk/modules/ssl/mod_ssl.c Mon Jan 24 16:14:42 2022
@@ -701,15 +701,15 @@ static int ssl_hook_process_connection(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(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 */

Modified: httpd/httpd/trunk/server/mpm/event/event.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/mpm/event/event.c?rev=1897423&r1=1897422&r2=1897423&view=diff
==============================================================================
--- httpd/httpd/trunk/server/mpm/event/event.c (original)
+++ httpd/httpd/trunk/server/mpm/event/event.c Mon Jan 24 16:14:42 2022
@@ -734,6 +734,9 @@ static int event_query(int query_code, i
     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)