You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by yl...@apache.org on 2020/07/02 15:49:54 UTC
svn commit: r1879451 - in /httpd/httpd/trunk: include/ap_mmn.h
include/ap_mpm.h include/mpm_common.h modules/proxy/mod_proxy_http.c
modules/proxy/mod_proxy_wstunnel.c server/mpm/event/event.c
server/mpm_common.c
Author: ylavic
Date: Thu Jul 2 15:49:53 2020
New Revision: 1879451
URL: http://svn.apache.org/viewvc?rev=1879451&view=rev
Log:
Follow up to r1879449: yet better MPM poll callback API.
Let pass a const pfds to the MPM, for it to make a copy on the given pool
as needed.
Modified:
httpd/httpd/trunk/include/ap_mmn.h
httpd/httpd/trunk/include/ap_mpm.h
httpd/httpd/trunk/include/mpm_common.h
httpd/httpd/trunk/modules/proxy/mod_proxy_http.c
httpd/httpd/trunk/modules/proxy/mod_proxy_wstunnel.c
httpd/httpd/trunk/server/mpm/event/event.c
httpd/httpd/trunk/server/mpm_common.c
Modified: httpd/httpd/trunk/include/ap_mmn.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/include/ap_mmn.h?rev=1879451&r1=1879450&r2=1879451&view=diff
==============================================================================
--- httpd/httpd/trunk/include/ap_mmn.h (original)
+++ httpd/httpd/trunk/include/ap_mmn.h Thu Jul 2 15:49:53 2020
@@ -650,7 +650,6 @@
* mpm_unregister_poll_callback hook.
* 20200702.0 (2.5.1-dev) Add pool arg to mpm_register_poll_callback and
* mpm_register_poll_callback_timeout hooks
- *
*/
#define MODULE_MAGIC_COOKIE 0x41503235UL /* "AP25" */
Modified: httpd/httpd/trunk/include/ap_mpm.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/include/ap_mpm.h?rev=1879451&r1=1879450&r2=1879451&view=diff
==============================================================================
--- httpd/httpd/trunk/include/ap_mpm.h (original)
+++ httpd/httpd/trunk/include/ap_mpm.h Thu Jul 2 15:49:53 2020
@@ -224,7 +224,7 @@ AP_DECLARE(apr_status_t) ap_mpm_register
*/
AP_DECLARE(apr_status_t) ap_mpm_register_poll_callback(
- apr_pool_t *p, apr_array_header_t *pfds,
+ apr_pool_t *p, const apr_array_header_t *pfds,
ap_mpm_callback_fn_t *cbfn, void *baton);
/**
@@ -247,7 +247,7 @@ AP_DECLARE(apr_status_t) ap_mpm_register
*/
AP_DECLARE(apr_status_t) ap_mpm_register_poll_callback_timeout(
- apr_pool_t *p, apr_array_header_t *pfds,
+ apr_pool_t *p, const apr_array_header_t *pfds,
ap_mpm_callback_fn_t *cbfn, ap_mpm_callback_fn_t *tofn,
void *baton, apr_time_t timeout);
Modified: httpd/httpd/trunk/include/mpm_common.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/include/mpm_common.h?rev=1879451&r1=1879450&r2=1879451&view=diff
==============================================================================
--- httpd/httpd/trunk/include/mpm_common.h (original)
+++ httpd/httpd/trunk/include/mpm_common.h Thu Jul 2 15:49:53 2020
@@ -427,7 +427,7 @@ AP_DECLARE_HOOK(apr_status_t, mpm_regist
* @ingroup hooks
*/
AP_DECLARE_HOOK(apr_status_t, mpm_register_poll_callback,
- (apr_pool_t *p, apr_array_header_t *pds,
+ (apr_pool_t *p, const apr_array_header_t *pds,
ap_mpm_callback_fn_t *cbfn, void *baton))
/* register the specified callback, with timeout
@@ -435,9 +435,8 @@ AP_DECLARE_HOOK(apr_status_t, mpm_regist
*
*/
AP_DECLARE_HOOK(apr_status_t, mpm_register_poll_callback_timeout,
- (apr_pool_t *p, apr_array_header_t *pds,
- ap_mpm_callback_fn_t *cbfn,
- ap_mpm_callback_fn_t *tofn,
+ (apr_pool_t *p, const apr_array_header_t *pds,
+ ap_mpm_callback_fn_t *cbfn, ap_mpm_callback_fn_t *tofn,
void *baton, apr_time_t timeout))
/** Resume the suspended connection
Modified: httpd/httpd/trunk/modules/proxy/mod_proxy_http.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/proxy/mod_proxy_http.c?rev=1879451&r1=1879450&r2=1879451&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/proxy/mod_proxy_http.c (original)
+++ httpd/httpd/trunk/modules/proxy/mod_proxy_http.c Thu Jul 2 15:49:53 2020
@@ -256,7 +256,6 @@ typedef struct {
proxy_tunnel_rec *tunnel;
apr_pool_t *async_pool;
- apr_array_header_t *pfds;
apr_interval_time_t idle_timeout;
unsigned int can_go_async :1,
@@ -319,26 +318,6 @@ static void proxy_http_async_cb(void *ba
/* Pump both ends until they'd block and then start over again */
status = ap_proxy_tunnel_run(req->tunnel);
if (status == HTTP_GATEWAY_TIME_OUT) {
- if (!req->async_pool) {
- /* Create the MPM's (req->)pfds off of our tunnel's, and
- * the subpool used by the MPM to alloc its own temporary
- * data, which we want to clear on the next round (above)
- * to avoid leaks.
- */
- req->pfds = apr_array_copy(req->p, req->tunnel->pfds);
- APR_ARRAY_IDX(req->pfds, 0, apr_pollfd_t).client_data = NULL;
- APR_ARRAY_IDX(req->pfds, 1, apr_pollfd_t).client_data = NULL;
- apr_pool_create(&req->async_pool, req->p);
- }
- else {
- /* Update only reqevents of the MPM's pfds with our tunnel's,
- * the rest didn't change.
- */
- APR_ARRAY_IDX(req->pfds, 0, apr_pollfd_t).reqevents =
- APR_ARRAY_IDX(req->tunnel->pfds, 0, apr_pollfd_t).reqevents;
- APR_ARRAY_IDX(req->pfds, 1, apr_pollfd_t).reqevents =
- APR_ARRAY_IDX(req->tunnel->pfds, 1, apr_pollfd_t).reqevents;
- }
status = SUSPENDED;
}
break;
@@ -356,7 +335,16 @@ static void proxy_http_async_cb(void *ba
"proxy %s: suspended, going async",
req->proto);
- ap_mpm_register_poll_callback_timeout(req->async_pool, req->pfds,
+ if (!req->async_pool) {
+ /* Create the subpool used by the MPM to alloc its own
+ * temporary data, which we want to clear on the next
+ * round (above) to avoid leaks.
+ */
+ apr_pool_create(&req->async_pool, req->p);
+ }
+
+ ap_mpm_register_poll_callback_timeout(req->async_pool,
+ req->tunnel->pfds,
proxy_http_async_cb,
proxy_http_async_cancel_cb,
req, req->idle_timeout);
Modified: httpd/httpd/trunk/modules/proxy/mod_proxy_wstunnel.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/proxy/mod_proxy_wstunnel.c?rev=1879451&r1=1879450&r2=1879451&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/proxy/mod_proxy_wstunnel.c (original)
+++ httpd/httpd/trunk/modules/proxy/mod_proxy_wstunnel.c Thu Jul 2 15:49:53 2020
@@ -29,7 +29,6 @@ typedef struct ws_baton_t {
request_rec *r;
proxy_conn_rec *backend;
proxy_tunnel_rec *tunnel;
- apr_array_header_t *pfds;
apr_pool_t *async_pool;
const char *scheme;
} ws_baton_t;
@@ -96,15 +95,8 @@ static void proxy_wstunnel_callback(void
ap_log_rerror(APLOG_MARK, APLOG_TRACE1, 0, baton->r,
"proxy_wstunnel_callback suspend");
- /* Update only reqevents of the MPM's pfds with our tunnel's,
- * the rest didn't change.
- */
- APR_ARRAY_IDX(baton->pfds, 0, apr_pollfd_t).reqevents =
- APR_ARRAY_IDX(baton->tunnel->pfds, 0, apr_pollfd_t).reqevents;
- APR_ARRAY_IDX(baton->pfds, 1, apr_pollfd_t).reqevents =
- APR_ARRAY_IDX(baton->tunnel->pfds, 1, apr_pollfd_t).reqevents;
-
- ap_mpm_register_poll_callback_timeout(baton->async_pool, baton->pfds,
+ ap_mpm_register_poll_callback_timeout(baton->async_pool,
+ baton->tunnel->pfds,
proxy_wstunnel_callback,
proxy_wstunnel_cancel_callback,
baton, dconf->idle_timeout);
@@ -275,18 +267,15 @@ static int proxy_wstunnel_request(apr_po
tunnel->timeout = dconf->async_delay;
status = proxy_wstunnel_pump(baton, 1);
if (status == SUSPENDED) {
- /* Create the MPM's (baton->)pfds off of our tunnel's, and
- * the subpool used by the MPM to alloc its own temporary
- * data, which we want to clear on the next round (above)
- * to avoid leaks.
+ /* Create the subpool used by the MPM to alloc its own
+ * temporary data, which we want to clear on the next
+ * round (above) to avoid leaks.
*/
- baton->pfds = apr_array_copy(baton->r->pool, baton->tunnel->pfds);
- APR_ARRAY_IDX(baton->pfds, 0, apr_pollfd_t).client_data = NULL;
- APR_ARRAY_IDX(baton->pfds, 1, apr_pollfd_t).client_data = NULL;
apr_pool_create(&baton->async_pool, baton->r->pool);
rv = ap_mpm_register_poll_callback_timeout(
- baton->async_pool, baton->pfds,
+ baton->async_pool,
+ baton->tunnel->pfds,
proxy_wstunnel_callback,
proxy_wstunnel_cancel_callback,
baton,
Modified: httpd/httpd/trunk/server/mpm/event/event.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/mpm/event/event.c?rev=1879451&r1=1879450&r2=1879451&view=diff
==============================================================================
--- httpd/httpd/trunk/server/mpm/event/event.c (original)
+++ httpd/httpd/trunk/server/mpm/event/event.c Thu Jul 2 15:49:53 2020
@@ -1605,11 +1605,11 @@ static apr_status_t event_cleanup_poll_c
}
static apr_status_t event_register_poll_callback_ex(apr_pool_t *p,
- apr_array_header_t *pfds,
- ap_mpm_callback_fn_t *cbfn,
- ap_mpm_callback_fn_t *tofn,
- void *baton,
- apr_time_t timeout)
+ const apr_array_header_t *pfds,
+ ap_mpm_callback_fn_t *cbfn,
+ ap_mpm_callback_fn_t *tofn,
+ void *baton,
+ apr_time_t timeout)
{
socket_callback_baton_t *scb = apr_pcalloc(p, sizeof(*scb));
listener_poll_type *pt = apr_palloc(p, sizeof(*pt));
@@ -1621,12 +1621,12 @@ static apr_status_t event_register_poll_
scb->cbfunc = cbfn;
scb->user_baton = baton;
- scb->pfds = pfds;
+ scb->pfds = apr_array_copy(p, pfds);
- apr_pool_pre_cleanup_register(p, pfds, event_cleanup_poll_callback);
+ apr_pool_pre_cleanup_register(p, scb->pfds, event_cleanup_poll_callback);
- for (i = 0; i < pfds->nelts; i++) {
- apr_pollfd_t *pfd = (apr_pollfd_t *)pfds->elts + i;
+ for (i = 0; i < scb->pfds->nelts; i++) {
+ apr_pollfd_t *pfd = (apr_pollfd_t *)scb->pfds->elts + i;
if (pfd->reqevents) {
if (pfd->reqevents & APR_POLLIN) {
pfd->reqevents |= APR_POLLHUP;
@@ -1641,10 +1641,10 @@ static apr_status_t event_register_poll_
if (timeout > 0) {
/* XXX: This cancel timer event can fire before the pollset is updated */
- scb->cancel_event = event_get_timer_event(timeout, tofn, baton, 1, pfds);
+ scb->cancel_event = event_get_timer_event(timeout, tofn, baton, 1, scb->pfds);
}
- for (i = 0; i < pfds->nelts; i++) {
- apr_pollfd_t *pfd = (apr_pollfd_t *)pfds->elts + i;
+ for (i = 0; i < scb->pfds->nelts; i++) {
+ apr_pollfd_t *pfd = (apr_pollfd_t *)scb->pfds->elts + i;
if (pfd->client_data) {
rc = apr_pollset_add(event_pollset, pfd);
if (rc != APR_SUCCESS) {
@@ -1656,7 +1656,7 @@ static apr_status_t event_register_poll_
}
static apr_status_t event_register_poll_callback(apr_pool_t *p,
- apr_array_header_t *pfds,
+ const apr_array_header_t *pfds,
ap_mpm_callback_fn_t *cbfn,
void *baton)
{
Modified: httpd/httpd/trunk/server/mpm_common.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/mpm_common.c?rev=1879451&r1=1879450&r2=1879451&view=diff
==============================================================================
--- httpd/httpd/trunk/server/mpm_common.c (original)
+++ httpd/httpd/trunk/server/mpm_common.c Thu Jul 2 15:49:53 2020
@@ -110,11 +110,11 @@ AP_IMPLEMENT_HOOK_RUN_FIRST(apr_status_t
(conn_rec *c),
(c), APR_ENOTIMPL)
AP_IMPLEMENT_HOOK_RUN_FIRST(apr_status_t, mpm_register_poll_callback,
- (apr_pool_t *p, apr_array_header_t *pds,
+ (apr_pool_t *p, const apr_array_header_t *pds,
ap_mpm_callback_fn_t *cbfn, void *baton),
(p, pds, cbfn, baton), APR_ENOTIMPL)
AP_IMPLEMENT_HOOK_RUN_FIRST(apr_status_t, mpm_register_poll_callback_timeout,
- (apr_pool_t *p, apr_array_header_t *pds,
+ (apr_pool_t *p, const apr_array_header_t *pds,
ap_mpm_callback_fn_t *cbfn,
ap_mpm_callback_fn_t *tofn,
void *baton, apr_time_t timeout),
@@ -572,15 +572,16 @@ AP_DECLARE(apr_status_t) ap_mpm_register
}
AP_DECLARE(apr_status_t) ap_mpm_register_poll_callback(
- apr_pool_t *p, apr_array_header_t *pfds,
+ apr_pool_t *p, const apr_array_header_t *pfds,
ap_mpm_callback_fn_t *cbfn, void *baton)
{
return ap_run_mpm_register_poll_callback(p, pfds, cbfn, baton);
}
AP_DECLARE(apr_status_t) ap_mpm_register_poll_callback_timeout(
- apr_pool_t *p, apr_array_header_t *pfds, ap_mpm_callback_fn_t *cbfn,
- ap_mpm_callback_fn_t *tofn, void *baton, apr_time_t timeout)
+ apr_pool_t *p, const apr_array_header_t *pfds,
+ ap_mpm_callback_fn_t *cbfn, ap_mpm_callback_fn_t *tofn,
+ void *baton, apr_time_t timeout)
{
return ap_run_mpm_register_poll_callback_timeout(p, pfds, cbfn, tofn,
baton, timeout);