httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s.@apache.org
Subject svn commit: r823337 - in /httpd/httpd/trunk: CHANGES include/ap_mmn.h include/http_core.h modules/loggers/mod_logio.c server/scoreboard.c
Date Thu, 08 Oct 2009 21:42:13 GMT
Author: sf
Date: Thu Oct  8 21:42:13 2009
New Revision: 823337

URL: http://svn.apache.org/viewvc?rev=823337&view=rev
Log:
mod_logio: introduce new optional function ap_logio_get_last_bytes to get
total byte count of last request.

core: Use ap_logio_get_last_bytes to report more accurate byte counts in
mod_status if mod_logio is loaded. Without mod_logio, don't increment
counts for HEAD requests.

PR: 25656

Modified:
    httpd/httpd/trunk/CHANGES
    httpd/httpd/trunk/include/ap_mmn.h
    httpd/httpd/trunk/include/http_core.h
    httpd/httpd/trunk/modules/loggers/mod_logio.c
    httpd/httpd/trunk/server/scoreboard.c

Modified: httpd/httpd/trunk/CHANGES
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/CHANGES?rev=823337&r1=823336&r2=823337&view=diff
==============================================================================
--- httpd/httpd/trunk/CHANGES [utf-8] (original)
+++ httpd/httpd/trunk/CHANGES [utf-8] Thu Oct  8 21:42:13 2009
@@ -10,6 +10,9 @@
      mod_proxy_ftp: NULL pointer dereference on error paths.
      [Stefan Fritsch <sf fritsch.de>, Joe Orton]
 
+  *) mod_logio/core: Report more accurate byte counts in mod_status if
+     mod_logio is loaded. PR 25656. [Stefan Fritsch]
+
   *) mod_ldap: If LDAPSharedCacheSize is too small, try harder to purge
      some cache entries and log a warning. Also increase the default
      LDAPSharedCacheSize to 500000. This is a more realistic size suitable

Modified: httpd/httpd/trunk/include/ap_mmn.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/include/ap_mmn.h?rev=823337&r1=823336&r2=823337&view=diff
==============================================================================
--- httpd/httpd/trunk/include/ap_mmn.h (original)
+++ httpd/httpd/trunk/include/ap_mmn.h Thu Oct  8 21:42:13 2009
@@ -198,15 +198,17 @@
  * 20090401.3 (2.3.3-dev)  Added DAV options provider to mod_dav.h
  * 20090925.0 (2.3.3-dev)  Added server_rec::context and added *server_rec
  *                         param to ap_wait_or_timeout()
+ * 20090925.1 (2.3.3-dev)  Add optional function ap_logio_get_last_bytes() to
+ *                         mod_logio
  *
  */
 
 #define MODULE_MAGIC_COOKIE 0x41503234UL /* "AP24" */
 
 #ifndef MODULE_MAGIC_NUMBER_MAJOR
-#define MODULE_MAGIC_NUMBER_MAJOR 20090401
+#define MODULE_MAGIC_NUMBER_MAJOR 20090925
 #endif
-#define MODULE_MAGIC_NUMBER_MINOR 2                     /* 0...n */
+#define MODULE_MAGIC_NUMBER_MINOR 1                     /* 0...n */
 
 /**
  * Determine if the server's current MODULE_MAGIC_NUMBER is at least a

Modified: httpd/httpd/trunk/include/http_core.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/include/http_core.h?rev=823337&r1=823336&r2=823337&view=diff
==============================================================================
--- httpd/httpd/trunk/include/http_core.h (original)
+++ httpd/httpd/trunk/include/http_core.h Thu Oct  8 21:42:13 2009
@@ -646,6 +646,8 @@
 APR_DECLARE_OPTIONAL_FN(void, ap_logio_add_bytes_in,
                         (conn_rec *c, apr_off_t bytes));
 
+APR_DECLARE_OPTIONAL_FN(apr_off_t, ap_logio_get_last_bytes, (conn_rec *c));
+
 /* ----------------------------------------------------------------------
  *
  * ident lookups with mod_ident

Modified: httpd/httpd/trunk/modules/loggers/mod_logio.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/loggers/mod_logio.c?rev=823337&r1=823336&r2=823337&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/loggers/mod_logio.c (original)
+++ httpd/httpd/trunk/modules/loggers/mod_logio.c Thu Oct  8 21:42:13 2009
@@ -53,6 +53,7 @@
 typedef struct logio_config_t {
     apr_off_t bytes_in;
     apr_off_t bytes_out;
+    apr_off_t bytes_last_request;
 } logio_config_t;
 
 /*
@@ -76,6 +77,18 @@
 }
 
 /*
+ * Optional function to get total byte count of last request for
+ * ap_increment_counts.
+ */
+
+static apr_off_t ap_logio_get_last_bytes(conn_rec *c)
+{
+    logio_config_t *cf = ap_get_module_config(c->conn_config, &logio_module);
+
+    return cf->bytes_last_request;
+}
+
+/*
  * Format items...
  */
 
