From ac23eaea4dea2a7ba9e41c5636c1d672e52edb45 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 4 Nov 2014 09:51:51 +0100 Subject: [PATCH 1/3] tdb: allow tdb_open_ex() with O_RDONLY of TDB_FEATURE_FLAG_MUTEX tdbs. Bug: https://bugzilla.samba.org/show_bug.cgi?id=10781 Signed-off-by: Stefan Metzmacher Reviewed-by: Michael Adam (cherry picked from commit c8d05e934ea03fffbc34944d2d51a016b89a7eca) --- lib/tdb/common/open.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/tdb/common/open.c b/lib/tdb/common/open.c index 16a76a3..3b53fa7 100644 --- a/lib/tdb/common/open.c +++ b/lib/tdb/common/open.c @@ -232,6 +232,14 @@ static bool tdb_mutex_open_ok(struct tdb_context *tdb, { int locked; + if (tdb->flags & TDB_NOLOCK) { + /* + * We don't look at locks, so it does not matter to have a + * compatible mutex implementation. Allow the open. + */ + return true; + } + locked = tdb_nest_lock(tdb, ACTIVE_LOCK, F_WRLCK, TDB_LOCK_NOWAIT|TDB_LOCK_PROBE); @@ -261,14 +269,6 @@ static bool tdb_mutex_open_ok(struct tdb_context *tdb, return false; } - if (tdb->flags & TDB_NOLOCK) { - /* - * We don't look at locks, so it does not matter to have a - * compatible mutex implementation. Allow the open. - */ - return true; - } - check_local_settings: if (!(tdb->flags & TDB_MUTEX_LOCKING)) { @@ -399,7 +399,7 @@ _PUBLIC_ struct tdb_context *tdb_open_ex(const char *name, int hash_size, int td tdb->read_only = 1; /* read only databases don't do locking or clear if first */ tdb->flags |= TDB_NOLOCK; - tdb->flags &= ~TDB_CLEAR_IF_FIRST; + tdb->flags &= ~(TDB_CLEAR_IF_FIRST|TDB_MUTEX_LOCKING); } if ((tdb->flags & TDB_ALLOW_NESTING) && -- 1.9.1 From 22a1836babaebd49b83db4a5636a5505d10bd1b3 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Wed, 26 Nov 2014 15:35:19 +0000 Subject: [PATCH 2/3] tdb: Fix tdb_runtime_check_for_robust_mutexes() When using exit() instead of _exit(), the child will flush buffered stdout (and other stdio) content that it inherited from the parent process. In make test, this led to duplicate output from net registry which then confused the blackbox selftest. Signed-off-by: Volker Lendecke Reviewed-by: Stefan Metzmacher (cherry picked from commit 42b2e5ca8c9b85e6fce71529bef5d6b3ba4f4a38) --- lib/tdb/common/mutex.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/tdb/common/mutex.c b/lib/tdb/common/mutex.c index bdc4c28..12f89d3 100644 --- a/lib/tdb/common/mutex.c +++ b/lib/tdb/common/mutex.c @@ -814,17 +814,17 @@ _PUBLIC_ bool tdb_runtime_check_for_robust_mutexes(void) ret = pthread_mutex_lock(m); nwritten = write(pipe_up[1], &ret, sizeof(ret)); if (nwritten != sizeof(ret)) { - exit(1); + _exit(1); } if (ret != 0) { - exit(1); + _exit(1); } nread = read(pipe_down[0], &c, 1); if (nread != 1) { - exit(1); + _exit(1); } /* leave locked */ - exit(0); + _exit(0); } if (tdb_robust_mutex_pid == -1) { goto cleanup_sig_child; -- 1.9.1 From ffea77d0b754c8b68c69aef6d89eb75f1210280a Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sat, 29 Nov 2014 11:37:54 +0100 Subject: [PATCH 3/3] tdb: version 1.3.2 The following bugs are fixed with this release: - Bug 10625 - tdb.h missing include of stdbool.h - Bug 10781 - smbstatus: locking.tdb - TDB_MUTEX_LOCKING requires TDB_CLEAR_IF_FIRST - Bug 10968 - tdb mutex runtime test clobbers stdout Bug: https://bugzilla.samba.org/show_bug.cgi?id=10625 Bug: https://bugzilla.samba.org/show_bug.cgi?id=10781 Bug: https://bugzilla.samba.org/show_bug.cgi?id=10968 Signed-off-by: Stefan Metzmacher Reviewed-by: Volker Lendecke (cherry picked from commit e6c766848c5f5f13584f3bc4c1670c76e7ff8472) --- lib/tdb/ABI/tdb-1.3.2.sigs | 68 ++++++++++++++++++++++++++++++++++++++++++++++ lib/tdb/wscript | 2 +- 2 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 lib/tdb/ABI/tdb-1.3.2.sigs diff --git a/lib/tdb/ABI/tdb-1.3.2.sigs b/lib/tdb/ABI/tdb-1.3.2.sigs new file mode 100644 index 0000000..7d3e469 --- /dev/null +++ b/lib/tdb/ABI/tdb-1.3.2.sigs @@ -0,0 +1,68 @@ +tdb_add_flags: void (struct tdb_context *, unsigned int) +tdb_append: int (struct tdb_context *, TDB_DATA, TDB_DATA) +tdb_chainlock: int (struct tdb_context *, TDB_DATA) +tdb_chainlock_mark: int (struct tdb_context *, TDB_DATA) +tdb_chainlock_nonblock: int (struct tdb_context *, TDB_DATA) +tdb_chainlock_read: int (struct tdb_context *, TDB_DATA) +tdb_chainlock_unmark: int (struct tdb_context *, TDB_DATA) +tdb_chainunlock: int (struct tdb_context *, TDB_DATA) +tdb_chainunlock_read: int (struct tdb_context *, TDB_DATA) +tdb_check: int (struct tdb_context *, int (*)(TDB_DATA, TDB_DATA, void *), void *) +tdb_close: int (struct tdb_context *) +tdb_delete: int (struct tdb_context *, TDB_DATA) +tdb_dump_all: void (struct tdb_context *) +tdb_enable_seqnum: void (struct tdb_context *) +tdb_error: enum TDB_ERROR (struct tdb_context *) +tdb_errorstr: const char *(struct tdb_context *) +tdb_exists: int (struct tdb_context *, TDB_DATA) +tdb_fd: int (struct tdb_context *) +tdb_fetch: TDB_DATA (struct tdb_context *, TDB_DATA) +tdb_firstkey: TDB_DATA (struct tdb_context *) +tdb_freelist_size: int (struct tdb_context *) +tdb_get_flags: int (struct tdb_context *) +tdb_get_logging_private: void *(struct tdb_context *) +tdb_get_seqnum: int (struct tdb_context *) +tdb_hash_size: int (struct tdb_context *) +tdb_increment_seqnum_nonblock: void (struct tdb_context *) +tdb_jenkins_hash: unsigned int (TDB_DATA *) +tdb_lock_nonblock: int (struct tdb_context *, int, int) +tdb_lockall: int (struct tdb_context *) +tdb_lockall_mark: int (struct tdb_context *) +tdb_lockall_nonblock: int (struct tdb_context *) +tdb_lockall_read: int (struct tdb_context *) +tdb_lockall_read_nonblock: int (struct tdb_context *) +tdb_lockall_unmark: int (struct tdb_context *) +tdb_log_fn: tdb_log_func (struct tdb_context *) +tdb_map_size: size_t (struct tdb_context *) +tdb_name: const char *(struct tdb_context *) +tdb_nextkey: TDB_DATA (struct tdb_context *, TDB_DATA) +tdb_null: dptr = 0xXXXX, dsize = 0 +tdb_open: struct tdb_context *(const char *, int, int, int, mode_t) +tdb_open_ex: struct tdb_context *(const char *, int, int, int, mode_t, const struct tdb_logging_context *, tdb_hash_func) +tdb_parse_record: int (struct tdb_context *, TDB_DATA, int (*)(TDB_DATA, TDB_DATA, void *), void *) +tdb_printfreelist: int (struct tdb_context *) +tdb_remove_flags: void (struct tdb_context *, unsigned int) +tdb_reopen: int (struct tdb_context *) +tdb_reopen_all: int (int) +tdb_repack: int (struct tdb_context *) +tdb_rescue: int (struct tdb_context *, void (*)(TDB_DATA, TDB_DATA, void *), void *) +tdb_runtime_check_for_robust_mutexes: bool (void) +tdb_set_logging_function: void (struct tdb_context *, const struct tdb_logging_context *) +tdb_set_max_dead: void (struct tdb_context *, int) +tdb_setalarm_sigptr: void (struct tdb_context *, volatile sig_atomic_t *) +tdb_store: int (struct tdb_context *, TDB_DATA, TDB_DATA, int) +tdb_summary: char *(struct tdb_context *) +tdb_transaction_cancel: int (struct tdb_context *) +tdb_transaction_commit: int (struct tdb_context *) +tdb_transaction_prepare_commit: int (struct tdb_context *) +tdb_transaction_start: int (struct tdb_context *) +tdb_transaction_start_nonblock: int (struct tdb_context *) +tdb_transaction_write_lock_mark: int (struct tdb_context *) +tdb_transaction_write_lock_unmark: int (struct tdb_context *) +tdb_traverse: int (struct tdb_context *, tdb_traverse_func, void *) +tdb_traverse_read: int (struct tdb_context *, tdb_traverse_func, void *) +tdb_unlock: int (struct tdb_context *, int, int) +tdb_unlockall: int (struct tdb_context *) +tdb_unlockall_read: int (struct tdb_context *) +tdb_validate_freelist: int (struct tdb_context *, int *) +tdb_wipe_all: int (struct tdb_context *) diff --git a/lib/tdb/wscript b/lib/tdb/wscript index dbbcaf3..99433e8 100644 --- a/lib/tdb/wscript +++ b/lib/tdb/wscript @@ -1,7 +1,7 @@ #!/usr/bin/env python APPNAME = 'tdb' -VERSION = '1.3.1' +VERSION = '1.3.2' blddir = 'bin' -- 1.9.1