Author: philip Date: Sat Mar 3 16:58:13 2018 New Revision: 1825778 URL: http://svn.apache.org/viewvc?rev=1825778&view=rev Log: Revert r1825736, r1779188 and r1778923. This reverts to caching the authz file for the duration of the connection in mod_authz_svn. This was due to performance issues:
https://mail-archives.apache.org/mod_mbox/subversion-dev/201803.mbox/%3CCAP_GPNii50yPBMNogDYgrgk9%3DpUs802YAjM3to2g5s7R21GX5g%40mail.gmail.com%3E * subversion/mod_authz_svn/mod_authz_svn.c (get_access_conf, req_check_access, subreq_bypass2): Revert. Modified: subversion/trunk/subversion/mod_authz_svn/mod_authz_svn.c Modified: subversion/trunk/subversion/mod_authz_svn/mod_authz_svn.c URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/mod_authz_svn/mod_authz_svn.c?rev=1825778&r1=1825777&r2=1825778&view=diff ============================================================================== --- subversion/trunk/subversion/mod_authz_svn/mod_authz_svn.c (original) +++ subversion/trunk/subversion/mod_authz_svn/mod_authz_svn.c Sat Mar 3 16:58:13 2018 @@ -395,17 +395,18 @@ resolve_repos_relative_url(const char ** } /* - * Get the svn_authz_t for this request. + * Get the, possibly cached, svn_authz_t for this request. */ static svn_authz_t * get_access_conf(request_rec *r, authz_svn_config_rec *conf, - apr_pool_t *result_pool, 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; @@ -465,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, - result_pool, scratch_pool); - - if (svn_err) + 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) { - log_svn_error(APLOG_MARK, r, - "Failed to load the mod_authz_svn config:", - svn_err, scratch_pool); - 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; + } + 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; } @@ -688,7 +701,7 @@ req_check_access(request_rec *r, } /* Retrieve/cache authorization file */ - access_conf = get_access_conf(r,conf, r->pool, r->pool); + access_conf = get_access_conf(r,conf, r->pool); if (access_conf == NULL) return DECLINED; @@ -805,7 +818,7 @@ subreq_bypass2(request_rec *r, } /* Retrieve authorization file */ - access_conf = get_access_conf(r, conf, scratch_pool, scratch_pool); + access_conf = get_access_conf(r, conf, scratch_pool); if (access_conf == NULL) return HTTP_FORBIDDEN;