Alien-SVN
view release on metacpan or search on metacpan
src/subversion/subversion/libsvn_fs_fs/lock.c view on Meta::CPAN
}
SVN_ERR(write_digest_file(this_children, this_lock, fs_path,
digest_path, perms_reference, subpool));
/* Prep for next iteration, or bail if we're done. */
if (svn_fspath__is_root(this_path->data, this_path->len))
break;
svn_stringbuf_set(this_path,
svn_fspath__dirname(this_path->data, subpool));
}
svn_pool_destroy(subpool);
return SVN_NO_ERROR;
}
/* Delete LOCK from FS in the actual OS filesystem. */
static svn_error_t *
delete_lock(svn_fs_t *fs,
svn_lock_t *lock,
apr_pool_t *pool)
{
svn_stringbuf_t *this_path = svn_stringbuf_create(lock->path, pool);
const char *child_to_kill = NULL;
apr_pool_t *subpool;
SVN_ERR_ASSERT(lock);
/* Iterate in reverse, deleting the lock for LOCK->path, and then
deleting its entry as it appears in each of its parents. */
subpool = svn_pool_create(pool);
while (1729)
{
const char *digest_path, *digest_file;
apr_hash_t *this_children;
svn_lock_t *this_lock;
svn_pool_clear(subpool);
/* Calculate the DIGEST_PATH for the currently FS path, and then
get its DIGEST_FILE basename. */
SVN_ERR(digest_path_from_path(&digest_path, fs->path, this_path->data,
subpool));
digest_file = svn_dirent_basename(digest_path, subpool);
SVN_ERR(read_digest_file(&this_children, &this_lock, fs->path,
digest_path, subpool));
/* Delete the lock (first time through only). */
if (lock)
{
this_lock = NULL;
lock = NULL;
child_to_kill = apr_pstrdup(pool, digest_file);
}
if (child_to_kill)
svn_hash_sets(this_children, child_to_kill, NULL);
if (! (this_lock || apr_hash_count(this_children) != 0))
{
/* Special case: no goodz, no file. And remember to nix
the entry for it in its parent. */
SVN_ERR(svn_io_remove_file2(digest_path, FALSE, subpool));
}
else
{
const char *rev_0_path;
SVN_ERR(svn_fs_fs__path_rev_absolute(&rev_0_path, fs, 0, pool));
SVN_ERR(write_digest_file(this_children, this_lock, fs->path,
digest_path, rev_0_path, subpool));
}
/* Prep for next iteration, or bail if we're done. */
if (svn_fspath__is_root(this_path->data, this_path->len))
break;
svn_stringbuf_set(this_path,
svn_fspath__dirname(this_path->data, subpool));
}
svn_pool_destroy(subpool);
return SVN_NO_ERROR;
}
/* Set *LOCK_P to the lock for PATH in FS. HAVE_WRITE_LOCK should be
TRUE if the caller (or one of its callers) has taken out the
repository-wide write lock, FALSE otherwise. If MUST_EXIST is
not set, the function will simply return NULL in *LOCK_P instead
of creating an SVN_FS__ERR_NO_SUCH_LOCK error in case the lock
was not found (much faster). Use POOL for allocations. */
static svn_error_t *
get_lock(svn_lock_t **lock_p,
svn_fs_t *fs,
const char *path,
svn_boolean_t have_write_lock,
svn_boolean_t must_exist,
apr_pool_t *pool)
{
svn_lock_t *lock = NULL;
const char *digest_path;
svn_node_kind_t kind;
SVN_ERR(digest_path_from_path(&digest_path, fs->path, path, pool));
SVN_ERR(svn_io_check_path(digest_path, &kind, pool));
*lock_p = NULL;
if (kind != svn_node_none)
SVN_ERR(read_digest_file(NULL, &lock, fs->path, digest_path, pool));
if (! lock)
return must_exist ? SVN_FS__ERR_NO_SUCH_LOCK(fs, path) : SVN_NO_ERROR;
/* Don't return an expired lock. */
if (lock->expiration_date && (apr_time_now() > lock->expiration_date))
{
/* Only remove the lock if we have the write lock.
Read operations shouldn't change the filesystem. */
if (have_write_lock)
SVN_ERR(delete_lock(fs, lock, pool));
return SVN_FS__ERR_LOCK_EXPIRED(fs, lock->token);
}
( run in 0.757 second using v1.01-cache-2.11-cpan-39bf76dae61 )