Author: kotkov
Date: Tue Feb 17 19:51:23 2015
New Revision: 1660480

URL: http://svn.apache.org/r1660480
Log:
Improve the way we currently log assertions and malfunctions in mod_dav_svn.

Prior to this changeset we were delegating this to the default malfunction
handler, svn_error_abort_on_malfunction().  If a malfunction happens, this
handler outputs the information about it to STDERR.  Apache usually replaces
STDERR with what the ErrorLog directive points to, but there are a couple
of caveats:

- First of all, doing so bypasses existing error log hooks installed via
  ap_hook_error_log().  There might be existing installations that happen to
  use custom error log hooks as an addition to the main error log or even as
  a complete replacement for it — think ErrorLog /dev/null, but with a custom
  logging module doing all the work.  In the latter case, the information
  about the malfunction would be completely lost.

- Secondly, the error message contains an unnecessary "svn:" prefix, and this
  is inconsistent with other Subversion errors that can appear in the Apache
  error log.

Avoid them by installing a custom malfunction handler.  Related discussion
can be found in http://svn.haxx.se/dev/archive-2015-02/0268.shtml
(Subject: "Handling assertions and malfunctions in mod_dav_svn")

* subversion/mod_dav_svn/mod_dav_svn.c
  (malfunction_handler): New function that logs the malfunction details with
   ap_log_error() and aborts the current process.
  (init_dso): Install new malfunction_handler in this APR_HOOK_REALLY_FIRST
   pre_config hook.

Modified:
    subversion/trunk/subversion/mod_dav_svn/mod_dav_svn.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=1660480&r1=1660479&r2=1660480&view=diff
==============================================================================
--- subversion/trunk/subversion/mod_dav_svn/mod_dav_svn.c (original)
+++ subversion/trunk/subversion/mod_dav_svn/mod_dav_svn.c Tue Feb 17 19:51:23 
2015
@@ -143,6 +143,25 @@ init(apr_pool_t *p, apr_pool_t *plog, ap
   return OK;
 }
 
+static svn_error_t *
+malfunction_handler(svn_boolean_t can_return,
+                    const char *file, int line,
+                    const char *expr)
+{
+  if (expr)
+    ap_log_error(APLOG_MARK, APLOG_CRIT, 0, NULL,
+                 "mod_dav_svn: file '%s', line %d, assertion \"%s\" failed",
+                 file, line, expr);
+  else
+    ap_log_error(APLOG_MARK, APLOG_CRIT, 0, NULL,
+                 "mod_dav_svn: file '%s', line %d, internal malfunction",
+                 file, line);
+  abort();
+
+  /* Should not be reached. */
+  return SVN_NO_ERROR;
+}
+
 static int
 init_dso(apr_pool_t *pconf, apr_pool_t *plog, apr_pool_t *ptemp)
 {
@@ -162,6 +181,8 @@ init_dso(apr_pool_t *pconf, apr_pool_t *
       return HTTP_INTERNAL_SERVER_ERROR;
     }
 
+  svn_error_set_malfunction_handler(malfunction_handler);
+
   return OK;
 }
 


Reply via email to