subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From stef...@apache.org
Subject svn commit: r1769875 - in /subversion/branches/authzperf/subversion: libsvn_repos/authz.c libsvn_repos/authz.h libsvn_repos/authz_info.c libsvn_repos/authz_parse.c tests/libsvn_repos/authz-test.c
Date Tue, 15 Nov 2016 20:09:50 GMT
Author: stefan2
Date: Tue Nov 15 20:09:50 2016
New Revision: 1769875

URL: http://svn.apache.org/viewvc?rev=1769875&view=rev
Log:
On the authzperf branch:
Prepare the parsed authz struct for caching.  To be cacheable and shareable,
we need it to be read-only but the svn_authz_t contains dynamic information
as well.

Therefore, move the parsed authz file (full model) into a new sub-struct
that is truly accessed read-only.

* subversion/libsvn_repos/authz.h
  (authz_full_t): The parser output and actually read-only part, factored
                  out from ...
  (svn_authz_t): ... this.
  (svn_authz__parse): Return
  (svn_authz__get_global_rights):  The operates on the parsed model only.

* subversion/libsvn_repos/authz_parse.c
  (ctor_baton_t,
   create_ctor_baton): Update the data type to use.

* subversion/libsvn_repos/authz_info.c
  (svn_authz__get_global_rights): Same.

* subversion/tests/libsvn_repos/authz-test.c
  (test_authz_parse): Same.

* subversion/libsvn_repos/authz.c
  (get_filtered_tree): Same. Update model access.
  (svn_repos_authz_read2,
   svn_repos_authz_parse): Create the now svn_authz_t wrapper around the
                           parsed model.

Modified:
    subversion/branches/authzperf/subversion/libsvn_repos/authz.c
    subversion/branches/authzperf/subversion/libsvn_repos/authz.h
    subversion/branches/authzperf/subversion/libsvn_repos/authz_info.c
    subversion/branches/authzperf/subversion/libsvn_repos/authz_parse.c
    subversion/branches/authzperf/subversion/tests/libsvn_repos/authz-test.c

