From: Yann Ylavic Date: Fri, 20 Jul 2018 15:47:16 +0000 (+0000) Subject: core: axe data_in_in/output_filter from conn_rec. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3fdba065dd16a9eafdf1997ba89277da195a66a9;p=apache core: axe data_in_in/output_filter from conn_rec. 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 --- diff --git a/include/ap_mmn.h b/include/ap_mmn.h index 98f1c3bae5..03dd7e7c24 100644 --- a/include/ap_mmn.h +++ b/include/ap_mmn.h @@ -585,14 +585,15 @@ * 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 diff --git a/include/httpd.h b/include/httpd.h index 33c7361991..45ad9765b1 100644 --- a/include/httpd.h +++ b/include/httpd.h @@ -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. diff --git a/modules/http/http_request.c b/modules/http/http_request.c index f8022e892a..1413a20c93 100644 --- a/modules/http/http_request.c +++ b/modules/http/http_request.c @@ -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; } } diff --git a/modules/http2/h2_conn.c b/modules/http2/h2_conn.c index 68233641a4..97831fd366 100644 --- a/modules/http2/h2_conn.c +++ b/modules/http2/h2_conn.c @@ -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; diff --git a/server/core.c b/server/core.c index d70acc369c..7fc2c35ec0 100644 --- a/server/core.c +++ b/server/core.c @@ -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 diff --git a/server/mpm/event/event.c b/server/mpm/event/event.c index fcc42a64c9..27071b1e37 100644 --- a/server/mpm/event/event.c +++ b/server/mpm/event/event.c @@ -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 diff --git a/server/util_filter.c b/server/util_filter.c index b1cfb0769a..e38a5af8e6 100644 --- a/server/util_filter.c +++ b/server/util_filter.c @@ -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; }