You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by ph...@apache.org on 2014/05/16 13:27:52 UTC
svn commit: r1595160 - in /subversion/trunk: build/ac-macros/apache.m4
subversion/mod_dav_svn/dav_svn.h subversion/mod_dav_svn/mod_dav_svn.c
subversion/mod_dav_svn/status.c
Author: philip
Date: Fri May 16 11:27:52 2014
New Revision: 1595160
URL: http://svn.apache.org/r1595160
Log:
Add a mod_dav_svn handler to allow the server admin to GET the FSFS
global cache statistics.
* subversion/mod_dav_svn/dav_svn.h
(dav_svn__status): New.
* subversion/mod_dav_svn/mod_dav_svn.c
(register_hooks): Register new hook.
* subversion/mod_dav_svn/status.c: New file.
* build/ac-macros/apache.m4: Check for unistd.h and getpid().
Added:
subversion/trunk/subversion/mod_dav_svn/status.c
Modified:
subversion/trunk/build/ac-macros/apache.m4
subversion/trunk/subversion/mod_dav_svn/dav_svn.h
subversion/trunk/subversion/mod_dav_svn/mod_dav_svn.c
Modified: subversion/trunk/build/ac-macros/apache.m4
URL: http://svn.apache.org/viewvc/subversion/trunk/build/ac-macros/apache.m4?rev=1595160&r1=1595159&r2=1595160&view=diff
==============================================================================
--- subversion/trunk/build/ac-macros/apache.m4 (original)
+++ subversion/trunk/build/ac-macros/apache.m4 Fri May 16 11:27:52 2014
@@ -157,6 +157,8 @@ if test -n "$APXS" && test "$APXS" != "n
APACHE_LIBEXECDIR="`$APXS -q libexecdir`"
fi
+ AC_CHECK_HEADERS(unistd.h, [AC_CHECK_FUNCS(getpid)], [])
+
BUILD_APACHE_RULE=apache-mod
INSTALL_APACHE_RULE=install-mods-shared
INSTALL_APACHE_MODS=true
Modified: subversion/trunk/subversion/mod_dav_svn/dav_svn.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/mod_dav_svn/dav_svn.h?rev=1595160&r1=1595159&r2=1595160&view=diff
==============================================================================
--- subversion/trunk/subversion/mod_dav_svn/dav_svn.h (original)
+++ subversion/trunk/subversion/mod_dav_svn/dav_svn.h Fri May 16 11:27:52 2014
@@ -482,6 +482,8 @@ dav_svn__store_activity(const dav_svn_re
/* POST request handler. (Used by HTTP protocol v2 clients only.) */
int dav_svn__method_post(request_rec *r);
+/* Request handler to GET Subversion internal status (FSFS cache). */
+int dav_svn__status(request_rec *r);
/*** repos.c ***/
Modified: subversion/trunk/subversion/mod_dav_svn/mod_dav_svn.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/mod_dav_svn/mod_dav_svn.c?rev=1595160&r1=1595159&r2=1595160&view=diff
==============================================================================
--- subversion/trunk/subversion/mod_dav_svn/mod_dav_svn.c (original)
+++ subversion/trunk/subversion/mod_dav_svn/mod_dav_svn.c Fri May 16 11:27:52 2014
@@ -1349,6 +1349,9 @@ register_hooks(apr_pool_t *pconf)
/* general request handler for methods which mod_dav DECLINEs. */
ap_hook_handler(dav_svn__handler, NULL, NULL, APR_HOOK_LAST);
+ /* Handler to GET Subversion's FSFS cache stats, a bit like mod_status. */
+ ap_hook_handler(dav_svn__status, NULL, NULL, APR_HOOK_MIDDLE);
+
/* live property handling */
dav_hook_gather_propsets(dav_svn__gather_propsets, NULL, NULL,
APR_HOOK_MIDDLE);
Added: subversion/trunk/subversion/mod_dav_svn/status.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/mod_dav_svn/status.c?rev=1595160&view=auto
==============================================================================
--- subversion/trunk/subversion/mod_dav_svn/status.c (added)
+++ subversion/trunk/subversion/mod_dav_svn/status.c Fri May 16 11:27:52 2014
@@ -0,0 +1,94 @@
+/*
+ * ====================================================================
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * ====================================================================
+ */
+
+#include <httpd.h>
+#include <http_core.h>
+#include <http_config.h>
+#include <http_request.h>
+#include <http_protocol.h>
+
+#include "dav_svn.h"
+#include "private/svn_cache.h"
+#include "private/svn_fs_private.h"
+
+#ifndef DEFAULT_TIME_FORMAT
+#define DEFAULT_TIME_FORMAT "%F %H:%M:%S %z"
+#endif
+
+/* A bit like mod_status: add a location:
+
+ <Location /svn-status>
+ SetHandler svn-status
+ </Location>
+
+ and then point a browser at http://server/svn-status.
+*/
+int dav_svn__status(request_rec *r)
+{
+ svn_cache__info_t *info;
+ svn_string_t *text_stats;
+ apr_array_header_t *lines;
+ int i;
+
+ if (r->method_number != M_GET || strcmp(r->handler, "svn-status"))
+ return DECLINED;
+
+ info = svn_cache__membuffer_get_global_info(r->pool);
+ text_stats = svn_cache__format_info(info, FALSE, r->pool);
+ lines = svn_cstring_split(text_stats->data, "\n", FALSE, r->pool);
+
+ ap_set_content_type(r, "text/html; charset=ISO-8859-1");
+
+ ap_rvputs(r,
+ DOCTYPE_HTML_3_2
+ "<html><head>\n"
+ "<title>Apache SVN Status</title>\n"
+ "</head><body>\n"
+ "<h1>Apache SVN Cache Status for ",
+ ap_escape_html(r->pool, ap_get_server_name(r)),
+ " (via ",
+ r->connection->local_ip,
+ ")</h1>\n<dl>\n<dt>Server Version: ",
+ ap_get_server_description(),
+ "</dt>\n<dt>Current Time: ",
+ ap_ht_time(r->pool, apr_time_now(), DEFAULT_TIME_FORMAT, 0),
+ "</dt>\n", SVN_VA_NULL);
+
+#if !defined(WIN32) && defined(HAVE_UNISTD_H) && defined(HAVE_GETPID)
+ /* On Unix the server is generally multiple processes and this
+ request only shows the status of the single process that handles
+ the request. Ideally we would iterate over all processes but that
+ would need some MPM support, so we settle for simply showing the
+ process ID. */
+#include <unistd.h>
+ ap_rprintf(r, "<dt>Server process id: %d</dt>\n", (int)getpid());
+#endif
+
+ for (i = 0; i < lines->nelts; ++i)
+ {
+ const char *line = APR_ARRAY_IDX(lines, i, const char *);
+ ap_rvputs(r, "<dt>", line, "</dt>\n", SVN_VA_NULL);
+ }
+
+ ap_rvputs(r, "</dl></body></html>\n", SVN_VA_NULL);
+
+ return 0;
+}