You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by st...@apache.org on 2016/12/03 09:22:03 UTC

svn commit: r1772438 - /subversion/branches/authzperf/subversion/libsvn_repos/authz.c

Author: stefan2
Date: Sat Dec  3 09:22:03 2016
New Revision: 1772438

URL: http://svn.apache.org/viewvc?rev=1772438&view=rev
Log:
On the authzperf branch:
Reorder code in preparation of upcoming changes.

* subversion/libsvn_repos/authz.c
  (authz_pool,
   authz_pool_initialized,
   synchronized_authz_initialize,
   svn_repos_authz_initialize): Move up.
  (construct_authz_key): Move up and renamed from ...
  (construct_key): ... this.
  (authz_read): Update caller.

Modified:
    subversion/branches/authzperf/subversion/libsvn_repos/authz.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=1772438&r1=1772437&r2=1772438&view=diff
==============================================================================
--- subversion/branches/authzperf/subversion/libsvn_repos/authz.c (original)
+++ subversion/branches/authzperf/subversion/libsvn_repos/authz.c Sat Dec  3 09:22:03 2016
@@ -120,6 +120,68 @@ combine_right_limits(limited_rights_t *t
 }
 
 
+
+/*** Authz cache access. ***/
+
+/* All authz instances currently in use will be cached here.
+ * Will be instantiated at most once. */
+svn_object_pool__t *authz_pool = NULL;
+static svn_atomic_t authz_pool_initialized = FALSE;
+
+/* Implements svn_atomic__err_init_func_t. */
+static svn_error_t *
+synchronized_authz_initialize(void *baton, apr_pool_t *pool)
+{
+  svn_boolean_t multi_threaded
+    = apr_allocator_mutex_get(apr_pool_allocator_get(pool)) != NULL;
+
+  SVN_ERR(svn_object_pool__create(&authz_pool, multi_threaded, pool));
+
+  return SVN_NO_ERROR;
+}
+
+svn_error_t *
+svn_repos_authz_initialize(apr_pool_t *pool)
+{
+  /* Protect against multiple calls. */
+  return svn_error_trace(svn_atomic__init_once(&authz_pool_initialized,
+                                               synchronized_authz_initialize,
+                                               NULL, pool));
+}
+
+/* Return a combination of AUTHZ_KEY and GROUPS_KEY, allocated in RESULT_POOL.
+ * GROUPS_KEY may be NULL.  This is the key for the AUTHZ_POOL.
+ */
+static svn_membuf_t *
+construct_authz_key(const svn_checksum_t *authz_key,
+                    const svn_checksum_t *groups_key,
+                    apr_pool_t *result_pool)
+{
+  svn_membuf_t *result = apr_pcalloc(result_pool, sizeof(*result));
+  if (groups_key)
+    {
+      apr_size_t authz_size = svn_checksum_size(authz_key);
+      apr_size_t groups_size = svn_checksum_size(groups_key);
+
+      svn_membuf__create(result, authz_size + groups_size, result_pool);
+      result->size = authz_size + groups_size; /* exact length is required! */
+
+      memcpy(result->data, authz_key->digest, authz_size);
+      memcpy((char *)result->data + authz_size,
+             groups_key->digest, groups_size);
+    }
+  else
+    {
+      apr_size_t size = svn_checksum_size(authz_key);
+      svn_membuf__create(result, size, result_pool);
+      result->size = size; /* exact length is required! */
+      memcpy(result->data, authz_key->digest, size);
+    }
+
+  return result;
+}
+
+
 /*** Constructing the prefix tree. ***/
 
 /* Since prefix arrays may have more than one hit, we need to link them
@@ -1356,66 +1418,6 @@ get_filtered_tree(svn_authz_t *authz,
 
 
 
-/*** Authz cache access. ***/
-
-/* All authz instances currently in use will be cached here.
- * Will be instantiated at most once. */
-svn_object_pool__t *authz_pool = NULL;
-static svn_atomic_t authz_pool_initialized = FALSE;
-
-/* Implements svn_atomic__err_init_func_t. */
-static svn_error_t *
-synchronized_authz_initialize(void *baton, apr_pool_t *pool)
-{
-  svn_boolean_t multi_threaded
-    = apr_allocator_mutex_get(apr_pool_allocator_get(pool)) != NULL;
-
-  return svn_error_trace(svn_object_pool__create(&authz_pool, multi_threaded,
-                                                 pool));
-}
-
-svn_error_t *
-svn_repos_authz_initialize(apr_pool_t *pool)
-{
-  /* Protect against multiple calls. */
-  return svn_error_trace(svn_atomic__init_once(&authz_pool_initialized,
-                                               synchronized_authz_initialize,
-                                               NULL, pool));
-}
-
-/* Return a combination of AUTHZ_KEY and GROUPS_KEY, allocated in RESULT_POOL.
- * GROUPS_KEY may be NULL.
- */
-static svn_membuf_t *
-construct_key(const svn_checksum_t *authz_key,
-              const svn_checksum_t *groups_key,
-              apr_pool_t *result_pool)
-{
-  svn_membuf_t *result = apr_pcalloc(result_pool, sizeof(*result));
-  if (groups_key)
-    {
-      apr_size_t authz_size = svn_checksum_size(authz_key);
-      apr_size_t groups_size = svn_checksum_size(groups_key);
-
-      svn_membuf__create(result, authz_size + groups_size, result_pool);
-      result->size = authz_size + groups_size; /* exact length is required! */
-
-      memcpy(result->data, authz_key->digest, authz_size);
-      memcpy((char *)result->data + authz_size,
-             groups_key->digest, groups_size);
-    }
-  else
-    {
-      apr_size_t size = svn_checksum_size(authz_key);
-      svn_membuf__create(result, size, result_pool);
-      result->size = size; /* exact length is required! */
-      memcpy(result->data, authz_key->digest, size);
-    }
-
-  return result;
-}
-
-
 /* Read authz configuration data from PATH into *AUTHZ_P, allocated in
    RESULT_POOL.  If GROUPS_PATH is set, use the global groups parsed from it.
    Use SCRATCH_POOL for temporary allocations.
@@ -1459,7 +1461,7 @@ authz_read(authz_full_t **authz_p,
   if (authz_pool)
     {
       /* Cache lookup. */
-      key = construct_key(rules_checksum, groups_checksum, scratch_pool);
+      key = construct_authz_key(rules_checksum, groups_checksum, scratch_pool);
       SVN_ERR(svn_object_pool__lookup((void **)authz_p, authz_pool, key,
                                       result_pool));