diff options
author | Andrew Tridgell <tridge@samba.org> | 2007-04-16 22:52:58 +1000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2007-04-16 22:52:58 +1000 |
commit | 8d2501e025e215bf6db0434519f0759105d8d12c (patch) | |
tree | ec7f0c2fcc10b29ad02f2e7d373d88acda0e6b33 /ctdb/lib/tdb/common/open.c | |
parent | b3ed006ef490cd09361abad49bbca95cc46dfbc2 (diff) | |
download | samba-8d2501e025e215bf6db0434519f0759105d8d12c.tar.gz samba-8d2501e025e215bf6db0434519f0759105d8d12c.tar.xz samba-8d2501e025e215bf6db0434519f0759105d8d12c.zip |
merge local copy of tdb from samba4 tdb
(This used to be ctdb commit d4619ce98ce44acaebeb6ae9c516a7917bf4e27f)
Diffstat (limited to 'ctdb/lib/tdb/common/open.c')
-rw-r--r-- | ctdb/lib/tdb/common/open.c | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/ctdb/lib/tdb/common/open.c b/ctdb/lib/tdb/common/open.c index e1f21aa8560..c7fd3f66564 100644 --- a/ctdb/lib/tdb/common/open.c +++ b/ctdb/lib/tdb/common/open.c @@ -263,15 +263,7 @@ struct tdb_context *tdb_open_ex(const char *name, int hash_size, int tdb_flags, tdb->map_size = st.st_size; tdb->device = st.st_dev; tdb->inode = st.st_ino; - tdb->locked = (struct tdb_lock_type *)calloc(tdb->header.hash_size+1, - sizeof(tdb->locked[0])); - if (!tdb->locked) { - TDB_LOG((tdb, TDB_DEBUG_ERROR, "tdb_open_ex: " - "failed to allocate lock structure for %s\n", - name)); - errno = ENOMEM; - goto fail; - } + tdb->max_dead_records = 0; tdb_mmap(tdb); if (locked) { if (tdb->methods->tdb_brlock(tdb, ACTIVE_LOCK, F_UNLCK, F_SETLK, 0, 1) == -1) { @@ -324,13 +316,21 @@ struct tdb_context *tdb_open_ex(const char *name, int hash_size, int tdb_flags, if (tdb->fd != -1) if (close(tdb->fd) != 0) TDB_LOG((tdb, TDB_DEBUG_ERROR, "tdb_open_ex: failed to close tdb->fd on error!\n")); - SAFE_FREE(tdb->locked); SAFE_FREE(tdb); errno = save_errno; return NULL; } } +/* + * Set the maximum number of dead records per hash chain + */ + +void tdb_set_max_dead(struct tdb_context *tdb, int max_dead) +{ + tdb->max_dead_records = max_dead; +} + /** * Close a database. * @@ -354,7 +354,7 @@ int tdb_close(struct tdb_context *tdb) SAFE_FREE(tdb->name); if (tdb->fd != -1) ret = close(tdb->fd); - SAFE_FREE(tdb->locked); + SAFE_FREE(tdb->lockrecs); /* Remove from contexts list */ for (i = &tdbs; *i; i = &(*i)->next) { @@ -372,9 +372,9 @@ int tdb_close(struct tdb_context *tdb) /* register a loging function */ void tdb_set_logging_function(struct tdb_context *tdb, - const struct tdb_logging_context *log) + const struct tdb_logging_context *log_ctx) { - tdb->log = *log; + tdb->log = *log_ctx; } void *tdb_get_logging_private(struct tdb_context *tdb) |