r***@apache.org
2014-10-05 17:00:31 UTC
Author: rjung
Date: Sun Oct 5 17:00:31 2014
New Revision: 1629507
URL: http://svn.apache.org/r1629507
Log:
mod_cache_socache: Add cache status to server-status.
The status_hook simply calls the status function of
socache, very much like mod_ssl does for the ssl
session cache.
Modified:
httpd/httpd/trunk/CHANGES
httpd/httpd/trunk/docs/log-message-tags/next-number
httpd/httpd/trunk/modules/cache/mod_cache_socache.c
Modified: httpd/httpd/trunk/CHANGES
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/CHANGES?rev=1629507&r1=1629506&r2=1629507&view=diff
==============================================================================
--- httpd/httpd/trunk/CHANGES [utf-8] (original)
+++ httpd/httpd/trunk/CHANGES [utf-8] Sun Oct 5 17:00:31 2014
@@ -1,6 +1,8 @@
-*- coding: utf-8 -*-
Changes with Apache 2.5.0
+ *) mod_cache_socache: Add cache status to server-status. [Rainer Jung]
+
*) mod_ssl: Move OCSP stapling information from a per-certificate store to
a per-server hash. PR 54357, PR 56919. [Alex Bligh <alex alex.org.uk>,
Kaspar Brand]
Modified: httpd/httpd/trunk/docs/log-message-tags/next-number
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/docs/log-message-tags/next-number?rev=1629507&r1=1629506&r2=1629507&view=diff
==============================================================================
--- httpd/httpd/trunk/docs/log-message-tags/next-number (original)
+++ httpd/httpd/trunk/docs/log-message-tags/next-number Sun Oct 5 17:00:31 2014
@@ -1 +1 @@
-2816
+2818
Modified: httpd/httpd/trunk/modules/cache/mod_cache_socache.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/cache/mod_cache_socache.c?rev=1629507&r1=1629506&r2=1629507&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/cache/mod_cache_socache.c (original)
+++ httpd/httpd/trunk/modules/cache/mod_cache_socache.c Sun Oct 5 17:00:31 2014
@@ -22,6 +22,7 @@
#include "http_config.h"
#include "http_log.h"
#include "http_core.h"
+#include "http_protocol.h"
#include "ap_provider.h"
#include "ap_socache.h"
#include "util_filter.h"
@@ -30,6 +31,7 @@
#include "util_mutex.h"
#include "mod_cache.h"
+#include "mod_status.h"
#include "cache_socache_common.h"
@@ -1375,6 +1377,56 @@ static apr_status_t destroy_cache(void *
return APR_SUCCESS;
}
+static int socache_status_hook(request_rec *r, int flags)
+{
+ apr_status_t status = APR_SUCCESS;
+ cache_socache_conf *conf = ap_get_module_config(r->server->module_config,
+ &cache_socache_module);
+ if (!conf->provider || !conf->provider->socache_provider ||
+ !conf->provider->socache_instance) {
+ return DECLINED;
+ }
+
+ ap_rputs("<hr>\n"
+ "<table cellspacing=0 cellpadding=0>\n"
+ "<tr><td bgcolor=\"#000000\">\n"
+ "<b><font color=\"#ffffff\" face=\"Arial,Helvetica\">"
+ "mod_cache_socache Status:</font></b>\n"
+ "</td></tr>\n"
+ "<tr><td bgcolor=\"#ffffff\">\n", r);
+
+ if (socache_mutex) {
+ status = apr_global_mutex_lock(socache_mutex);
+ if (status != APR_SUCCESS) {
+ ap_log_rerror(APLOG_MARK, APLOG_ERR, status, r, APLOGNO(02816)
+ "could not acquire lock for cache status");
+ }
+ }
+
+ if (status != APR_SUCCESS) {
+ ap_rputs("No cache status data available\n", r);
+ } else {
+ conf->provider->socache_provider->status(conf->provider->socache_instance,
+ r, flags);
+ }
+
+ if (socache_mutex && status == APR_SUCCESS) {
+ status = apr_global_mutex_unlock(socache_mutex);
+ if (status != APR_SUCCESS) {
+ ap_log_rerror(APLOG_MARK, APLOG_ERR, status, r, APLOGNO(02817)
+ "could not release lock for cache status");
+ }
+ }
+
+ ap_rputs("</td></tr>\n</table>\n", r);
+ return OK;
+}
+
+void socache_status_register(apr_pool_t *p)
+{
+ APR_OPTIONAL_HOOK(ap, status_hook, socache_status_hook, NULL, NULL, APR_HOOK_MIDDLE);
+}
+
static int socache_precfg(apr_pool_t *pconf, apr_pool_t *plog, apr_pool_t *ptmp)
{
apr_status_t rv = ap_mutex_register(pconf, cache_socache_id, NULL,
@@ -1384,6 +1436,10 @@ static int socache_precfg(apr_pool_t *pc
"failed to register %s mutex", cache_socache_id);
return 500; /* An HTTP status would be a misnomer! */
}
+
+ /* Register to handle mod_status status page generation */
+ socache_status_register(pconf);
+
return OK;
}
Date: Sun Oct 5 17:00:31 2014
New Revision: 1629507
URL: http://svn.apache.org/r1629507
Log:
mod_cache_socache: Add cache status to server-status.
The status_hook simply calls the status function of
socache, very much like mod_ssl does for the ssl
session cache.
Modified:
httpd/httpd/trunk/CHANGES
httpd/httpd/trunk/docs/log-message-tags/next-number
httpd/httpd/trunk/modules/cache/mod_cache_socache.c
Modified: httpd/httpd/trunk/CHANGES
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/CHANGES?rev=1629507&r1=1629506&r2=1629507&view=diff
==============================================================================
--- httpd/httpd/trunk/CHANGES [utf-8] (original)
+++ httpd/httpd/trunk/CHANGES [utf-8] Sun Oct 5 17:00:31 2014
@@ -1,6 +1,8 @@
-*- coding: utf-8 -*-
Changes with Apache 2.5.0
+ *) mod_cache_socache: Add cache status to server-status. [Rainer Jung]
+
*) mod_ssl: Move OCSP stapling information from a per-certificate store to
a per-server hash. PR 54357, PR 56919. [Alex Bligh <alex alex.org.uk>,
Kaspar Brand]
Modified: httpd/httpd/trunk/docs/log-message-tags/next-number
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/docs/log-message-tags/next-number?rev=1629507&r1=1629506&r2=1629507&view=diff
==============================================================================
--- httpd/httpd/trunk/docs/log-message-tags/next-number (original)
+++ httpd/httpd/trunk/docs/log-message-tags/next-number Sun Oct 5 17:00:31 2014
@@ -1 +1 @@
-2816
+2818
Modified: httpd/httpd/trunk/modules/cache/mod_cache_socache.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/cache/mod_cache_socache.c?rev=1629507&r1=1629506&r2=1629507&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/cache/mod_cache_socache.c (original)
+++ httpd/httpd/trunk/modules/cache/mod_cache_socache.c Sun Oct 5 17:00:31 2014
@@ -22,6 +22,7 @@
#include "http_config.h"
#include "http_log.h"
#include "http_core.h"
+#include "http_protocol.h"
#include "ap_provider.h"
#include "ap_socache.h"
#include "util_filter.h"
@@ -30,6 +31,7 @@
#include "util_mutex.h"
#include "mod_cache.h"
+#include "mod_status.h"
#include "cache_socache_common.h"
@@ -1375,6 +1377,56 @@ static apr_status_t destroy_cache(void *
return APR_SUCCESS;
}
+static int socache_status_hook(request_rec *r, int flags)
+{
+ apr_status_t status = APR_SUCCESS;
+ cache_socache_conf *conf = ap_get_module_config(r->server->module_config,
+ &cache_socache_module);
+ if (!conf->provider || !conf->provider->socache_provider ||
+ !conf->provider->socache_instance) {
+ return DECLINED;
+ }
+
+ ap_rputs("<hr>\n"
+ "<table cellspacing=0 cellpadding=0>\n"
+ "<tr><td bgcolor=\"#000000\">\n"
+ "<b><font color=\"#ffffff\" face=\"Arial,Helvetica\">"
+ "mod_cache_socache Status:</font></b>\n"
+ "</td></tr>\n"
+ "<tr><td bgcolor=\"#ffffff\">\n", r);
+
+ if (socache_mutex) {
+ status = apr_global_mutex_lock(socache_mutex);
+ if (status != APR_SUCCESS) {
+ ap_log_rerror(APLOG_MARK, APLOG_ERR, status, r, APLOGNO(02816)
+ "could not acquire lock for cache status");
+ }
+ }
+
+ if (status != APR_SUCCESS) {
+ ap_rputs("No cache status data available\n", r);
+ } else {
+ conf->provider->socache_provider->status(conf->provider->socache_instance,
+ r, flags);
+ }
+
+ if (socache_mutex && status == APR_SUCCESS) {
+ status = apr_global_mutex_unlock(socache_mutex);
+ if (status != APR_SUCCESS) {
+ ap_log_rerror(APLOG_MARK, APLOG_ERR, status, r, APLOGNO(02817)
+ "could not release lock for cache status");
+ }
+ }
+
+ ap_rputs("</td></tr>\n</table>\n", r);
+ return OK;
+}
+
+void socache_status_register(apr_pool_t *p)
+{
+ APR_OPTIONAL_HOOK(ap, status_hook, socache_status_hook, NULL, NULL, APR_HOOK_MIDDLE);
+}
+
static int socache_precfg(apr_pool_t *pconf, apr_pool_t *plog, apr_pool_t *ptmp)
{
apr_status_t rv = ap_mutex_register(pconf, cache_socache_id, NULL,
@@ -1384,6 +1436,10 @@ static int socache_precfg(apr_pool_t *pc
"failed to register %s mutex", cache_socache_id);
return 500; /* An HTTP status would be a misnomer! */
}
+
+ /* Register to handle mod_status status page generation */
+ socache_status_register(pconf);
+
return OK;
}