Modified: subversion/branches/authzperf/subversion/libsvn_repos/authz.c
URL: http://svn.apache.org/viewvc/subversion/branches/authzperf/subversion/libsvn_repos/authz.c?rev=1769875&r1=1769874&r2=1769875&view=diff
==============================================================================
--- subversion/branches/authzperf/subversion/libsvn_repos/authz.c (original)
+++ subversion/branches/authzperf/subversion/libsvn_repos/authz.c Tue Nov 15 20:09:50 2016
@@ -779,7 +779,7 @@ finalize_tree(node_t *node,
  * Return the filtered rule tree.
  */
 static node_t *
-create_user_authz(svn_authz_t *authz,
+create_user_authz(authz_full_t *authz,
                   const char *repository,
                   const char *user,
                   apr_pool_t *result_pool,
@@ -1467,7 +1467,7 @@ get_filtered_tree(svn_authz_t *authz,
   authz->user_rules[i]->pool = pool;
   authz->user_rules[i]->repository = apr_pstrdup(pool, repos_name);
   authz->user_rules[i]->user = user ? apr_pstrdup(pool, user) : NULL;
-  authz->user_rules[i]->root = create_user_authz(authz,
+  authz->user_rules[i]->root = create_user_authz(authz->full,
                                                  repos_name, user, pool,
                                                  scratch_pool);
   authz->user_rules[i]->lookup_state = create_lookup_state(pool);
@@ -1550,7 +1550,7 @@ svn_repos__retrieve_config(svn_config_t
    undefined.  If MUST_EXIST is TRUE, a missing authz or global groups file
    is also an error. */
 svn_error_t *
-authz_read(svn_authz_t **authz_p,
+authz_read(authz_full_t **authz_p,
            const char *path,
            const char *groups_path,
            svn_boolean_t must_exist,
@@ -1594,11 +1594,15 @@ svn_repos_authz_read2(svn_authz_t **auth
                       apr_pool_t *pool)
 {
   apr_pool_t *scratch_pool = svn_pool_create(pool);
+  svn_authz_t *authz = apr_pcalloc(pool, sizeof(*authz));
+  authz->pool = pool;
 
-  SVN_ERR(authz_read(authz_p, path, groups_path, must_exist, pool,
+  SVN_ERR(authz_read(&authz->full, path, groups_path, must_exist, pool,
                      scratch_pool));
 
   svn_pool_destroy(scratch_pool);
+
+  *authz_p = authz;
   return SVN_NO_ERROR;
 }
 
@@ -1608,12 +1612,16 @@ svn_repos_authz_parse(svn_authz_t **auth
                       svn_stream_t *groups_stream, apr_pool_t *pool)
 {
   apr_pool_t *scratch_pool = svn_pool_create(pool);
+  svn_authz_t *authz = apr_pcalloc(pool, sizeof(*authz));
+  authz->pool = pool;
 
   /* Parse the configuration and construct the full authz model from it. */
-  SVN_ERR(svn_authz__parse(authz_p, stream, groups_stream, pool,
+  SVN_ERR(svn_authz__parse(&authz->full, stream, groups_stream, pool,
                            scratch_pool));
 
   svn_pool_destroy(scratch_pool);
+
+  *authz_p = authz;
   return SVN_NO_ERROR;
 }
 

Modified: subversion/branches/authzperf/subversion/libsvn_repos/authz.h
URL: http://svn.apache.org/viewvc/subversion/branches/authzperf/subversion/libsvn_repos/authz.h?rev=1769875&r1=1769874&r2=1769875&view=diff
==============================================================================
--- subversion/branches/authzperf/subversion/libsvn_repos/authz.h (original)
+++ subversion/branches/authzperf/subversion/libsvn_repos/authz.h Tue Nov 15 20:09:50 2016
@@ -138,7 +138,7 @@ typedef struct authz_global_rights_t
 
 
 /* Immutable authorization info */
-struct svn_authz_t
+typedef struct authz_full_t
 {
   /* All ACLs from the authz file, in the order of definition. */
   apr_array_header_t *acls;
@@ -156,6 +156,22 @@ struct svn_authz_t
      an authz_global_rights_t*. */
   apr_hash_t *user_rights;
 
+  /* The pool from which all the parsed authz data is allocated.
+     This is the RESULT_POOL passed to svn_authz__tng_parse.
+
+     It's a good idea to dedicate a pool for the authz structure, so
+     that the whole authz representation can be deallocated by
+     destroying the pool. */
+  apr_pool_t *pool;
+} authz_full_t;
+
+
+/* Dynamic authorization info */
+struct svn_authz_t
+{
+  /* The parsed and pre-processed contents of the authz file. */
+  authz_full_t *full;
+
   /* A cache of rules filtered for a particular user.
      These will be generated on-demand. */
   authz_user_rules_t *user_rules[AUTHZ_FILTERED_CACHE_SIZE];
@@ -292,7 +308,7 @@ typedef struct authz_ace_t
  * The function uses SCRATCH_POOL for temporary allocations.
  */
 svn_error_t *
-svn_authz__parse(svn_authz_t **authz,
+svn_authz__parse(authz_full_t **authz,
                  svn_stream_t *rules,
                  svn_stream_t *groups,
                  apr_pool_t *result_pool,
@@ -337,7 +353,7 @@ svn_authz__get_acl_access(authz_access_t
  */
 svn_boolean_t
 svn_authz__get_global_rights(authz_rights_t *rights,
-                             const svn_authz_t *authz,
+                             const authz_full_t *authz,
                              const char *user, const char *repos);
 
 

Modified: subversion/branches/authzperf/subversion/libsvn_repos/authz_info.c
URL: http://svn.apache.org/viewvc/subversion/branches/authzperf/subversion/libsvn_repos/authz_info.c?rev=1769875&r1=1769874&r2=1769875&view=diff
==============================================================================
--- subversion/branches/authzperf/subversion/libsvn_repos/authz_info.c (original)
+++ subversion/branches/authzperf/subversion/libsvn_repos/authz_info.c Tue Nov 15 20:09:50
2016
@@ -119,7 +119,7 @@ resolve_global_rights(authz_rights_t *ri
 
 svn_boolean_t
 svn_authz__get_global_rights(authz_rights_t *rights_p,
-                             const svn_authz_t *authz,
+                             const authz_full_t *authz,
                              const char *user, const char *repos)
 {
   if (!user || 0 == strcmp(user, AUTHZ_ANONYMOUS_USER))

Modified: subversion/branches/authzperf/subversion/libsvn_repos/authz_parse.c
URL: http://svn.apache.org/viewvc/subversion/branches/authzperf/subversion/libsvn_repos/authz_parse.c?rev=1769875&r1=1769874&r2=1769875&view=diff
==============================================================================
--- subversion/branches/authzperf/subversion/libsvn_repos/authz_parse.c (original)
+++ subversion/branches/authzperf/subversion/libsvn_repos/authz_parse.c Tue Nov 15 20:09:50
2016
@@ -75,7 +75,7 @@ typedef struct parsed_group_t
 typedef struct ctor_baton_t
 {
   /* The final output of the parser. */
-  svn_authz_t *authz;
+  authz_full_t *authz;
 
   /* Interned-string set, allocated in AUTHZ->pool.
      Stores singleton instances of user, group and repository names,
@@ -205,7 +205,7 @@ create_ctor_baton(apr_pool_t *result_poo
   apr_pool_t *const parser_pool = svn_pool_create(scratch_pool);
   ctor_baton_t *const cb = apr_pcalloc(parser_pool, sizeof(*cb));
 
-  svn_authz_t *const authz = apr_pcalloc(result_pool, sizeof(*authz));
+  authz_full_t *const authz = apr_pcalloc(result_pool, sizeof(*authz));
   init_global_rights(&authz->anon_rights, anon_access_token, result_pool);
   init_global_rights(&authz->authn_rights, authn_access_token, result_pool);
   authz->user_rights = svn_hash__make(result_pool);
@@ -1293,7 +1293,7 @@ compare_parsed_acls(const void *va, cons
 
 
 svn_error_t *
-svn_authz__parse(svn_authz_t **authz,
+svn_authz__parse(authz_full_t **authz,
                  svn_stream_t *rules,
                  svn_stream_t *groups,
                  apr_pool_t *result_pool,

Modified: subversion/branches/authzperf/subversion/tests/libsvn_repos/authz-test.c
URL: http://svn.apache.org/viewvc/subversion/branches/authzperf/subversion/tests/libsvn_repos/authz-test.c?rev=1769875&r1=1769874&r2=1769875&view=diff
==============================================================================
--- subversion/branches/authzperf/subversion/tests/libsvn_repos/authz-test.c (original)
+++ subversion/branches/authzperf/subversion/tests/libsvn_repos/authz-test.c Tue Nov 15 20:09:50
2016
@@ -188,7 +188,7 @@ test_authz_parse(const svn_test_opts_t *
   const char *groups_path;
   apr_file_t *groups_file;
   svn_stream_t *groups;
-  svn_authz_t *authz;
+  authz_full_t *authz;
   apr_hash_t *groupdefs = svn_hash__make(pool);
   int i;
 



Mime
View raw message