Alien-SVN
view release on metacpan or search on metacpan
src/subversion/subversion/libsvn_ra_local/ra_plugin.c view on Meta::CPAN
#include "svn_cache_config.h"
#include "svn_private_config.h"
#include "../libsvn_ra/ra_loader.h"
#include "private/svn_mergeinfo_private.h"
#include "private/svn_repos_private.h"
#include "private/svn_fspath.h"
#include "private/svn_atomic.h"
#include "private/svn_subr_private.h"
#define APR_WANT_STRFUNC
#include <apr_want.h>
/*----------------------------------------------------------------*/
/*** Miscellaneous helper functions ***/
/* Pool cleanup handler: ensure that the access descriptor of the
filesystem (svn_fs_t *) DATA is set to NULL. */
static apr_status_t
cleanup_access(void *data)
{
svn_error_t *serr;
svn_fs_t *fs = data;
serr = svn_fs_set_access(fs, NULL);
if (serr)
{
apr_status_t apr_err = serr->apr_err;
svn_error_clear(serr);
return apr_err;
}
return APR_SUCCESS;
}
/* Fetch a username for use with SESSION, and store it in SESSION->username.
*
* Allocate the username in SESSION->pool. Use SCRATCH_POOL for temporary
* allocations. */
static svn_error_t *
get_username(svn_ra_session_t *session,
apr_pool_t *scratch_pool)
{
svn_ra_local__session_baton_t *sess = session->priv;
/* If we've already found the username don't ask for it again. */
if (! sess->username)
{
/* Get a username somehow, so we have some svn:author property to
attach to a commit. */
if (sess->callbacks->auth_baton)
{
void *creds;
svn_auth_cred_username_t *username_creds;
svn_auth_iterstate_t *iterstate;
SVN_ERR(svn_auth_first_credentials(&creds, &iterstate,
SVN_AUTH_CRED_USERNAME,
sess->uuid, /* realmstring */
sess->callbacks->auth_baton,
scratch_pool));
/* No point in calling next_creds(), since that assumes that the
first_creds() somehow failed to authenticate. But there's no
challenge going on, so we use whatever creds we get back on
the first try. */
username_creds = creds;
if (username_creds && username_creds->username)
{
sess->username = apr_pstrdup(session->pool,
username_creds->username);
svn_error_clear(svn_auth_save_credentials(iterstate,
scratch_pool));
}
else
sess->username = "";
}
else
sess->username = "";
}
/* If we have a real username, attach it to the filesystem so that it can
be used to validate locks. Even if there already is a user context
associated, it may contain irrelevant lock tokens, so always create a new.
*/
if (*sess->username)
{
svn_fs_access_t *access_ctx;
SVN_ERR(svn_fs_create_access(&access_ctx, sess->username,
session->pool));
SVN_ERR(svn_fs_set_access(sess->fs, access_ctx));
/* Make sure this context is disassociated when the pool gets
destroyed. */
apr_pool_cleanup_register(session->pool, sess->fs, cleanup_access,
apr_pool_cleanup_null);
}
return SVN_NO_ERROR;
}
/* Implements an svn_atomic__init_once callback. Sets the FSFS memory
cache size. */
static svn_error_t *
cache_init(void *baton, apr_pool_t *pool)
{
apr_hash_t *config_hash = baton;
svn_config_t *config = NULL;
const char *memory_cache_size_str;
if (config_hash)
config = svn_hash_gets(config_hash, SVN_CONFIG_CATEGORY_CONFIG);
svn_config_get(config, &memory_cache_size_str, SVN_CONFIG_SECTION_MISCELLANY,
SVN_CONFIG_OPTION_MEMORY_CACHE_SIZE, NULL);
if (memory_cache_size_str)
{
apr_uint64_t memory_cache_size;
svn_cache_config_t settings = *svn_cache_config_get();
SVN_ERR(svn_error_quick_wrap(svn_cstring_atoui64(&memory_cache_size,
memory_cache_size_str),
_("memory-cache-size invalid")));
settings.cache_size = 1024 * 1024 * memory_cache_size;
svn_cache_config_set(&settings);
}
return SVN_NO_ERROR;
}
/*----------------------------------------------------------------*/
( run in 1.777 second using v1.01-cache-2.11-cpan-677af5a14d3 )