diff options
Diffstat (limited to 'subversion/libsvn_wc/wc_db_wcroot.c')
-rw-r--r-- | subversion/libsvn_wc/wc_db_wcroot.c | 84 |
1 files changed, 62 insertions, 22 deletions
diff --git a/subversion/libsvn_wc/wc_db_wcroot.c b/subversion/libsvn_wc/wc_db_wcroot.c index a111073..1cfca3d 100644 --- a/subversion/libsvn_wc/wc_db_wcroot.c +++ b/subversion/libsvn_wc/wc_db_wcroot.c @@ -28,6 +28,7 @@ #include "svn_dirent_uri.h" #include "svn_hash.h" #include "svn_path.h" +#include "svn_pools.h" #include "svn_version.h" #include "wc.h" @@ -42,7 +43,7 @@ #define UNKNOWN_WC_ID ((apr_int64_t) -1) #define FORMAT_FROM_SDB (-1) - +/* #define VERIFY_ON_CLOSE */ /* Get the format version from a wc-1 directory. If it is not a working copy directory, then it sets VERSION to zero and returns no error. */ @@ -145,9 +146,8 @@ get_path_kind(svn_node_kind_t *kind, } -/* Return an error if the work queue in SDB is non-empty. */ -static svn_error_t * -verify_no_work(svn_sqlite__db_t *sdb) +svn_error_t * +svn_wc__db_verify_no_work(svn_sqlite__db_t *sdb) { svn_sqlite__stmt_t *stmt; svn_boolean_t have_row; @@ -163,6 +163,27 @@ verify_no_work(svn_sqlite__db_t *sdb) return SVN_NO_ERROR; } +#if defined(VERIFY_ON_CLOSE) && defined(SVN_DEBUG) +/* Implements svn_wc__db_verify_cb_t */ +static svn_error_t * +verify_db_cb(void *baton, + const char *wc_abspath, + const char *local_relpath, + int op_depth, + int id, + const char *msg, + apr_pool_t *scratch_pool) +{ + if (op_depth >= 0) + SVN_DBG(("DB-VRFY: %s: %s (%d): SV%04d %s", + wc_abspath, local_relpath, op_depth, id, msg)); + else + SVN_DBG(("DB-VRFY: %s: %s: SV%04d %s", + wc_abspath, local_relpath, id, msg)); + + return SVN_NO_ERROR; +} +#endif /* */ static apr_status_t @@ -173,6 +194,18 @@ close_wcroot(void *data) SVN_ERR_ASSERT_NO_RETURN(wcroot->sdb != NULL); +#if defined(VERIFY_ON_CLOSE) && defined(SVN_DEBUG) + if (getenv("SVN_CMDLINE_VERIFY_SQL_AT_CLOSE")) + { + apr_pool_t *scratch_pool = svn_pool_create(NULL); + + svn_error_clear(svn_wc__db_verify_db_full_internal( + wcroot, verify_db_cb, NULL, scratch_pool)); + + svn_pool_destroy(scratch_pool); + } +#endif + err = svn_sqlite__close(wcroot->sdb); wcroot->sdb = NULL; if (err) @@ -207,6 +240,7 @@ svn_wc__db_open(svn_wc__db_t **db, { svn_error_t *err; svn_boolean_t sqlite_exclusive = FALSE; + apr_int64_t timeout; err = svn_config_get_bool(config, &sqlite_exclusive, SVN_CONFIG_SECTION_WORKING_COPY, @@ -218,6 +252,15 @@ svn_wc__db_open(svn_wc__db_t **db, } else (*db)->exclusive = sqlite_exclusive; + + err = svn_config_get_int64(config, &timeout, + SVN_CONFIG_SECTION_WORKING_COPY, + SVN_CONFIG_OPTION_SQLITE_BUSY_TIMEOUT, + 0); + if (err || timeout < 0 || timeout > APR_INT32_MAX) + svn_error_clear(err); + else + (*db)->timeout = (apr_int32_t)timeout; } return SVN_NO_ERROR; @@ -236,8 +279,8 @@ svn_wc__db_close(svn_wc__db_t *db) hi; hi = apr_hash_next(hi)) { - svn_wc__db_wcroot_t *wcroot = svn__apr_hash_index_val(hi); - const char *local_abspath = svn__apr_hash_index_key(hi); + svn_wc__db_wcroot_t *wcroot = apr_hash_this_val(hi); + const char *local_abspath = apr_hash_this_key(hi); if (wcroot->sdb) svn_hash_sets(roots, wcroot->abspath, wcroot); @@ -258,7 +301,6 @@ svn_wc__db_pdh_create_wcroot(svn_wc__db_wcroot_t **wcroot, apr_int64_t wc_id, int format, svn_boolean_t verify_format, - svn_boolean_t enforce_empty_wq, apr_pool_t *result_pool, apr_pool_t *scratch_pool) { @@ -293,11 +335,11 @@ svn_wc__db_pdh_create_wcroot(svn_wc__db_wcroot_t **wcroot, } /* Verify that no work items exists. If they do, then our integrity is - suspect and, thus, we cannot use this database. */ - if (format >= SVN_WC__HAS_WORK_QUEUE - && (enforce_empty_wq || (format < SVN_WC__VERSION && verify_format))) + suspect and, thus, we cannot upgrade this database. */ + if (format >= SVN_WC__HAS_WORK_QUEUE && + format < SVN_WC__VERSION && verify_format) { - svn_error_t *err = verify_no_work(sdb); + svn_error_t *err = svn_wc__db_verify_no_work(sdb); if (err) { /* Special message for attempts to upgrade a 1.7-dev wc with @@ -354,7 +396,7 @@ svn_wc__db_close_many_wcroots(apr_hash_t *roots, for (hi = apr_hash_first(scratch_pool, roots); hi; hi = apr_hash_next(hi)) { - svn_wc__db_wcroot_t *wcroot = svn__apr_hash_index_val(hi); + svn_wc__db_wcroot_t *wcroot = apr_hash_this_val(hi); apr_status_t result; result = apr_pool_cleanup_run(state_pool, wcroot, close_wcroot); @@ -594,7 +636,7 @@ svn_wc__db_wcroot_parse_local_abspath(svn_wc__db_wcroot_t **wcroot, as the filesystem allows. */ err = svn_wc__db_util_open_db(&sdb, local_abspath, SDB_FILE, svn_sqlite__mode_readwrite, - db->exclusive, NULL, + db->exclusive, db->timeout, NULL, db->state_pool, scratch_pool); if (err == NULL) { @@ -711,11 +753,9 @@ try_symlink_as_dir: if (err) { if (err->apr_err == SVN_ERR_WC_CORRUPT) - return svn_error_quick_wrap( - err, apr_psprintf(scratch_pool, - _("Missing a row in WCROOT for '%s'."), - svn_dirent_local_style(original_abspath, - scratch_pool))); + return svn_error_quick_wrapf( + err, _("Missing a row in WCROOT for '%s'."), + svn_dirent_local_style(original_abspath, scratch_pool)); return svn_error_trace(err); } @@ -729,7 +769,7 @@ try_symlink_as_dir: ? symlink_wcroot_abspath : local_abspath), sdb, wc_id, format, - db->verify_format, db->enforce_empty_wq, + db->verify_format, db->state_pool, scratch_pool); if (err && (err->apr_err == SVN_ERR_WC_UNSUPPORTED_FORMAT || err->apr_err == SVN_ERR_WC_UPGRADE_REQUIRED) && @@ -804,7 +844,7 @@ try_symlink_as_dir: ? symlink_wcroot_abspath : local_abspath), NULL, UNKNOWN_WC_ID, wc_format, - db->verify_format, db->enforce_empty_wq, + db->verify_format, db->state_pool, scratch_pool)); } @@ -959,10 +999,10 @@ svn_wc__db_drop_root(svn_wc__db_t *db, hi; hi = apr_hash_next(hi)) { - svn_wc__db_wcroot_t *wcroot = svn__apr_hash_index_val(hi); + svn_wc__db_wcroot_t *wcroot = apr_hash_this_val(hi); if (wcroot == root_wcroot) - svn_hash_sets(db->dir_data, svn__apr_hash_index_key(hi), NULL); + svn_hash_sets(db->dir_data, apr_hash_this_key(hi), NULL); } result = apr_pool_cleanup_run(db->state_pool, root_wcroot, close_wcroot); |