subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From stef...@apache.org
Subject svn commit: r1617083 - in /subversion/branches/authzperf/subversion: include/private/svn_repos_private.h libsvn_repos/authz.c libsvn_repos/authz_pool.c libsvn_repos/config_pool.c libsvn_repos/deprecated.c libsvn_repos/repos.h
Date Sun, 10 Aug 2014 10:03:29 GMT
Author: stefan2
Date: Sun Aug 10 10:03:28 2014
New Revision: 1617083

URL: http://svn.apache.org/r1617083
Log:
On the authzperf branch:  Prepare authz code to switch from svn_config_t
to the next-gen authz model.

This involves switching internal functions to return streams and only
produce svn_config_t as a last step.  We also switch private interfaces
to the two-pool paradigm and remove private API that is not needed ATM.
Finally, temporarily disable the authz_pool logic.

* subversion/include/private/svn_repos_private.h
  (svn_repos__retrieve_config): Switch to two-pool paradigm.

* subversion/libsvn_repos/repos.h
  (svn_repos__authz_read): Same.
  (svn_repos__authz_config_validate,
   svn_repos__create_authz): Drop these.

* subversion/libsvn_repos/authz.c
  (authz_retrieve_config_repo): Return a stream instead of a parsed config
                                and drop then now unused CASE_SENSITIVE
                                parameter.
  (authz_retrieve_config_file): New function with similar to the previous
                                but reading from the local file system.
  (retrieve_config): New, factored out from svn_repos__retrieve_config,
                     combining the above two.
  (svn_repos__authz_config_validate,
   svn_repos__create_authz): Rename to ...
  (authz_config_validate,
   create_authz): ... these as they are no longer exposed through a header.

  (svn_repos__retrieve_config): Update and simplify.  Do the config parsing
                                only here at the interface.
  (svn_repos__authz_read): Update.  Do the config parsing only here at the
                           interface.
  (svn_repos_authz_read2,
   svn_repos_authz_parse): Update callers.

* subversion/libsvn_repos/config_pool.c
  (svn_repos__config_pool_get): Update caller.

* subversion/libsvn_repos/deprecated.c
  (svn_repos_authz_read): Ditto.

* subversion/libsvn_repos/authz_pool.c
  (svn_repos__authz_pool_get): Bypass config-based logic and always read
                               authz data anew.

Modified:
    subversion/branches/authzperf/subversion/include/private/svn_repos_private.h
    subversion/branches/authzperf/subversion/libsvn_repos/authz.c
    subversion/branches/authzperf/subversion/libsvn_repos/authz_pool.c
    subversion/branches/authzperf/subversion/libsvn_repos/config_pool.c
    subversion/branches/authzperf/subversion/libsvn_repos/deprecated.c
    subversion/branches/authzperf/subversion/libsvn_repos/repos.h

