You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by iv...@apache.org on 2014/04/22 11:13:36 UTC
svn commit: r1589048 - in /subversion/trunk/subversion: include/svn_fs.h
include/svn_repos.h libsvn_fs/fs-loader.c libsvn_repos/deprecated.c
libsvn_repos/repos.c mod_dav_svn/repos.c mod_dav_svn/version.c
svnserve/serve.c
Author: ivan
Date: Tue Apr 22 09:13:35 2014
New Revision: 1589048
URL: http://svn.apache.org/r1589048
Log:
Switch svn_repos_open2() and svn_fs_open() to result/scratch pool paradigm.
* subversion/include/svn_fs.h
(svn_fs_open2): Revv svn_fs_open() with SCRATCH_POOL argument.
(svn_fs_open): Deprecate.
* subversion/include/svn_repos.h
(svn_repos_open3): Revv svn_repos_open2() with SCRATCH_POOL argument.
(svn_repos_open2): Implement deprecated function.
* subversion/libsvn_fs/fs-loader.c
(fs_library_vtable): Remove subpool.
(svn_fs_open2): Revv. Use SCRATCH_POOL for temporary allocations.
(svn_fs_open): Implement deprecated function.
* subversion/libsvn_repos/deprecated.c
(svn_repos_open2): Implement deprecated function.
* subversion/libsvn_repos/repos.c
(get_repos): Add SCRATCH_POOL argument. Use it where appropriate.
(svn_repos_open3): Revv svn_repos_open2(). Use SCRATCH_POOL for
temporary allocations.
(svn_repos_upgrade2, svn_repos_recover4, multi_freeze,
svn_repos_db_logfiles, svn_repos_hotcopy2): Adapt callers of get_repos().
* subversion/mod_dav_svn/repos.c
(get_resource): Use svn_repos_open3() with r->pool as SCRATCH_POOL.
* subversion/mod_dav_svn/version.c
(cleanup_deltify): Use svn_repos_open3().
* subversion/svnserve/serve.c
(find_repos): Add SCRATCH_POOL and use svn_repos_open3().
(construct_server_baton): Update caller.
Modified:
subversion/trunk/subversion/include/svn_fs.h
subversion/trunk/subversion/include/svn_repos.h
subversion/trunk/subversion/libsvn_fs/fs-loader.c
subversion/trunk/subversion/libsvn_repos/deprecated.c
subversion/trunk/subversion/libsvn_repos/repos.c
subversion/trunk/subversion/mod_dav_svn/repos.c
subversion/trunk/subversion/mod_dav_svn/version.c
subversion/trunk/subversion/svnserve/serve.c
Modified: subversion/trunk/subversion/include/svn_fs.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/include/svn_fs.h?rev=1589048&r1=1589047&r2=1589048&view=diff
==============================================================================
--- subversion/trunk/subversion/include/svn_fs.h (original)
+++ subversion/trunk/subversion/include/svn_fs.h Tue Apr 22 09:13:35 2014
@@ -266,21 +266,35 @@ svn_fs_create(svn_fs_t **fs_p,
* NULL, the options it contains modify the behavior of the
* filesystem. The interpretation of @a fs_config is specific to the
* filesystem back-end. The opened filesystem may be closed by
- * destroying @a pool.
+ * destroying @a result_pool.
*
* @note The lifetime of @a fs_config must not be shorter than @a
- * pool's. It's a good idea to allocate @a fs_config from @a pool or
- * one of its ancestors.
+ * result_pool's. It's a good idea to allocate @a fs_config from
+ * @a result_pool or one of its ancestors.
*
* Only one thread may operate on any given filesystem object at once.
* Two threads may access the same filesystem simultaneously only if
* they open separate filesystem objects.
*
* @note You probably don't want to use this directly. Take a look at
- * svn_repos_open2() instead.
+ * svn_repos_open3() instead.
*
+ * @since New in 1.9.
+ */
+svn_error_t *
+svn_fs_open2(svn_fs_t **fs_p,
+ const char *path,
+ apr_hash_t *fs_config,
+ apr_pool_t *result_pool,
+ apr_pool_t *scratch_pool);
+
+/**
+ * Like svn_fs_open2(), but without @a scratch_pool.
+ *
+ * @deprecated Provided for backward compatibility with the 1.8 API.
* @since New in 1.1.
*/
+SVN_DEPRECATED
svn_error_t *
svn_fs_open(svn_fs_t **fs_p,
const char *path,
Modified: subversion/trunk/subversion/include/svn_repos.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/include/svn_repos.h?rev=1589048&r1=1589047&r2=1589048&view=diff
==============================================================================
--- subversion/trunk/subversion/include/svn_repos.h (original)
+++ subversion/trunk/subversion/include/svn_repos.h Tue Apr 22 09:13:35 2014
@@ -405,16 +405,31 @@ svn_repos_find_root_path(const char *pat
/** Set @a *repos_p to a repository object for the repository at @a path.
*
- * Allocate @a *repos_p in @a pool.
+ * Allocate @a *repos_p in @a result_pool.
*
* Acquires a shared lock on the repository, and attaches a cleanup
- * function to @a pool to remove the lock. If no lock can be acquired,
+ * function to @a result_pool to remove the lock. If no lock can be acquired,
* returns error, with undefined effect on @a *repos_p. If an exclusive
* lock is present, this blocks until it's gone. @a fs_config will be
* passed to the filesystem initialization function and may be @c NULL.
*
+ * Use @a scratch_pool for temporary allocations.
+ *
+ * @since New in 1.9.
+ */
+svn_error_t *
+svn_repos_open3(svn_repos_t **repos_p,
+ const char *path,
+ apr_hash_t *fs_config,
+ apr_pool_t *result_pool,
+ apr_pool_t *scratch_pool);
+
+/** Similar to svn_repos_open3() but without @a scratch_pool.
+ *
+ * @deprecated Provided for backward compatibility with 1.8 API.
* @since New in 1.7.
*/
+SVN_DEPRECATED
svn_error_t *
svn_repos_open2(svn_repos_t **repos_p,
const char *path,
Modified: subversion/trunk/subversion/libsvn_fs/fs-loader.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs/fs-loader.c?rev=1589048&r1=1589047&r2=1589048&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs/fs-loader.c (original)
+++ subversion/trunk/subversion/libsvn_fs/fs-loader.c Tue Apr 22 09:13:35 2014
@@ -344,13 +344,11 @@ fs_library_vtable(fs_library_vtable_t **
apr_pool_t *pool)
{
const char *fs_type;
- apr_pool_t *subpool = svn_pool_create(pool);
- SVN_ERR(svn_fs_type(&fs_type, path, subpool));
+ SVN_ERR(svn_fs_type(&fs_type, path, pool));
/* Fetch the library vtable by name, now that we've chosen one. */
- SVN_ERR(get_library_vtable(vtable, fs_type, subpool));
- svn_pool_destroy(subpool);
+ SVN_ERR(get_library_vtable(vtable, fs_type, pool));
return SVN_NO_ERROR;
}
@@ -507,20 +505,31 @@ svn_fs_create(svn_fs_t **fs_p, const cha
}
svn_error_t *
-svn_fs_open(svn_fs_t **fs_p, const char *path, apr_hash_t *fs_config,
- apr_pool_t *pool)
+svn_fs_open2(svn_fs_t **fs_p, const char *path, apr_hash_t *fs_config,
+ apr_pool_t *result_pool,
+ apr_pool_t *scratch_pool)
{
fs_library_vtable_t *vtable;
- SVN_ERR(fs_library_vtable(&vtable, path, pool));
- *fs_p = fs_new(fs_config, pool);
- SVN_ERR(vtable->open_fs(*fs_p, path, common_pool_lock, pool, common_pool));
+ SVN_ERR(fs_library_vtable(&vtable, path, scratch_pool));
+ *fs_p = fs_new(fs_config, result_pool);
+ SVN_ERR(vtable->open_fs(*fs_p, path, common_pool_lock, result_pool,
+ common_pool));
SVN_ERR(vtable->set_svn_fs_open(*fs_p, svn_fs_open));
return SVN_NO_ERROR;
}
svn_error_t *
+svn_fs_open(svn_fs_t **fs_p,
+ const char *path,
+ apr_hash_t *fs_config,
+ apr_pool_t *pool)
+{
+ return svn_fs_open2(fs_p, path, fs_config, pool, pool);
+}
+
+svn_error_t *
svn_fs_upgrade2(const char *path,
svn_fs_upgrade_notify_t notify_func,
void *notify_baton,
Modified: subversion/trunk/subversion/libsvn_repos/deprecated.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_repos/deprecated.c?rev=1589048&r1=1589047&r2=1589048&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_repos/deprecated.c (original)
+++ subversion/trunk/subversion/libsvn_repos/deprecated.c Tue Apr 22 09:13:35 2014
@@ -138,6 +138,15 @@ svn_repos_get_commit_editor(const svn_de
}
svn_error_t *
+svn_repos_open2(svn_repos_t **repos_p,
+ const char *path,
+ apr_hash_t *fs_config,
+ apr_pool_t *pool)
+{
+ return svn_repos_open3(repos_p, path, fs_config, pool, pool);
+}
+
+svn_error_t *
svn_repos_open(svn_repos_t **repos_p,
const char *path,
apr_pool_t *pool)
Modified: subversion/trunk/subversion/libsvn_repos/repos.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_repos/repos.c?rev=1589048&r1=1589047&r2=1589048&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_repos/repos.c (original)
+++ subversion/trunk/subversion/libsvn_repos/repos.c Tue Apr 22 09:13:35 2014
@@ -1454,25 +1454,29 @@ get_repos(svn_repos_t **repos_p,
svn_boolean_t nonblocking,
svn_boolean_t open_fs,
apr_hash_t *fs_config,
- apr_pool_t *pool)
+ apr_pool_t *result_pool,
+ apr_pool_t *scratch_pool)
{
svn_repos_t *repos;
+ const char *fs_type;
/* Allocate a repository object. */
- repos = create_svn_repos_t(path, pool);
+ repos = create_svn_repos_t(path, result_pool);
/* Verify the validity of our repository format. */
- SVN_ERR(check_repos_format(repos, pool));
+ SVN_ERR(check_repos_format(repos, scratch_pool));
/* Discover the FS type. */
- SVN_ERR(svn_fs_type(&repos->fs_type, repos->db_path, pool));
+ SVN_ERR(svn_fs_type(&fs_type, repos->db_path, scratch_pool));
+ repos->fs_type = apr_pstrdup(result_pool, fs_type);
/* Lock if needed. */
- SVN_ERR(lock_repos(repos, exclusive, nonblocking, pool));
+ SVN_ERR(lock_repos(repos, exclusive, nonblocking, result_pool));
/* Open up the filesystem only after obtaining the lock. */
if (open_fs)
- SVN_ERR(svn_fs_open(&repos->fs, repos->db_path, fs_config, pool));
+ SVN_ERR(svn_fs_open2(&repos->fs, repos->db_path, fs_config,
+ result_pool, scratch_pool));
#ifdef SVN_DEBUG_CRASH_AT_REPOS_OPEN
/* If $PATH/config/debug-abort exists, crash the server here.
@@ -1483,8 +1487,8 @@ get_repos(svn_repos_t **repos_p,
{
svn_node_kind_t kind;
svn_error_t *err = svn_io_check_path(
- svn_dirent_join(repos->conf_path, "debug-abort", pool),
- &kind, pool);
+ svn_dirent_join(repos->conf_path, "debug-abort", scratch_pool),
+ &kind, scratch_pool);
svn_error_clear(err);
if (!err && kind == svn_node_file)
SVN_ERR_MALFUNCTION_NO_RETURN();
@@ -1525,17 +1529,18 @@ svn_repos_find_root_path(const char *pat
return candidate;
}
-
svn_error_t *
-svn_repos_open2(svn_repos_t **repos_p,
+svn_repos_open3(svn_repos_t **repos_p,
const char *path,
apr_hash_t *fs_config,
- apr_pool_t *pool)
+ apr_pool_t *result_pool,
+ apr_pool_t *scratch_pool)
{
/* Fetch a repository object initialized with a shared read/write
lock on the database. */
- return get_repos(repos_p, path, FALSE, FALSE, TRUE, fs_config, pool);
+ return get_repos(repos_p, path, FALSE, FALSE, TRUE, fs_config,
+ result_pool, scratch_pool);
}
/* Baton used with fs_upgrade_notify, specifying the svn_repos layer
@@ -1608,7 +1613,8 @@ svn_repos_upgrade2(const char *path,
least prevent others from trying to read or write to it while we
run recovery. (Other backends should do their own locking; see
lock_repos.) */
- SVN_ERR(get_repos(&repos, path, TRUE, nonblocking, FALSE, NULL, subpool));
+ SVN_ERR(get_repos(&repos, path, TRUE, nonblocking, FALSE, NULL, subpool,
+ subpool));
if (notify_func)
{
@@ -1848,7 +1854,7 @@ svn_repos_recover4(const char *path,
SVN_ERR(get_repos(&repos, path, TRUE, nonblocking,
FALSE, /* don't try to open the db yet. */
NULL,
- subpool));
+ subpool, subpool));
if (notify_func)
{
@@ -1903,7 +1909,7 @@ multi_freeze(void *baton,
TRUE /* exclusive (only applies to BDB) */,
FALSE /* non-blocking */,
FALSE /* open-fs */,
- NULL, subpool));
+ NULL, subpool, subpool));
if (strcmp(repos->fs_type, SVN_FS_TYPE_BDB) == 0)
@@ -1963,7 +1969,7 @@ svn_error_t *svn_repos_db_logfiles(apr_a
FALSE, FALSE,
FALSE, /* Do not open fs. */
NULL,
- pool));
+ pool, pool));
SVN_ERR(svn_fs_berkeley_logfiles(logfiles,
svn_repos_db_env(repos, pool),
@@ -2106,7 +2112,7 @@ svn_repos_hotcopy2(const char *src_path,
FALSE, FALSE,
FALSE, /* don't try to open the db yet. */
NULL,
- pool));
+ pool, pool));
/* If we are going to clean logs, then get an exclusive lock on
db-logs.lock, to ensure that no one else will work with logs.
Modified: subversion/trunk/subversion/mod_dav_svn/repos.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/mod_dav_svn/repos.c?rev=1589048&r1=1589047&r2=1589048&view=diff
==============================================================================
--- subversion/trunk/subversion/mod_dav_svn/repos.c (original)
+++ subversion/trunk/subversion/mod_dav_svn/repos.c Tue Apr 22 09:13:35 2014
@@ -2291,8 +2291,8 @@ get_resource(request_rec *r,
/* open the FS */
if (!serr)
- serr = svn_repos_open2(&(repos->repos), fs_path, fs_config,
- r->connection->pool);
+ serr = svn_repos_open3(&(repos->repos), fs_path, fs_config,
+ r->connection->pool, r->pool);
if (serr != NULL)
{
/* The error returned by svn_repos_open2 might contain the
Modified: subversion/trunk/subversion/mod_dav_svn/version.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/mod_dav_svn/version.c?rev=1589048&r1=1589047&r2=1589048&view=diff
==============================================================================
--- subversion/trunk/subversion/mod_dav_svn/version.c (original)
+++ subversion/trunk/subversion/mod_dav_svn/version.c Tue Apr 22 09:13:35 2014
@@ -841,7 +841,7 @@ cleanup_deltify(void *data)
subpool, then destroy it before exiting. */
apr_pool_t *subpool = svn_pool_create(cdb->pool);
- err = svn_repos_open2(&repos, cdb->repos_path, NULL, subpool);
+ err = svn_repos_open3(&repos, cdb->repos_path, NULL, subpool, subpool);
if (err)
{
ap_log_perror(APLOG_MARK, APLOG_ERR, err->apr_err, cdb->pool,
Modified: subversion/trunk/subversion/svnserve/serve.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svnserve/serve.c?rev=1589048&r1=1589047&r2=1589048&view=diff
==============================================================================
--- subversion/trunk/subversion/svnserve/serve.c (original)
+++ subversion/trunk/subversion/svnserve/serve.c Tue Apr 22 09:13:35 2014
@@ -3442,6 +3442,9 @@ repos_path_valid(const char *path)
*
* CONFIG_POOL and AUTHZ_POOL shall be used to load any object of the
* respective type.
+ *
+ * Use SCRATCH_POOL for temporary allocations.
+ *
*/
static svn_error_t *
find_repos(const char *url,
@@ -3453,7 +3456,8 @@ find_repos(const char *url,
svn_repos__config_pool_t *config_pool,
svn_repos__authz_pool_t *authz_pool,
apr_hash_t *fs_config,
- apr_pool_t *pool)
+ apr_pool_t *result_pool,
+ apr_pool_t *scratch_pool)
{
const char *path, *full_path, *fs_path, *hooks_env;
svn_stringbuf_t *url_buf;
@@ -3470,8 +3474,8 @@ find_repos(const char *url,
if (path == NULL)
path = "";
}
- path = svn_relpath_canonicalize(path, pool);
- path = svn_path_uri_decode(path, pool);
+ path = svn_relpath_canonicalize(path, scratch_pool);
+ path = svn_path_uri_decode(path, scratch_pool);
/* Ensure that it isn't possible to escape the root by disallowing
'..' segments. */
@@ -3480,55 +3484,55 @@ find_repos(const char *url,
"Couldn't determine repository path");
/* Join the server-configured root with the client path. */
- full_path = svn_dirent_join(svn_dirent_canonicalize(root, pool),
- path, pool);
+ full_path = svn_dirent_join(svn_dirent_canonicalize(root, scratch_pool),
+ path, scratch_pool);
/* Search for a repository in the full path. */
- repository->repos_root = svn_repos_find_root_path(full_path, pool);
+ repository->repos_root = svn_repos_find_root_path(full_path, result_pool);
if (!repository->repos_root)
return svn_error_createf(SVN_ERR_RA_SVN_REPOS_NOT_FOUND, NULL,
"No repository found in '%s'", url);
/* Open the repository and fill in b with the resulting information. */
- SVN_ERR(svn_repos_open2(&repository->repos, repository->repos_root,
- fs_config, pool));
+ SVN_ERR(svn_repos_open3(&repository->repos, repository->repos_root,
+ fs_config, result_pool, scratch_pool));
SVN_ERR(svn_repos_remember_client_capabilities(repository->repos,
repository->capabilities));
repository->fs = svn_repos_fs(repository->repos);
fs_path = full_path + strlen(repository->repos_root);
repository->fs_path = svn_stringbuf_create(*fs_path ? fs_path : "/",
- pool);
- url_buf = svn_stringbuf_create(url, pool);
+ result_pool);
+ url_buf = svn_stringbuf_create(url, result_pool);
svn_path_remove_components(url_buf,
svn_path_component_count(repository->fs_path->data));
repository->repos_url = url_buf->data;
repository->authz_repos_name = svn_dirent_is_child(root,
repository->repos_root,
- pool);
+ result_pool);
if (repository->authz_repos_name == NULL)
repository->repos_name = svn_dirent_basename(repository->repos_root,
- pool);
+ result_pool);
else
repository->repos_name = repository->authz_repos_name;
repository->repos_name = svn_path_uri_encode(repository->repos_name,
- pool);
+ result_pool);
/* If the svnserve configuration has not been loaded then load it from the
* repository. */
if (NULL == cfg)
{
- repository->base = svn_repos_conf_dir(repository->repos, pool);
+ repository->base = svn_repos_conf_dir(repository->repos, result_pool);
SVN_ERR(svn_repos__config_pool_get(&cfg, NULL, config_pool,
svn_repos_svnserve_conf
- (repository->repos, pool),
+ (repository->repos, result_pool),
FALSE, FALSE, repository->repos,
- pool));
+ result_pool));
}
- SVN_ERR(load_pwdb_config(repository, cfg, config_pool, pool));
+ SVN_ERR(load_pwdb_config(repository, cfg, config_pool, result_pool));
SVN_ERR(load_authz_config(repository, repository->repos_root, cfg,
- authz_pool, pool));
+ authz_pool, result_pool));
#ifdef SVN_HAVE_SASL
{
@@ -3550,10 +3554,10 @@ find_repos(const char *url,
#endif
/* Use the repository UUID as the default realm. */
- SVN_ERR(svn_fs_get_uuid(repository->fs, &repository->realm, pool));
+ SVN_ERR(svn_fs_get_uuid(repository->fs, &repository->realm, scratch_pool));
svn_config_get(cfg, &repository->realm, SVN_CONFIG_SECTION_GENERAL,
SVN_CONFIG_OPTION_REALM, repository->realm);
- repository->realm = apr_pstrdup(pool, repository->realm);
+ repository->realm = apr_pstrdup(result_pool, repository->realm);
/* Make sure it's possible for the client to authenticate. Note
that this doesn't take into account any authz configuration read
@@ -3565,9 +3569,9 @@ find_repos(const char *url,
svn_config_get(cfg, &hooks_env, SVN_CONFIG_SECTION_GENERAL,
SVN_CONFIG_OPTION_HOOKS_ENV, NULL);
if (hooks_env)
- hooks_env = svn_dirent_internal_style(hooks_env, pool);
+ hooks_env = svn_dirent_internal_style(hooks_env, scratch_pool);
- repository->hooks_env = apr_pstrdup(pool, hooks_env);
+ repository->hooks_env = apr_pstrdup(result_pool, hooks_env);
return SVN_NO_ERROR;
}
@@ -3857,7 +3861,7 @@ construct_server_baton(server_baton_t **
b->read_only, params->cfg,
b->repository, params->config_pool,
params->authz_pool, params->fs_config,
- conn_pool),
+ conn_pool, scratch_pool),
b);
if (!err)
{