From: Jim Jagielski Date: Wed, 26 Nov 2008 23:24:20 +0000 (+0000) Subject: Merge r693120, r720250 from trunk: X-Git-Tag: 2.2.11~42 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=60ba8573a64d2256d84ea11fa49d2495931e883d;p=thirdparty%2Fapache%2Fhttpd.git Merge r693120, r720250 from trunk: Add in useful feature. %k which logs the keepalives value. PR: 45762 Dan Poirier Make %k work as it should. No regression noted in perl test framework. Reviewed by: jim git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.2.x@721033 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/CHANGES b/CHANGES index 2c744f9d92e..bd80c1e8c63 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,10 @@ -*- coding: utf-8 -*- Changes with Apache 2.2.11 + *) Add new LogFormat parameter, %k, which logs the number of + keepalive requests on this connection for this request. + PR 45762 [Dan Poirier , Jim Jagielski] + *) Export and install the mod_rewrite.h header to ensure the optional rewrite_mapfunc_t and ap_register_rewrite_mapfunc functions are available to third party modules. [Graham Leggett] diff --git a/STATUS b/STATUS index f2bb5b548d9..417082eb3be 100644 --- a/STATUS +++ b/STATUS @@ -85,14 +85,6 @@ RELEASE SHOWSTOPPERS: PATCHES ACCEPTED TO BACKPORT FROM TRUNK: [ start all new proposals below, under PATCHES PROPOSED. ] - * mod_log_config: Add in useful feature, %k which logs the keepalives - value. PR: 45762 - Trunk version of patch: - http://svn.apache.org/viewvc?view=rev&revision=693120 - http://svn.apache.org/viewvc?view=rev&revision=720250 - Backport version for 2.2.x of patch: - Trunk version of patch works (minus CHANGES conflict) - +1: jim, rpluem, pgolluci * srclib/pcre and vendor/pcre http://www.vuxml.org/freebsd/pkg-pcre.html diff --git a/docs/manual/mod/mod_log_config.xml b/docs/manual/mod/mod_log_config.xml index e997c40de9c..40b9d8f4b83 100644 --- a/docs/manual/mod/mod_log_config.xml +++ b/docs/manual/mod/mod_log_config.xml @@ -109,6 +109,11 @@ modules (e.g. mod_headers) affect this. + %k + Number of keepalive requests handled on this connection. Interesting if + KeepAlive is being used; + otherwise this is always 0. + %l Remote logname (from identd, if supplied). This will return a dash unless mod_ident is present and server->keep_alive_max - r->connection->keepalives; int wimpy = ap_find_token(r->pool, apr_table_get(r->headers_out, "Connection"), "close"); @@ -207,7 +208,7 @@ AP_DECLARE(int) ap_set_keepalive(request_rec *r) && r->server->keep_alive && (r->server->keep_alive_timeout > 0) && ((r->server->keep_alive_max == 0) - || (r->server->keep_alive_max > r->connection->keepalives)) + || (left > 0)) && !ap_status_drops_connection(r->status) && !wimpy && !ap_find_token(r->pool, conn, "close") @@ -216,7 +217,6 @@ AP_DECLARE(int) ap_set_keepalive(request_rec *r) && ((ka_sent = ap_find_token(r->pool, conn, "keep-alive")) || (r->proto_num >= HTTP_VERSION(1,1))) && !ap_graceful_stop_signalled()) { - int left = r->server->keep_alive_max - r->connection->keepalives; r->connection->keepalive = AP_CONN_KEEPALIVE; r->connection->keepalives++; @@ -252,6 +252,16 @@ AP_DECLARE(int) ap_set_keepalive(request_rec *r) apr_table_mergen(r->headers_out, "Connection", "close"); } + /* + * If we had previously been a keepalive connection and this + * is the last one, then bump up the number of keepalives + * we've had + */ + if ((r->connection->keepalive != AP_CONN_CLOSE) + && r->server->keep_alive_max + && !left) { + r->connection->keepalives++; + } r->connection->keepalive = AP_CONN_CLOSE; return 0; diff --git a/modules/loggers/mod_log_config.c b/modules/loggers/mod_log_config.c index cd468be1410..60485dd3cd0 100644 --- a/modules/loggers/mod_log_config.c +++ b/modules/loggers/mod_log_config.c @@ -87,6 +87,7 @@ * %...A: local IP-address * %...{Foobar}i: The contents of Foobar: header line(s) in the request * sent to the client. + * %...k: number of keepalive requests served over this connection * %...l: remote logname (from identd, if supplied) * %...{Foobar}n: The contents of note "Foobar" from another module. * %...{Foobar}o: The contents of Foobar: header line(s) in the reply. @@ -699,6 +700,12 @@ static const char *log_connection_status(request_rec *r, char *a) return "-"; } +static const char *log_requests_on_connection(request_rec *r, char *a) +{ + int num = r->connection->keepalives ? r->connection->keepalives - 1 : 0; + return apr_itoa(r->pool, num); +} + /***************************************************************** * * Parsing the log format string @@ -1503,6 +1510,7 @@ static int log_pre_config(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp) log_pfn_register(p, "q", log_request_query, 0); log_pfn_register(p, "X", log_connection_status, 0); log_pfn_register(p, "C", log_cookie, 0); + log_pfn_register(p, "k", log_requests_on_connection, 0); log_pfn_register(p, "r", log_request_line, 1); log_pfn_register(p, "D", log_request_duration_microseconds, 1); log_pfn_register(p, "T", log_request_duration, 1);