Modified: subversion/branches/authzperf/subversion/include/private/svn_repos_private.h
URL: http://svn.apache.org/viewvc/subversion/branches/authzperf/subversion/include/private/svn_repos_private.h?rev=1617083&r1=1617082&r2=1617083&view=diff
==============================================================================
--- subversion/branches/authzperf/subversion/include/private/svn_repos_private.h (original)
+++ subversion/branches/authzperf/subversion/include/private/svn_repos_private.h Sun Aug 10
10:03:28 2014
@@ -132,7 +132,8 @@ svn_repos__replay_ev2(svn_fs_root_t *roo
  * or a location in the Windows registry.
  *
  * Retrieve the configuration data that PATH points at and parse it into
- * CFG_P allocated in POOL.
+ * CFG_P allocated in RESULT_POOL.  Use SCRATCH_POOL for temporary
+ * allocations.
  *
  * If PATH cannot be parsed as a config file then an error is returned.  The
  * contents of CFG_P is then undefined.  If MUST_EXIST is TRUE, a missing
@@ -147,7 +148,8 @@ svn_repos__retrieve_config(svn_config_t 
                            const char *path,
                            svn_boolean_t must_exist,
                            svn_boolean_t case_sensitive,
-                           apr_pool_t *pool);
+                           apr_pool_t *result_pool,
+                           apr_pool_t *scratch_pool);
 
 /**
  * @defgroup svn_config_pool Configuration object pool API

Modified: subversion/branches/authzperf/subversion/libsvn_repos/authz.c
URL: http://svn.apache.org/viewvc/subversion/branches/authzperf/subversion/libsvn_repos/authz.c?rev=1617083&r1=1617082&r2=1617083&view=diff
==============================================================================
--- subversion/branches/authzperf/subversion/libsvn_repos/authz.c (original)
+++ subversion/branches/authzperf/subversion/libsvn_repos/authz.c Sun Aug 10 10:03:28 2014
@@ -1758,24 +1758,21 @@ struct svn_authz_t
 };
 
 
-/* Retrieve the file at DIRENT (contained in a repo) then parse it as a config
- * file placing the result into CFG_P allocated in POOL.
+/* Retrieve the file at DIRENT (contained in a repo) and return its contents
+ * as *STREAM allocated in RESULT_POOL.
  *
- * If DIRENT cannot be parsed as a config file then an error is returned.  The
- * contents of CFG_P is then undefined.  If MUST_EXIST is TRUE, a missing
- * authz file is also an error.  The CASE_SENSITIVE controls the lookup
- * behavior for section and option names alike.
+ * If MUST_EXIST is TRUE, a missing authz file is also an error, otherwise
+ * an empty stream is returned.
  *
- * SCRATCH_POOL will be used for temporary allocations. */
+ * SCRATCH_POOL will be used for temporary allocations.
+ */
 static svn_error_t *
