summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGraham Leggett <minfrin@apache.org>2022-01-24 17:14:42 +0100
committerGraham Leggett <minfrin@apache.org>2022-01-24 17:14:42 +0100
commit3c6a7074916ea1b6b448e2c2c196de65f878efea (patch)
treec4e72644badeda65792dc46a02b7480aa6aa18d8
parentmod_reqtimeout: Set socket timeout for AP_MODE_INIT. (diff)
downloadapache2-3c6a7074916ea1b6b448e2c2c196de65f878efea.tar.xz
apache2-3c6a7074916ea1b6b448e2c2c196de65f878efea.zip
event: Add AP_MPM_CAN_AGAIN and AGAIN to signal to the MPM that
non blocking behaviour is requested. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1897423 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--CHANGES5
-rw-r--r--include/ap_mmn.h3
-rw-r--r--include/ap_mpm.h2
-rw-r--r--include/httpd.h3
-rw-r--r--modules/ssl/mod_ssl.c10
-rw-r--r--server/mpm/event/event.c11
6 files changed, 23 insertions, 11 deletions
diff --git a/CHANGES b/CHANGES
index 233319563a..044de2ae07 100644
--- 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
diff --git a/include/ap_mmn.h b/include/ap_mmn.h
index 6dbbe5e27c..25709472db 100644
--- a/include/ap_mmn.h
+++ b/include/ap_mmn.h
@@ -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
diff --git a/include/ap_mpm.h b/include/ap_mpm.h
index 6698d0e7c6..82075a4488 100644
--- a/include/ap_mpm.h
+++ b/include/ap_mpm.h
@@ -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
/** @} */
/**
diff --git a/include/httpd.h b/include/httpd.h
index e5375d77c2..f9f36fee5b 100644
--- a/include/httpd.h
+++ b/include/httpd.h
@@ -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(). */
diff --git a/modules/ssl/mod_ssl.c b/modules/ssl/mod_ssl.c
index 0faed73af7..40b83a8709 100644
--- a/modules/ssl/mod_ssl.c
+++ b/modules/ssl/mod_ssl.c
@@ -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 */
diff --git a/server/mpm/event/event.c b/server/mpm/event/event.c
index 44943aef69..11443dea7a 100644
--- a/server/mpm/event/event.c
+++ b/server/mpm/event/event.c
@@ -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)