Alien-SVN
view release on metacpan or search on metacpan
src/subversion/subversion/libsvn_fs_base/bdb/env.c view on Meta::CPAN
and passes the same error prefix (char *) pointer given to
set_errpfx(). The bdb_error_gatherer() callback casts the
(char *) it back to a (bdb_env_t *).
To avoid problems should BDB ever try to interpret our baton as a
string, the first field in the structure is a char
errpfx_string[]. Initializers of this structure must strcpy the
value of BDB_ERRPFX_STRING into this array. */
char errpfx_string[sizeof(BDB_ERRPFX_STRING)];
/* Extended error information. */
#if APR_HAS_THREADS
apr_threadkey_t *error_info; /* Points to a bdb_error_info_t. */
#else
bdb_error_info_t error_info;
#endif
/**************************************************************************/
/* BDB Environment Cache */
/* The Berkeley DB environment. */
DB_ENV *env;
/* The flags with which this environment was opened. Reopening the
environment with a different set of flags is not allowed. Trying
to change the state of the DB_PRIVATE flag is an especially bad
idea, so svn_fs_bdb__open() forbids any flag changes. */
u_int32_t flags;
/* The home path of this environment; a canonical SVN path encoded in
UTF-8 and allocated from this decriptor's pool. */
const char *path;
/* The home path of this environment, in the form expected by BDB. */
const char *path_bdb;
/* The reference count for this environment handle; this is
essentially the difference between the number of calls to
svn_fs_bdb__open and svn_fs_bdb__close. */
unsigned refcount;
/* If this flag is TRUE, someone has detected that the environment
descriptor is in a panicked state and should be removed from the
cache.
Note 1: Once this flag is set, it must not be cleared again.
Note 2: Unlike other fields in this structure, this field is not
protected by the cache mutex on threaded platforms, and
should only be accesses via the svn_atomic functions. */
volatile svn_atomic_t panic;
/* The key for the environment descriptor cache. */
bdb_env_key_t key;
/* The handle of the open DB_CONFIG file.
We keep the DB_CONFIG file open in this process as long as the
environment handle itself is open. On Windows, this guarantees
that the cache key remains unique; here's what the Windows SDK
docs have to say about the file index (interpreted as the INODE
number by APR):
"This value is useful only while the file is open by at least
one process. If no processes have it open, the index may
change the next time the file is opened."
Now, we certainly don't want a unique key to change while it's
being used, do we... */
apr_file_t *dbconfig_file;
/* The pool associated with this environment descriptor.
Because the descriptor has a life of its own, the structure and
any data associated with it are allocated from their own global
pool. */
apr_pool_t *pool;
};
#if APR_HAS_THREADS
/* Get the thread-specific error info from a bdb_env_t. */
static bdb_error_info_t *
get_error_info(const bdb_env_t *bdb)
{
void *priv;
apr_threadkey_private_get(&priv, bdb->error_info);
if (!priv)
{
priv = calloc(1, sizeof(bdb_error_info_t));
apr_threadkey_private_set(priv, bdb->error_info);
}
return priv;
}
#else
#define get_error_info(bdb) (&(bdb)->error_info)
#endif /* APR_HAS_THREADS */
/* Convert a BDB error to a Subversion error. */
static svn_error_t *
convert_bdb_error(bdb_env_t *bdb, int db_err)
{
if (db_err)
{
bdb_env_baton_t bdb_baton;
bdb_baton.env = bdb->env;
bdb_baton.bdb = bdb;
bdb_baton.error_info = get_error_info(bdb);
SVN_BDB_ERR(&bdb_baton, db_err);
}
return SVN_NO_ERROR;
}
/* Allocating an appropriate Berkeley DB environment object. */
/* BDB error callback. See bdb_error_info_t in env.h for more info.
Note: bdb_error_gatherer is a macro with BDB < 4.3, so be careful how
you use it! */
( run in 0.557 second using v1.01-cache-2.11-cpan-483215c6ad5 )