-authz_retrieve_config_repo(svn_config_t **cfg_p,
+authz_retrieve_config_repo(svn_stream_t **stream,
                            const char *dirent,
                            svn_boolean_t must_exist,
-                           svn_boolean_t case_sensitive,
                            apr_pool_t *result_pool,
                            apr_pool_t *scratch_pool)
 {
-  svn_error_t *err;
   svn_repos_t *repos;
   const char *repos_root_dirent;
   const char *fs_path;
@@ -1783,7 +1780,6 @@ authz_retrieve_config_repo(svn_config_t 
   svn_fs_root_t *root;
   svn_revnum_t youngest_rev;
   svn_node_kind_t node_kind;
-  svn_stream_t *contents;
 
   /* Search for a repository in the full path. */
   repos_root_dirent = svn_repos_find_root_path(dirent, scratch_pool);
@@ -1792,7 +1788,7 @@ authz_retrieve_config_repo(svn_config_t 
                              "Unable to find repository at '%s'", dirent);
 
   /* Attempt to open a repository at repos_root_dirent. */
-  SVN_ERR(svn_repos_open3(&repos, repos_root_dirent, NULL, scratch_pool,
+  SVN_ERR(svn_repos_open3(&repos, repos_root_dirent, NULL, result_pool,
                           scratch_pool));
 
   fs_path = &dirent[strlen(repos_root_dirent)];
@@ -1814,15 +1810,14 @@ authz_retrieve_config_repo(svn_config_t 
 
   /* Find HEAD and the revision root */
   SVN_ERR(svn_fs_youngest_rev(&youngest_rev, fs, scratch_pool));
-  SVN_ERR(svn_fs_revision_root(&root, fs, youngest_rev, scratch_pool));
+  SVN_ERR(svn_fs_revision_root(&root, fs, youngest_rev, result_pool));
 
   SVN_ERR(svn_fs_check_path(&node_kind, root, fs_path, scratch_pool));
   if (node_kind == svn_node_none)
     {
       if (!must_exist)
         {
-          SVN_ERR(svn_config_create2(cfg_p, case_sensitive, case_sensitive,
-                                     result_pool));
+          *stream = svn_stream_empty(result_pool);
           return SVN_NO_ERROR;
         }
       else
@@ -1839,15 +1834,51 @@ authz_retrieve_config_repo(svn_config_t 
                                repos_root_dirent);
     }
 
-  SVN_ERR(svn_fs_file_contents(&contents, root, fs_path, scratch_pool));
-  err = svn_config_parse(cfg_p, contents, case_sensitive, case_sensitive,
-                         result_pool);
+  SVN_ERR(svn_fs_file_contents(stream, root, fs_path, result_pool));
+  return SVN_NO_ERROR;
+}
 
-  /* Add the URL to the error stack since the parser doesn't have it. */
-  if (err != SVN_NO_ERROR)
-    return svn_error_createf(err->apr_err, err,
-                             "Error while parsing config file: '%s' in repo '%s':",
-                             fs_path, repos_root_dirent);
+/* Retrieve the file at PATH and return its contents as *STREAM allocated in
+ * RESULT_POOL.
+ *
+ * If MUST_EXIST is TRUE, a missing authz file is also an error, otherwise
+ * an empty stream is returned.
+ *
+ * SCRATCH_POOL will be used for temporary allocations.
+ */
+static svn_error_t *
+authz_retrieve_config_file(svn_stream_t **stream,
+                           const char *path,
+                           svn_boolean_t must_exist,
+                           apr_pool_t *result_pool,
+                           apr_pool_t *scratch_pool)
+{
+  svn_node_kind_t node_kind;
+  apr_file_t *file;
+
+  SVN_ERR(svn_io_check_path(path, &node_kind, scratch_pool));
+  if (node_kind == svn_node_none)
+    {
+      if (!must_exist)
+        {
+          *stream = svn_stream_empty(result_pool);
+          return SVN_NO_ERROR;
+        }
+      else
+        {
+          return svn_error_createf(SVN_ERR_ILLEGAL_TARGET, NULL,
+                                   "'%s' path not found", path);
+        }
+    }
+  else if (node_kind != svn_node_file)
+    {
+      return svn_error_createf(SVN_ERR_ILLEGAL_TARGET, NULL,
+                               "'%s' is not a file", path);
+    }
+
+  SVN_ERR(svn_io_file_open(&file, path, APR_READ | APR_BUFFERED,
+                           APR_OS_DEFAULT, result_pool));
+  *stream = svn_stream_from_aprfile2(file, FALSE, result_pool);
 
   return SVN_NO_ERROR;
 }
@@ -1963,46 +1994,42 @@ get_filtered_tree(svn_authz_t *authz,
   return &authz->prefiltered[i];
 }
 
-
-/*** Private API functions. ***/
 
-svn_error_t *
-svn_repos__retrieve_config(svn_config_t **cfg_p,
-                           const char *path,
-                           svn_boolean_t must_exist,
-                           svn_boolean_t case_sensitive,
-                           apr_pool_t *pool)
+/* Retrieve the file at PATH (local path or repository URL) and return its
+ * contents as *STREAM allocated in RESULT_POOL.
+ *
+ * If MUST_EXIST is TRUE, a missing authz file is also an error, otherwise
+ * an empty stream is returned.
+ *
+ * SCRATCH_POOL will be used for temporary allocations.
+ */
+static svn_error_t *
+retrieve_config(svn_stream_t **stream,
+                const char *path,
+                svn_boolean_t must_exist,
+                apr_pool_t *result_pool,
+                apr_pool_t *scratch_pool)
 {
   if (svn_path_is_url(path))
     {
       const char *dirent;
-      svn_error_t *err;
-      apr_pool_t *scratch_pool = svn_pool_create(pool);
-
-      err = svn_uri_get_dirent_from_file_url(&dirent, path, scratch_pool);
-
-      if (err == SVN_NO_ERROR)
-        err = authz_retrieve_config_repo(cfg_p, dirent, must_exist,
-                                         case_sensitive, pool, scratch_pool);
-
-      /* Close the repos and streams we opened. */
-      svn_pool_destroy(scratch_pool);
-
-      return err;
+      SVN_ERR(svn_uri_get_dirent_from_file_url(&dirent, path, scratch_pool));
+      SVN_ERR(authz_retrieve_config_repo(stream, dirent, must_exist,
+                                         result_pool, scratch_pool));
     }
   else
     {
       /* Outside of repo file or Windows registry*/
-      SVN_ERR(svn_config_read3(cfg_p, path, must_exist, case_sensitive,
-                               case_sensitive, pool));
+      SVN_ERR(authz_retrieve_config_file(stream, path, must_exist,
+                                         result_pool, scratch_pool));
     }
 
   return SVN_NO_ERROR;
 }
 
-svn_error_t *
-svn_repos__authz_config_validate(svn_config_t *config,
-                                 apr_pool_t *pool)
+static svn_error_t *
+authz_config_validate(svn_config_t *config,
+                      apr_pool_t *pool)
 {
   struct authz_validate_baton baton = { 0 };
 
@@ -2017,10 +2044,10 @@ svn_repos__authz_config_validate(svn_con
   return SVN_NO_ERROR;
 }
 
-svn_error_t *
-svn_repos__create_authz(svn_authz_t **authz_p,
-                        svn_config_t *config,
-                        apr_pool_t *result_pool)
+static svn_error_t *
+create_authz(svn_authz_t **authz_p,
+             svn_config_t *config,
+             apr_pool_t *result_pool)
 {
   svn_authz_t *result = apr_pcalloc(result_pool, sizeof(*result));
 
@@ -2031,35 +2058,70 @@ svn_repos__create_authz(svn_authz_t **au
   return SVN_NO_ERROR;
 }
 
+
+/*** Private API functions. ***/
+
+svn_error_t *
+svn_repos__retrieve_config(svn_config_t **cfg_p,
+                           const char *path,
+                           svn_boolean_t must_exist,
+                           svn_boolean_t case_sensitive,
+                           apr_pool_t *result_pool,
+                           apr_pool_t *scratch_pool)
+{
+  svn_error_t *err;
+  svn_stream_t *stream;
+  SVN_ERR(retrieve_config(&stream, path, must_exist, scratch_pool,
+                          scratch_pool));
+  err = svn_config_parse(cfg_p, stream, case_sensitive, case_sensitive,
+                         result_pool);
+
+  /* Add the URL to the error stack since the parser doesn't have it. */
+  if (err != SVN_NO_ERROR)
+    return svn_error_createf(err->apr_err, err,
+                             "Error while parsing config file: '%s':",
+                             path);
+
+  return SVN_NO_ERROR;
+}
+
 svn_error_t *
 svn_repos__authz_read(svn_authz_t **authz_p, const char *path,
                       const char *groups_path, svn_boolean_t must_exist,
-                      svn_boolean_t accept_urls, apr_pool_t *pool)
+                      svn_boolean_t accept_urls, apr_pool_t *result_pool,
+                      apr_pool_t *scratch_pool)
 {
   svn_config_t *config;
+  svn_config_t *groups_cfg;
+  svn_stream_t *rules;
+  svn_stream_t *groups;
 
-  /* Load the authz file */
+  /* Open the main authz file */
   if (accept_urls)
-    SVN_ERR(svn_repos__retrieve_config(&config, path, must_exist, TRUE,
-                                       pool));
+    SVN_ERR(retrieve_config(&rules, path, must_exist, scratch_pool,
+                            scratch_pool));
   else
-    SVN_ERR(svn_config_read3(&config, path, must_exist, TRUE, TRUE, pool));
+    SVN_ERR(authz_retrieve_config_file(&rules, path, must_exist,
+                                       scratch_pool, scratch_pool));
+
+  SVN_ERR(svn_config_parse(&config, rules, TRUE, TRUE, result_pool));
 
+  /* Open the optional groups file */
   if (groups_path)
     {
-      svn_config_t *groups_cfg;
-      svn_error_t *err;
+      svn_error_t* err;
 
-      /* Load the groups file */
       if (accept_urls)
-        SVN_ERR(svn_repos__retrieve_config(&groups_cfg, groups_path,
-                                           must_exist, TRUE, pool));
+        SVN_ERR(retrieve_config(&groups, groups_path, must_exist,
+                                scratch_pool, scratch_pool));
       else
-        SVN_ERR(svn_config_read3(&groups_cfg, groups_path, must_exist,
-                                 TRUE, TRUE, pool));
+        SVN_ERR(authz_retrieve_config_file(&groups, groups_path, must_exist,
+                                           scratch_pool, scratch_pool));
+
+      SVN_ERR(svn_config_parse(&groups_cfg, groups, TRUE, TRUE, result_pool));
 
       /* Copy the groups from groups_cfg into authz. */
-      err = authz_copy_groups(config, groups_cfg, pool);
+      err = authz_copy_groups(config, groups_cfg, result_pool);
 
       /* Add the paths to the error stack since the authz_copy_groups
          routine knows nothing about them. */
@@ -2068,11 +2130,15 @@ svn_repos__authz_read(svn_authz_t **auth
                                  "Error reading authz file '%s' with "
                                  "groups file '%s':", path, groups_path);
     }
+  else
+    {
+      groups = NULL;
+    }
 
   /* Make sure there are no errors in the configuration. */
-  SVN_ERR(svn_repos__authz_config_validate(config, pool));
+  SVN_ERR(authz_config_validate(config, scratch_pool));
 
-  SVN_ERR(svn_repos__create_authz(authz_p, config, pool));
+  SVN_ERR(create_authz(authz_p, config, result_pool));
 
   return SVN_NO_ERROR;
 }
@@ -2086,8 +2152,13 @@ svn_repos_authz_read2(svn_authz_t **auth
                       const char *groups_path, svn_boolean_t must_exist,
                       apr_pool_t *pool)
 {
-  return svn_repos__authz_read(authz_p, path, groups_path, must_exist,
-                               TRUE, pool);
+  apr_pool_t *scratch_pool = svn_pool_create(pool);
+
+  SVN_ERR(svn_repos__authz_read(authz_p, path, groups_path, must_exist,
+                                TRUE, pool, scratch_pool));
+
+  svn_pool_destroy(scratch_pool);
+  return SVN_NO_ERROR;
 }
 
 
@@ -2096,6 +2167,7 @@ svn_repos_authz_parse(svn_authz_t **auth
                       svn_stream_t *groups_stream, apr_pool_t *pool)
 {
   svn_config_t *config;
+  apr_pool_t *scratch_pool = svn_pool_create(pool);
 
   /* Parse the authz stream */
   SVN_ERR(svn_config_parse(&config, stream, TRUE, TRUE, pool));
@@ -2111,10 +2183,11 @@ svn_repos_authz_parse(svn_authz_t **auth
     }
 
   /* Make sure there are no errors in the configuration. */
-  SVN_ERR(svn_repos__authz_config_validate(config, pool));
+  SVN_ERR(authz_config_validate(config, scratch_pool));
 
-  SVN_ERR(svn_repos__create_authz(authz_p, config, pool));
+  SVN_ERR(create_authz(authz_p, config, pool));
 
+  svn_pool_destroy(scratch_pool);
   return SVN_NO_ERROR;
 }
 

Modified: subversion/branches/authzperf/subversion/libsvn_repos/authz_pool.c
URL: http://svn.apache.org/viewvc/subversion/branches/authzperf/subversion/libsvn_repos/authz_pool.c?rev=1617083&r1=1617082&r2=1617083&view=diff
==============================================================================
--- subversion/branches/authzperf/subversion/libsvn_repos/authz_pool.c (original)
+++ subversion/branches/authzperf/subversion/libsvn_repos/authz_pool.c Sun Aug 10 10:03:28
2014
@@ -142,6 +142,10 @@ svn_repos__authz_pool_get(svn_authz_t **
                           svn_repos_t *preferred_repos,
                           apr_pool_t *pool)
 {
+#if 1
+  SVN_ERR(svn_repos_authz_read2(authz_p, path, groups_path, must_exist,
+                                pool));
+#else
   apr_pool_t *authz_ref_pool
     = svn_object_pool__new_wrapper_pool(authz_pool->object_pool);
   authz_object_t *authz_ref
@@ -220,6 +224,7 @@ svn_repos__authz_pool_get(svn_authz_t **
                                   authz_pool->object_pool,
                                   authz_ref->key, authz_ref, NULL,
                                   authz_ref_pool, pool));
+#endif
 
   return SVN_NO_ERROR;
 }

Modified: subversion/branches/authzperf/subversion/libsvn_repos/config_pool.c
URL: http://svn.apache.org/viewvc/subversion/branches/authzperf/subversion/libsvn_repos/config_pool.c?rev=1617083&r1=1617082&r2=1617083&view=diff
==============================================================================
--- subversion/branches/authzperf/subversion/libsvn_repos/config_pool.c (original)
+++ subversion/branches/authzperf/subversion/libsvn_repos/config_pool.c Sun Aug 10 10:03:28
2014
@@ -502,7 +502,8 @@ svn_repos__config_pool_get(svn_config_t 
           /* let the standard implementation handle all the difficult cases */
           svn_error_clear(err);
           err = svn_repos__retrieve_config(cfg, path, must_exist,
-                                           case_sensitive, pool);
+                                           case_sensitive, pool,
+                                           scratch_pool);
         }
     }
   else

Modified: subversion/branches/authzperf/subversion/libsvn_repos/deprecated.c
URL: http://svn.apache.org/viewvc/subversion/branches/authzperf/subversion/libsvn_repos/deprecated.c?rev=1617083&r1=1617082&r2=1617083&view=diff
==============================================================================
--- subversion/branches/authzperf/subversion/libsvn_repos/deprecated.c (original)
+++ subversion/branches/authzperf/subversion/libsvn_repos/deprecated.c Sun Aug 10 10:03:28
2014
@@ -30,6 +30,7 @@
 #include "svn_compat.h"
 #include "svn_hash.h"
 #include "svn_props.h"
+#include "svn_pools.h"
 
 #include "svn_private_config.h"
 
@@ -1068,6 +1069,10 @@ svn_error_t *
 svn_repos_authz_read(svn_authz_t **authz_p, const char *file,
                      svn_boolean_t must_exist, apr_pool_t *pool)
 {
-  return svn_repos__authz_read(authz_p, file, NULL, must_exist,
-                               FALSE, pool);
+  apr_pool_t *scratch_pool = svn_pool_create(pool);
+  SVN_ERR(svn_repos__authz_read(authz_p, file, NULL, must_exist,
+                                FALSE, pool, scratch_pool));
+  svn_pool_destroy(scratch_pool);
+
+  return SVN_NO_ERROR;
 }

Modified: subversion/branches/authzperf/subversion/libsvn_repos/repos.h
URL: http://svn.apache.org/viewvc/subversion/branches/authzperf/subversion/libsvn_repos/repos.h?rev=1617083&r1=1617082&r2=1617083&view=diff
==============================================================================
--- subversion/branches/authzperf/subversion/libsvn_repos/repos.h (original)
+++ subversion/branches/authzperf/subversion/libsvn_repos/repos.h Sun Aug 10 10:03:28 2014
@@ -365,8 +365,9 @@ svn_repos__hooks_post_unlock(svn_repos_t
 
 /*** Authz Functions ***/
 
-/* Read authz configuration data from PATH into *AUTHZ_P, allocated
-   in POOL.  If GROUPS_PATH is set, use the global groups parsed from it.
+/* 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.
 
    PATH and GROUPS_PATH may be a dirent or a registry path and iff ACCEPT_URLS
    is set it may also be an absolute file url.
@@ -381,17 +382,8 @@ svn_repos__authz_read(svn_authz_t **auth
                       const char *groups_path,
                       svn_boolean_t must_exist,
                       svn_boolean_t accept_urls,
-                      apr_pool_t *pool);
-
-/* Walk the authz configuration CONFIG looking for any errors. */
-svn_error_t *
-svn_repos__authz_config_validate(svn_config_t *config,
-                                 apr_pool_t *pool);
-
-svn_error_t *
-svn_repos__create_authz(svn_authz_t **authz_p,
-                        svn_config_t *config,
-                        apr_pool_t *result_pool);
+                      apr_pool_t *result_pool,
+                      apr_pool_t *scratch_pool);
 
 
 /*** Utility Functions ***/



Mime
View raw message