diff options
Diffstat (limited to 'subversion/libsvn_fs_x/rep-cache.c')
-rw-r--r-- | subversion/libsvn_fs_x/rep-cache.c | 54 |
1 files changed, 39 insertions, 15 deletions
diff --git a/subversion/libsvn_fs_x/rep-cache.c b/subversion/libsvn_fs_x/rep-cache.c index 85e62a46f376..639762182582 100644 --- a/subversion/libsvn_fs_x/rep-cache.c +++ b/subversion/libsvn_fs_x/rep-cache.c @@ -100,12 +100,16 @@ open_rep_cache(void *baton, 0, NULL, 0, fs->pool, scratch_pool)); - SVN_ERR(svn_sqlite__read_schema_version(&version, sdb, scratch_pool)); + SVN_SQLITE__ERR_CLOSE(svn_sqlite__read_schema_version(&version, sdb, + scratch_pool), + sdb); if (version < REP_CACHE_SCHEMA_FORMAT) { /* Must be 0 -- an uninitialized (no schema) database. Create the schema. Results in schema version of 1. */ - SVN_ERR(svn_sqlite__exec_statements(sdb, STMT_CREATE_SCHEMA)); + SVN_SQLITE__ERR_CLOSE(svn_sqlite__exec_statements(sdb, + STMT_CREATE_SCHEMA), + sdb); } /* This is used as a flag that the database is available so don't @@ -122,7 +126,26 @@ svn_fs_x__open_rep_cache(svn_fs_t *fs, svn_fs_x__data_t *ffd = fs->fsap_data; svn_error_t *err = svn_atomic__init_once(&ffd->rep_cache_db_opened, open_rep_cache, fs, scratch_pool); - return svn_error_quick_wrap(err, _("Couldn't open rep-cache database")); + return svn_error_quick_wrapf(err, + _("Couldn't open rep-cache database '%s'"), + svn_dirent_local_style( + path_rep_cache_db(fs->path, scratch_pool), + scratch_pool)); +} + +svn_error_t * +svn_fs_x__close_rep_cache(svn_fs_t *fs) +{ + svn_fs_x__data_t *ffd = fs->fsap_data; + + if (ffd->rep_cache_db) + { + SVN_ERR(svn_sqlite__close(ffd->rep_cache_db)); + ffd->rep_cache_db = NULL; + ffd->rep_cache_db_opened = 0; + } + + return SVN_NO_ERROR; } svn_error_t * @@ -236,7 +259,7 @@ svn_fs_x__walk_rep_reference(svn_fs_t *fs, If you extend this function, check the callsite to see if you have to make it not-ignore additional error codes. */ svn_error_t * -svn_fs_x__get_rep_reference(svn_fs_x__representation_t **rep, +svn_fs_x__get_rep_reference(svn_fs_x__representation_t **rep_p, svn_fs_t *fs, svn_checksum_t *checksum, apr_pool_t *result_pool, @@ -245,6 +268,7 @@ svn_fs_x__get_rep_reference(svn_fs_x__representation_t **rep, svn_fs_x__data_t *ffd = fs->fsap_data; svn_sqlite__stmt_t *stmt; svn_boolean_t have_row; + svn_fs_x__representation_t *rep; SVN_ERR_ASSERT(ffd->rep_sharing_allowed); if (! ffd->rep_cache_db) @@ -263,24 +287,23 @@ svn_fs_x__get_rep_reference(svn_fs_x__representation_t **rep, SVN_ERR(svn_sqlite__step(&have_row, stmt)); if (have_row) { - *rep = apr_pcalloc(result_pool, sizeof(**rep)); - memcpy((*rep)->sha1_digest, checksum->digest, - sizeof((*rep)->sha1_digest)); - (*rep)->has_sha1 = TRUE; - (*rep)->id.change_set = svn_sqlite__column_revnum(stmt, 0); - (*rep)->id.number = svn_sqlite__column_int64(stmt, 1); - (*rep)->size = svn_sqlite__column_int64(stmt, 2); - (*rep)->expanded_size = svn_sqlite__column_int64(stmt, 3); + rep = apr_pcalloc(result_pool, sizeof(*rep)); + memcpy(rep->sha1_digest, checksum->digest, sizeof(rep->sha1_digest)); + rep->has_sha1 = TRUE; + rep->id.change_set = svn_sqlite__column_revnum(stmt, 0); + rep->id.number = svn_sqlite__column_int64(stmt, 1); + rep->size = svn_sqlite__column_int64(stmt, 2); + rep->expanded_size = svn_sqlite__column_int64(stmt, 3); } else - *rep = NULL; + rep = NULL; SVN_ERR(svn_sqlite__reset(stmt)); - if (*rep) + if (rep) { /* Check that REP refers to a revision that exists in FS. */ - svn_revnum_t revision = svn_fs_x__get_revnum((*rep)->id.change_set); + svn_revnum_t revision = svn_fs_x__get_revnum(rep->id.change_set); svn_error_t *err = svn_fs_x__ensure_revision_exists(revision, fs, scratch_pool); if (err) @@ -289,6 +312,7 @@ svn_fs_x__get_rep_reference(svn_fs_x__representation_t **rep, svn_checksum_to_cstring_display(checksum, scratch_pool)); } + *rep_p = rep; return SVN_NO_ERROR; } |