@@ -104,6 +117,8 @@
     logio_config_t *cf = ap_get_module_config(r->connection->conn_config,
                                               &logio_module);
 
+    /* need to save byte count of last request for ap_increment_counts */
+    cf->bytes_last_request = cf->bytes_in + cf->bytes_out;
     cf->bytes_in = cf->bytes_out = 0;
 
     return OK;
@@ -173,6 +188,7 @@
 
     APR_REGISTER_OPTIONAL_FN(ap_logio_add_bytes_out);
     APR_REGISTER_OPTIONAL_FN(ap_logio_add_bytes_in);
+    APR_REGISTER_OPTIONAL_FN(ap_logio_get_last_bytes);
 }
 
 module AP_MODULE_DECLARE_DATA logio_module =

Modified: httpd/httpd/trunk/server/scoreboard.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/scoreboard.c?rev=823337&r1=823336&r2=823337&view=diff
==============================================================================
--- httpd/httpd/trunk/server/scoreboard.c (original)
+++ httpd/httpd/trunk/server/scoreboard.c Thu Oct  8 21:42:13 2009
@@ -64,6 +64,8 @@
                                 *pfn_proxy_lb_workers;
 static APR_OPTIONAL_FN_TYPE(ap_proxy_lb_worker_size)
                                 *pfn_proxy_lb_worker_size;
+static APR_OPTIONAL_FN_TYPE(ap_logio_get_last_bytes)
+                                *pfn_ap_logio_get_last_bytes;
 
 struct ap_sb_handle_t {
     int child_num;
@@ -116,6 +118,8 @@
     if (lb_limit && lb_size)
         scoreboard_size += lb_size * lb_limit;
 
+    pfn_ap_logio_get_last_bytes = APR_RETRIEVE_OPTIONAL_FN(ap_logio_get_last_bytes);
+
     return scoreboard_size;
 }
 
@@ -350,11 +354,21 @@
 AP_DECLARE(void) ap_increment_counts(ap_sb_handle_t *sb, request_rec *r)
 {
     worker_score *ws;
+    apr_off_t bytes;
 
     if (!sb)
         return;
 
     ws = &ap_scoreboard_image->servers[sb->child_num][sb->thread_num];
+    if (pfn_ap_logio_get_last_bytes != NULL) {
+        bytes = pfn_ap_logio_get_last_bytes(r->connection);
+    }
+    else if (r->method_number == M_GET && r->method[0] == 'H') {
+        bytes = 0;
+    }
+    else {
+        bytes = r->bytes_sent;
+    }
 
 #ifdef HAVE_TIMES
     times(&ws->times);
@@ -362,9 +376,9 @@
     ws->access_count++;
     ws->my_access_count++;
     ws->conn_count++;
-    ws->bytes_served += r->bytes_sent;
-    ws->my_bytes_served += r->bytes_sent;
-    ws->conn_bytes += r->bytes_sent;
+    ws->bytes_served += bytes;
+    ws->my_bytes_served += bytes;
+    ws->conn_bytes += bytes;
 }
 
 AP_DECLARE(int) ap_find_child_by_pid(apr_proc_t *pid)



Mime
View raw message