From 8d2501e025e215bf6db0434519f0759105d8d12c Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 16 Apr 2007 22:52:58 +1000 Subject: merge local copy of tdb from samba4 tdb (This used to be ctdb commit d4619ce98ce44acaebeb6ae9c516a7917bf4e27f) --- ctdb/lib/tdb/common/open.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'ctdb/lib/tdb/common/open.c') 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) -- cgit