Author: svn-role
Date: Sun Mar  4 04:00:06 2018
New Revision: 1825795

URL: http://svn.apache.org/viewvc?rev=1825795&view=rev
Log:
Merge the r1825736 group from trunk:

 * r1825736, r1825778
   Fix a memory usage problem in mod_authz_svn.
   Justifiation:
     Server uses too much memory if authz is enabled.
     See https://svn.haxx.se/dev/archive-2018-03/0010.shtml
   Votes:
     +1: philip, stsp, brane

Modified:
    subversion/branches/1.10.x/   (props changed)
    subversion/branches/1.10.x/STATUS
    subversion/branches/1.10.x/subversion/mod_authz_svn/mod_authz_svn.c

Propchange: subversion/branches/1.10.x/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun Mar  4 04:00:06 2018
@@ -100,4 +100,4 @@
 /subversion/branches/verify-at-commit:1462039-1462408
 /subversion/branches/verify-keep-going:1439280-1546110
 /subversion/branches/wc-collate-path:1402685-1480384
-/subversion/trunk:1817837,1817856,1818577-1818578,1818584,1818651,1818662,1818727,1818801,1818803,1818807,1818868,1818871,1819036-1819037,1819043,1819049,1819052,1819093,1819146,1819162,1819444,1819556-1819557,1819603,1819804,1819911,1820044,1820046-1820047,1820518,1820627,1820718,1820778,1821183,1821224,1821621,1821678,1822401,1822587,1822591,1822996,1823202-1823203,1823211,1823327,1823791,1823966,1823989,1824033,1825024,1825045,1825215,1825266
+/subversion/trunk:1817837,1817856,1818577-1818578,1818584,1818651,1818662,1818727,1818801,1818803,1818807,1818868,1818871,1819036-1819037,1819043,1819049,1819052,1819093,1819146,1819162,1819444,1819556-1819557,1819603,1819804,1819911,1820044,1820046-1820047,1820518,1820627,1820718,1820778,1821183,1821224,1821621,1821678,1822401,1822587,1822591,1822996,1823202-1823203,1823211,1823327,1823791,1823966,1823989,1824033,1825024,1825045,1825215,1825266,1825736,1825778

Modified: subversion/branches/1.10.x/STATUS
URL: 
http://svn.apache.org/viewvc/subversion/branches/1.10.x/STATUS?rev=1825795&r1=1825794&r2=1825795&view=diff
==============================================================================
--- subversion/branches/1.10.x/STATUS (original)
+++ subversion/branches/1.10.x/STATUS Sun Mar  4 04:00:06 2018
@@ -51,11 +51,3 @@ Veto-blocked changes:
 
 Approved changes:
 =================
-
- * r1825736, r1825778
-   Fix a memory usage problem in mod_authz_svn.
-   Justifiation:
-     Server uses too much memory if authz is enabled.
-     See https://svn.haxx.se/dev/archive-2018-03/0010.shtml
-   Votes:
-     +1: philip, stsp, brane

Modified: subversion/branches/1.10.x/subversion/mod_authz_svn/mod_authz_svn.c
URL: 
http://svn.apache.org/viewvc/subversion/branches/1.10.x/subversion/mod_authz_svn/mod_authz_svn.c?rev=1825795&r1=1825794&r2=1825795&view=diff
==============================================================================
--- subversion/branches/1.10.x/subversion/mod_authz_svn/mod_authz_svn.c 
(original)
+++ subversion/branches/1.10.x/subversion/mod_authz_svn/mod_authz_svn.c Sun Mar 
 4 04:00:06 2018
@@ -401,10 +401,12 @@ static svn_authz_t *
 get_access_conf(request_rec *r, authz_svn_config_rec *conf,
                 apr_pool_t *scratch_pool)
 {
+  const char *cache_key = NULL;
   const char *access_file;
   const char *groups_file;
   const char *repos_path;
   const char *repos_url = NULL;
+  void *user_data = NULL;
   svn_authz_t *access_conf = NULL;
   svn_error_t *svn_err = SVN_NO_ERROR;
   dav_error *dav_err;
@@ -464,19 +466,31 @@ get_access_conf(request_rec *r, authz_sv
                     "Path to groups file is %s", groups_file);
     }
 
-  svn_err = svn_repos_authz_read3(&access_conf,
-                                  access_file, groups_file,
-                                  TRUE, NULL,
-                                  r->connection->pool, scratch_pool);
+  cache_key = apr_pstrcat(scratch_pool, "mod_authz_svn:",
+                          access_file, groups_file, SVN_VA_NULL);
+  apr_pool_userdata_get(&user_data, cache_key, r->connection->pool);
+  access_conf = user_data;
+  if (access_conf == NULL)
+    {
+      svn_err = svn_repos_authz_read3(&access_conf, access_file,
+                                      groups_file, TRUE, NULL,
+                                      r->connection->pool,
+                                      scratch_pool);
 
-  if (svn_err)
-    {
-      log_svn_error(APLOG_MARK, r,
-                    "Failed to load the mod_authz_svn config:",
-                    svn_err, scratch_pool);
-      access_conf = NULL;
+      if (svn_err)
+        {
+          log_svn_error(APLOG_MARK, r,
+                        "Failed to load the mod_authz_svn config:",
+                        svn_err, scratch_pool);
+          access_conf = NULL;
+        }
+      else
+        {
+          /* Cache the open repos for the next request on this connection */
+          apr_pool_userdata_set(access_conf, cache_key,
+                                NULL, r->connection->pool);
+        }
     }
-
   return access_conf;
 }
 


Reply via email to