From: Yann Ylavic Date: Wed, 20 Dec 2017 14:49:17 +0000 (+0000) Subject: mpm_event: close connections not reported as handled by any module. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=81465df06176b084d73b244d7940ca70a1ac695e;p=apache mpm_event: close connections not reported as handled by any module. This avoids losing track of them and leaking scoreboard entries. PR 61551. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1818804 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/CHANGES b/CHANGES index cf1d8c6650..b2bf5ab623 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,10 @@ -*- coding: utf-8 -*- Changes with Apache 2.5.1 + *) mpm_event: close connections not reported as handled by any module to + avoid losing track of them and leaking scoreboard entries. PR 61551. + [Yann Ylavic] + *) mod_dumpio: do nothing below log level TRACE7. [Yann Ylavic] *) mod_md: reverses most of v1.0.5 optimization of post_config init, so that diff --git a/server/mpm/event/event.c b/server/mpm/event/event.c index d57e771c7e..cb730a3762 100644 --- a/server/mpm/event/event.c +++ b/server/mpm/event/event.c @@ -1049,20 +1049,30 @@ static void process_socket(apr_thread_t *thd, apr_pool_t * p, apr_socket_t * soc * otherwise write, should set the sense appropriately. */ apr_atomic_inc32(&clogged_count); - ap_run_process_connection(c); - if (cs->pub.state != CONN_STATE_SUSPENDED) { + rc = ap_run_process_connection(c); + if (rc || cs->pub.state != CONN_STATE_SUSPENDED) { cs->pub.state = CONN_STATE_LINGER; } apr_atomic_dec32(&clogged_count); } else if (cs->pub.state == CONN_STATE_READ_REQUEST_LINE) { read_request: - ap_run_process_connection(c); - - /* state will be updated upon return - * fall thru to either wait for readability/timeout or - * do lingering close + rc = ap_run_process_connection(c); + + /* State will be updated upon successful return: fall thru to either + * wait for readability/timeout, do write completion or lingering + * close. But forcibly close the connection if the run failed (handler + * raised an error for it) or the state is something unexpected at the + * MPM level (meaning that no module handled it and we can't do much + * here; note that if a handler wants mpm_event to keep POLLIN for the + * rest of the request line it should use CHECK_REQUEST_LINE_READABLE + * and not simply return OK with the initial READ_REQUEST_LINE state). */ + if (rc || (cs->pub.state != CONN_STATE_CHECK_REQUEST_LINE_READABLE + && cs->pub.state != CONN_STATE_WRITE_COMPLETION + && cs->pub.state != CONN_STATE_SUSPENDED)) { + cs->pub.state = CONN_STATE_LINGER; + } } if (cs->pub.state == CONN_STATE_WRITE_COMPLETION) {