From: Yann Ylavic Date: Sat, 7 Jun 2014 22:57:08 +0000 (+0000) Subject: mpm_event[opt]: Send the SSL close notify alert when the KeepAliveTimeout X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fd39e28b8396007b1f6bea3290aa25f55028f8a3;p=thirdparty%2Fapache%2Fhttpd.git mpm_event[opt]: Send the SSL close notify alert when the KeepAliveTimeout expires. PR54998. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1601185 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/CHANGES b/CHANGES index 4ef66ba0d27..52af761c883 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,9 @@ -*- coding: utf-8 -*- Changes with Apache 2.5.0 + *) mpm_event[opt]: Send the SSL close notify alert when the KeepAliveTimeout + expires. PR54998. [Yann Ylavic] + *) mod_ssl: Ensure that the SSL close notify alert is flushed to the client. PR54998. [Tim Kosse , Yann Ylavic] diff --git a/include/ap_mmn.h b/include/ap_mmn.h index 7ba28e13fd5..55cc96395db 100644 --- a/include/ap_mmn.h +++ b/include/ap_mmn.h @@ -456,6 +456,7 @@ * ap_mpm_query(), and suspended_baton to conn_rec * 20140207.6 (2.5.0-dev) Added ap_log_common(). * 20140207.7 (2.5.0-dev) Added ap_force_set_tz(). + * 20140207.8 (2.5.0-dev) Added ap_shutdown_conn(). */ #define MODULE_MAGIC_COOKIE 0x41503235UL /* "AP25" */ @@ -463,7 +464,7 @@ #ifndef MODULE_MAGIC_NUMBER_MAJOR #define MODULE_MAGIC_NUMBER_MAJOR 20140207 #endif -#define MODULE_MAGIC_NUMBER_MINOR 7 /* 0...n */ +#define MODULE_MAGIC_NUMBER_MINOR 8 /* 0...n */ /** * Determine if the server's current MODULE_MAGIC_NUMBER is at least a diff --git a/include/http_connection.h b/include/http_connection.h index f73670b442d..571bf57d2a6 100644 --- a/include/http_connection.h +++ b/include/http_connection.h @@ -47,9 +47,18 @@ extern "C" { */ AP_CORE_DECLARE(void) ap_process_connection(conn_rec *c, void *csd); +/** + * Shutdown the connection for writing. + * @param c The connection to shutdown + * @param flush Whether or not to flush pending data before + * @return APR_SUCCESS or the underlying error + */ +AP_CORE_DECLARE(apr_status_t) ap_shutdown_conn(conn_rec *c, int flush); + /** * Flushes all remain data in the client send buffer * @param c The connection to flush + * @remark calls ap_shutdown_conn(c, 1) */ AP_CORE_DECLARE(void) ap_flush_conn(conn_rec *c); diff --git a/server/connection.c b/server/connection.c index 44544c7d8d5..4f862e4ece6 100644 --- a/server/connection.c +++ b/server/connection.c @@ -64,22 +64,32 @@ AP_IMPLEMENT_HOOK_RUN_ALL(int,pre_connection,(conn_rec *c, void *csd),(c, csd),O #define MAX_SECS_TO_LINGER 30 #endif -AP_CORE_DECLARE(void) ap_flush_conn(conn_rec *c) +AP_CORE_DECLARE(apr_status_t) ap_shutdown_conn(conn_rec *c, int flush) { + apr_status_t rv; apr_bucket_brigade *bb; apr_bucket *b; bb = apr_brigade_create(c->pool, c->bucket_alloc); - /* FLUSH bucket */ - b = apr_bucket_flush_create(c->bucket_alloc); - APR_BRIGADE_INSERT_TAIL(bb, b); + if (flush) { + /* FLUSH bucket */ + b = apr_bucket_flush_create(c->bucket_alloc); + APR_BRIGADE_INSERT_TAIL(bb, b); + } /* End Of Connection bucket */ b = ap_bucket_eoc_create(c->bucket_alloc); APR_BRIGADE_INSERT_TAIL(bb, b); - ap_pass_brigade(c->output_filters, bb); + rv = ap_pass_brigade(c->output_filters, bb); + apr_brigade_destroy(bb); + return rv; +} + +AP_CORE_DECLARE(void) ap_flush_conn(conn_rec *c) +{ + (void)ap_shutdown_conn(c, 1); } /* we now proceed to read from the client until we get EOF, or until diff --git a/server/mpm/event/event.c b/server/mpm/event/event.c index c937b319f88..2f5229aaa24 100644 --- a/server/mpm/event/event.c +++ b/server/mpm/event/event.c @@ -895,6 +895,7 @@ static int start_lingering_close_nonblocking(event_conn_state_t *cs) apr_socket_t *csd = cs->pfd.desc.s; if (c->aborted + || ap_shutdown_conn(c, 0) != APR_SUCCESS || c->aborted || apr_socket_shutdown(csd, APR_SHUTDOWN_WRITE) != APR_SUCCESS) { apr_socket_close(csd); apr_pool_clear(cs->p); diff --git a/server/mpm/eventopt/eventopt.c b/server/mpm/eventopt/eventopt.c index 4d3794a927e..a42eb62aa1c 100644 --- a/server/mpm/eventopt/eventopt.c +++ b/server/mpm/eventopt/eventopt.c @@ -930,6 +930,7 @@ static int start_lingering_close_nonblocking(event_conn_state_t *cs, ap_equeue_t apr_socket_t *csd = cs->pfd.desc.s; if (c->aborted + || ap_shutdown_conn(c, 0) != APR_SUCCESS || c->aborted || apr_socket_shutdown(csd, APR_SHUTDOWN_WRITE) != APR_SUCCESS) { apr_socket_close(csd); apr_pool_clear(cs->p);