]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
Merge r693120, r720250 from trunk:
authorJim Jagielski <jim@apache.org>
Wed, 26 Nov 2008 23:24:20 +0000 (23:24 +0000)
committerJim Jagielski <jim@apache.org>
Wed, 26 Nov 2008 23:24:20 +0000 (23:24 +0000)
Add in useful feature. %k which logs the keepalives
value.
PR: 45762
        Dan Poirier <poirier@pobox.com>

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

CHANGES
STATUS
docs/manual/mod/mod_log_config.xml
modules/http/http_protocol.c
modules/loggers/mod_log_config.c

diff --git a/CHANGES b/CHANGES
index 2c744f9d92e863d4ea65560946a0a3cd024d6fac..bd80c1e8c639a3be28810bd333071811f7feaf2a 100644 (file)
--- 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 <poirier pobox.com>, 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 f2bb5b548d9db9383e513aafd1470402642077a2..417082eb3bee4b81c7d56fe91e409e4082fc3958 100644 (file)
--- 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
index e997c40de9c1895ff0ff0d25dbe4392d8e1e6b16..40b9d8f4b833beb4a2e4ac6c92e74563f3d17e9e 100644 (file)
         modules (e.g. <module>mod_headers</module>) affect this.
         </td></tr>
 
+    <tr><td><code>%k</code></td>
+        <td>Number of keepalive requests handled on this connection.  Interesting if
+          <directive module="core">KeepAlive</directive> is being used;
+          otherwise this is always 0.</td></tr>
+
     <tr><td><code>%l</code></td>
         <td>Remote logname (from identd, if supplied). This will return a
         dash unless <module>mod_ident</module> is present and <directive
index 87f3f3079a805b521ad71698e900292cdd9f6148..10e6514b6176ce792d388fd9b947a6c7f0746410 100644 (file)
@@ -162,6 +162,7 @@ AP_IMPLEMENT_HOOK_VOID(insert_error_filter, (request_rec *r), (r))
 AP_DECLARE(int) ap_set_keepalive(request_rec *r)
 {
     int ka_sent = 0;
+    int left = r->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;
index cd468be14101f2d9cd20ec80a9738db003ffc38e..60485dd3cd0b8a6409cd59d7af2782fcd1104fdc 100644 (file)
@@ -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);