[SCM] Samba Shared Repository - branch master updated

Jeremy Allison jra at samba.org
Thu May 22 15:34:06 MDT 2014


The branch, master has been updated
       via  26b9155 selftest: use dbwrap_tdb_mutexes:* = yes for "plugin_s4_dc" and "member"
       via  41cf51b dbwrap_tdb: Use mutexes on demand
       via  85fe2e8 tdb/tools: Allow tdbtool to r/o open mutexed tdbs
       via  bd54fea tdb/tools: add -m option to tdbtorture
       via  b39e8ea tdb/test: add marklock deadlock test
       via  fbaf94b tdb/test: add mutex related tests
       via  db5bda5 tdb: add TDB_MUTEX_LOCKING support
       via  cbd73ba tdb: introduce tdb->hdr_ofs
       via  c29e64d tdb: introduce TDB_SUPPORTED_FEATURE_FLAGS
       via  c0b0648 tdb: use asprintf() to simplify tdb_summary()
       via  549338f libreplace: Define PTHREAD_MUTEX_ROBUST along with pthread_mutexattr_setrobust
       via  4baa2d0 libreplace-waf: Only check for _np functions if standard functions are not available
       via  4ea036c libreplace: Add support for pthread_mutex_consistent
       via  1993f60 libreplace: Add support for pthread_mutexattr_setrobust
       via  730745d libreplace: only add PTHREAD CFLAGS and LDFLAGS globally if asked for
       via  a8a9183 libreplace: Move thread checks from source3/wscript
       via  469e2fc wscript: set conf.env.replace_add_global_pthread = True
       via  1672643 tdb/test: add UNMAP command to external-agent.c
       via  1e74ba4 tdb/test: add PING command to external-agent.c
       via  1cb1b13 tdb/test: add shutdown_agent() helper function
       via  417489a tdb/test: add a "skip()" macro.
       via  19fb729 tdb/test: correctly use stderr, not stdout, in fail()
       via  9bf4f10 tdb/tools: explicitly use TDB_NOLOCK in tdbdump
       via  b4b8e39 tdb/tools: add -l option to tdbtool
       via  7815630 tdb/tools: add -l option to tdbbackup
      from  8935242 Add protocol version to smbstatus output

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 26b91558dfc260725ad6e074625644669453cfab
Author: Stefan Metzmacher <metze at samba.org>
Date:   Mon May 13 11:14:26 2013 +0200

    selftest: use dbwrap_tdb_mutexes:* = yes for "plugin_s4_dc" and "member"
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    
    Autobuild-User(master): Jeremy Allison <jra at samba.org>
    Autobuild-Date(master): Thu May 22 23:33:41 CEST 2014 on sn-devel-104

commit 41cf51b77459153d2bf5579025e42e221e179bc7
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Mar 19 12:02:22 2013 +0100

    dbwrap_tdb: Use mutexes on demand
    
    Pair-Programmed-With: Stefan Metzmacher <metze at samba.org>
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 85fe2e8e3be15370f961561882518aedf137de5f
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Nov 15 12:57:06 2013 +0100

    tdb/tools: Allow tdbtool to r/o open mutexed tdbs
    
    Pair-Programmed-With: Stefan Metzmacher <metze at samba.org>
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit bd54feab46d5dfd36c8a1729a46b59757ffe1e6a
Author: Volker Lendecke <vl at samba.org>
Date:   Thu Feb 21 16:34:32 2013 +0100

    tdb/tools: add -m option to tdbtorture
    
    This allows tdbtorture to run with mutexes.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit b39e8eac2036f5aaed848d3361596984cc913083
Author: Volker Lendecke <vl at samba.org>
Date:   Wed Jan 22 11:15:55 2014 +0100

    tdb/test: add marklock deadlock test
    
    Pair-Programmed-With: Stefan Metzmacher <metze at samba.org>
    Pair-Programmed-With: Michael Adam <obnox at samba.org>
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit fbaf94bb85c69f95f1fcd0b43b80d41eb01b55c3
Author: Volker Lendecke <vl at samba.org>
Date:   Thu Feb 21 16:34:32 2013 +0100

    tdb/test: add mutex related tests
    
    Pair-Programmed-With: Stefan Metzmacher <metze at samba.org>
    Pair-Programmed-With: Michael Adam <obnox at samba.org>
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit db5bda56bf089ec6052d92bb78f3b49f7c812e00
Author: Volker Lendecke <vl at samba.org>
Date:   Thu Feb 21 16:34:32 2013 +0100

    tdb: add TDB_MUTEX_LOCKING support
    
    This adds optional support for locking based on
    shared robust mutexes.
    
    The caller can use the TDB_MUTEX_LOCKING flag
    together with TDB_CLEAR_IF_FIRST after verifying
    with tdb_runtime_check_for_robust_mutexes() that
    it's supported by the current system.
    
    The caller should be aware that using TDB_MUTEX_LOCKING
    implies some limitations, e.g. it's not possible to
    have multiple read chainlocks on a given hash chain
    from multiple processes.
    
    Note: that this doesn't make tdb thread safe!
    
    Pair-Programmed-With: Stefan Metzmacher <metze at samba.org>
    Pair-Programmed-With: Michael Adam <obnox at samba.org>
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit cbd73ba1635c061fa71ff0476cbce087b389d1ad
Author: Volker Lendecke <vl at samba.org>
Date:   Thu Feb 21 16:34:32 2013 +0100

    tdb: introduce tdb->hdr_ofs
    
    This makes it possible to have some extra headers before
    the real tdb content starts in the file.
    
    This will be used used e.g. to implement locking based on robust mutexes.
    
    Pair-Programmed-With: Stefan Metzmacher <metze at samba.org>
    Pair-Programmed-With: Michael Adam <obnox at samba.org>
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit c29e64d97ee18e9d7946151052d1757084f861c6
Author: Stefan Metzmacher <metze at samba.org>
Date:   Tue Feb 4 23:35:53 2014 +0100

    tdb: introduce TDB_SUPPORTED_FEATURE_FLAGS
    
    This will allow to store a feature mask in the tdb header on disk,
    so that openers can check if they can handle the features
    other openers are using.
    
    Pair-Programmed-With: Volker Lendecke <vl at samba.org>
    Pair-Programmed-With: Michael Adam <obnox at samba.org>
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit c0b0648555cd6193a587da4810ac2b0543497ea8
Author: Stefan Metzmacher <metze at samba.org>
Date:   Tue May 13 03:15:41 2014 +0200

    tdb: use asprintf() to simplify tdb_summary()
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 549338ff38e8689666890348d678bec7e1b0fe5e
Author: Volker Lendecke <vl at samba.org>
Date:   Wed Feb 6 12:16:02 2013 +0100

    libreplace: Define PTHREAD_MUTEX_ROBUST along with pthread_mutexattr_setrobust
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 4baa2d021cb1be0ca19bad9da0f6300a95c9a722
Author: Volker Lendecke <vl at samba.org>
Date:   Wed Feb 6 12:15:41 2013 +0100

    libreplace-waf: Only check for _np functions if standard functions are not available
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 4ea036c26dd921c4fce18db3e54f551e9f856a07
Author: Volker Lendecke <vl at samba.org>
Date:   Mon Feb 4 12:26:47 2013 +0100

    libreplace: Add support for pthread_mutex_consistent
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 1993f605a4452087e49ae552dc85aa940e827e20
Author: Volker Lendecke <vl at samba.org>
Date:   Sat Dec 22 08:42:48 2012 +0100

    libreplace: Add support for pthread_mutexattr_setrobust
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 730745d560c70160a81e26c84c8bef82589b382f
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu May 16 11:50:38 2013 +0200

    libreplace: only add PTHREAD CFLAGS and LDFLAGS globally if asked for
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit a8a9183400a4463d5eb9aa1744573b8fac8eca5d
Author: Volker Lendecke <vl at samba.org>
Date:   Mon Jan 14 14:56:25 2013 +0100

    libreplace: Move thread checks from source3/wscript
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 469e2fc36cea3bdfcd1ce983737b9a6148397237
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu May 16 11:48:02 2013 +0200

    wscript: set conf.env.replace_add_global_pthread = True
    
    In Samba we currently add PTHREAD CFLAGS/LDFLAGS globally.
    The following changes will move the configure checks to
    lib/replace and the the default of adding the flags globally will change there.
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 1672643e4498c96d2b36d8bd608644c885e01138
Author: Volker Lendecke <vl at samba.org>
Date:   Thu Feb 21 16:34:32 2013 +0100

    tdb/test: add UNMAP command to external-agent.c
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 1e74ba47daccbcadb5f15288b5e929f7e8cefb95
Author: Volker Lendecke <vl at samba.org>
Date:   Thu Feb 21 16:34:32 2013 +0100

    tdb/test: add PING command to external-agent.c
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 1cb1b13cc954f2e40796a8db96f7ab9bf4fffc79
Author: Volker Lendecke <vl at samba.org>
Date:   Thu Feb 21 16:34:32 2013 +0100

    tdb/test: add shutdown_agent() helper function
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 417489a214757055ab95c98180c5ce960bdbe632
Author: Stefan Metzmacher <metze at samba.org>
Date:   Tue May 6 11:11:38 2014 +0200

    tdb/test: add a "skip()" macro.
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 19fb729188304e5817a694da9e5a4db5d1dfcb51
Author: Stefan Metzmacher <metze at samba.org>
Date:   Tue May 6 11:10:23 2014 +0200

    tdb/test: correctly use stderr, not stdout, in fail()
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 9bf4f10b4b326f2d2a1f8a40f0eb55a0c39c6689
Author: Volker Lendecke <vl at samba.org>
Date:   Thu Feb 21 16:34:32 2013 +0100

    tdb/tools: explicitly use TDB_NOLOCK in tdbdump
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit b4b8e393e5bde7989707b5a7c6cab1da7ae2c0d0
Author: Volker Lendecke <vl at samba.org>
Date:   Thu Feb 21 16:34:32 2013 +0100

    tdb/tools: add -l option to tdbtool
    
    This opens the tdb with TDB_NOLOCK.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 781563061dbf2b53bc6685cd2db7ace9ee35d280
Author: Volker Lendecke <vl at samba.org>
Date:   Thu Feb 21 16:34:32 2013 +0100

    tdb/tools: add -l option to tdbbackup
    
    This opens the tdb with TDB_NOLOCK.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

-----------------------------------------------------------------------

Summary of changes:
 lib/replace/system/threads.h               |   48 ++
 lib/replace/wscript                        |   63 ++
 lib/tdb/ABI/tdb-1.3.0.sigs                 |   68 ++
 lib/tdb/common/check.c                     |    4 +-
 lib/tdb/common/io.c                        |  102 +++-
 lib/tdb/common/lock.c                      |   79 ++-
 lib/tdb/common/mutex.c                     | 1000 ++++++++++++++++++++++++++++
 lib/tdb/common/open.c                      |  281 ++++++++-
 lib/tdb/common/summary.c                   |   39 +-
 lib/tdb/common/tdb.c                       |    9 +
 lib/tdb/common/tdb_private.h               |   34 +-
 lib/tdb/common/transaction.c               |    3 +-
 lib/tdb/docs/mutex.txt                     |  136 ++++
 lib/tdb/include/tdb.h                      |   34 +
 lib/tdb/man/tdbbackup.8.xml                |   12 +
 lib/tdb/man/tdbtool.8.xml                  |   21 +
 lib/tdb/test/external-agent.c              |   37 +-
 lib/tdb/test/external-agent.h              |    3 +
 lib/tdb/test/run-3G-file.c                 |    7 +-
 lib/tdb/test/run-bad-tdb-header.c          |    1 +
 lib/tdb/test/run-check.c                   |    1 +
 lib/tdb/test/run-corrupt.c                 |    1 +
 lib/tdb/test/run-die-during-transaction.c  |    1 +
 lib/tdb/test/run-endian.c                  |    1 +
 lib/tdb/test/run-incompatible.c            |    1 +
 lib/tdb/test/run-marklock-deadlock.c       |  278 ++++++++
 lib/tdb/test/run-mutex-allrecord-bench.c   |   82 +++
 lib/tdb/test/run-mutex-allrecord-block.c   |  120 ++++
 lib/tdb/test/run-mutex-allrecord-trylock.c |  113 ++++
 lib/tdb/test/run-mutex-die.c               |  269 ++++++++
 lib/tdb/test/run-mutex-openflags2.c        |  152 +++++
 lib/tdb/test/run-mutex-trylock.c           |  122 ++++
 lib/tdb/test/run-mutex1.c                  |  138 ++++
 lib/tdb/test/run-nested-transactions.c     |    1 +
 lib/tdb/test/run-nested-traverse.c         |    1 +
 lib/tdb/test/run-no-lock-during-traverse.c |    1 +
 lib/tdb/test/run-oldhash.c                 |    1 +
 lib/tdb/test/run-open-during-transaction.c |    1 +
 lib/tdb/test/run-readonly-check.c          |    1 +
 lib/tdb/test/run-rescue-find_entry.c       |    1 +
 lib/tdb/test/run-rescue.c                  |    1 +
 lib/tdb/test/run-rwlock-check.c            |    1 +
 lib/tdb/test/run-summary.c                 |    1 +
 lib/tdb/test/run-transaction-expand.c      |    1 +
 lib/tdb/test/run-traverse-in-transaction.c |    1 +
 lib/tdb/test/run-wronghash-fail.c          |    1 +
 lib/tdb/test/run-zero-append.c             |    1 +
 lib/tdb/test/run.c                         |    1 +
 lib/tdb/test/tap-interface.h               |    3 +-
 lib/tdb/tools/tdbbackup.c                  |   18 +-
 lib/tdb/tools/tdbdump.c                    |   10 +-
 lib/tdb/tools/tdbtool.c                    |   64 ++-
 lib/tdb/tools/tdbtorture.c                 |   29 +-
 lib/tdb/wscript                            |   46 ++-
 selftest/target/Samba3.pm                  |    1 +
 selftest/target/Samba4.pm                  |    2 +
 source3/lib/dbwrap/dbwrap_open.c           |   19 +
 source3/wscript                            |   32 -
 wscript                                    |    1 +
 59 files changed, 3382 insertions(+), 118 deletions(-)
 create mode 100644 lib/replace/system/threads.h
 create mode 100644 lib/tdb/ABI/tdb-1.3.0.sigs
 create mode 100644 lib/tdb/common/mutex.c
 create mode 100644 lib/tdb/docs/mutex.txt
 create mode 100644 lib/tdb/test/run-marklock-deadlock.c
 create mode 100644 lib/tdb/test/run-mutex-allrecord-bench.c
 create mode 100644 lib/tdb/test/run-mutex-allrecord-block.c
 create mode 100644 lib/tdb/test/run-mutex-allrecord-trylock.c
 create mode 100644 lib/tdb/test/run-mutex-die.c
 create mode 100644 lib/tdb/test/run-mutex-openflags2.c
 create mode 100644 lib/tdb/test/run-mutex-trylock.c
 create mode 100644 lib/tdb/test/run-mutex1.c


Changeset truncated at 500 lines:

diff --git a/lib/replace/system/threads.h b/lib/replace/system/threads.h
new file mode 100644
index 0000000..25d3502
--- /dev/null
+++ b/lib/replace/system/threads.h
@@ -0,0 +1,48 @@
+#ifndef _system_threads_h
+#define _system_threads_h
+/*
+   Unix SMB/CIFS implementation.
+
+   macros to go along with the lib/replace/ portability layer code
+
+   Copyright (C) Volker Lendecke 2012
+
+     ** NOTE! The following LGPL license applies to the replace
+     ** library. This does NOT imply that all of Samba is released
+     ** under the LGPL
+
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 3 of the License, or (at your option) any later version.
+
+   This library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with this library; if not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include <pthread.h>
+
+#if defined(HAVE_PTHREAD_MUTEXATTR_SETROBUST_NP) && \
+	!defined(HAVE_PTHREAD_MUTEXATTR_SETROBUST)
+
+#define pthread_mutexattr_setrobust pthread_mutexattr_setrobust_np
+
+/*
+ * We assume that PTHREAD_MUTEX_ROBUST_NP goes along with
+ * pthread_mutexattr_setrobust_np()
+ */
+#define PTHREAD_MUTEX_ROBUST PTHREAD_MUTEX_ROBUST_NP
+
+#endif
+
+#if defined(HAVE_PTHREAD_MUTEX_CONSISTENT_NP) && \
+	!defined(HAVE_PTHREAD_MUTEX_CONSISTENT)
+#define pthread_mutex_consistent pthread_mutex_consistent_np
+#endif
+
+#endif
diff --git a/lib/replace/wscript b/lib/replace/wscript
index fd5b386..a26de0f 100644
--- a/lib/replace/wscript
+++ b/lib/replace/wscript
@@ -422,6 +422,69 @@ removeea setea
 
     conf.CHECK_FUNCS_IN('pthread_create', 'pthread', checklibc=True, headers='pthread.h')
 
+    PTHREAD_CFLAGS='error'
+    PTHREAD_LDFLAGS='error'
+
+    if PTHREAD_LDFLAGS == 'error':
+        if conf.CHECK_FUNCS_IN('pthread_attr_init', 'pthread'):
+            PTHREAD_CFLAGS='-D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS'
+            PTHREAD_LDFLAGS='-lpthread'
+    if PTHREAD_LDFLAGS == 'error':
+        if conf.CHECK_FUNCS_IN('pthread_attr_init', 'pthreads'):
+            PTHREAD_CFLAGS='-D_THREAD_SAFE'
+            PTHREAD_LDFLAGS='-lpthreads'
+    if PTHREAD_LDFLAGS == 'error':
+        if conf.CHECK_FUNCS_IN('pthread_attr_init', 'c_r'):
+            PTHREAD_CFLAGS='-D_THREAD_SAFE -pthread'
+            PTHREAD_LDFLAGS='-pthread'
+    if PTHREAD_LDFLAGS == 'error':
+        if conf.CHECK_FUNCS('pthread_attr_init'):
+            PTHREAD_CFLAGS='-D_REENTRANT'
+            PTHREAD_LDFLAGS='-lpthread'
+    # especially for HP-UX, where the CHECK_FUNC macro fails to test for
+    # pthread_attr_init. On pthread_mutex_lock it works there...
+    if PTHREAD_LDFLAGS == 'error':
+        if conf.CHECK_FUNCS_IN('pthread_mutex_lock', 'pthread'):
+            PTHREAD_CFLAGS='-D_REENTRANT'
+            PTHREAD_LDFLAGS='-lpthread'
+
+    if PTHREAD_CFLAGS != 'error' and PTHREAD_LDFLAGS != 'error':
+        if conf.CONFIG_SET('replace_add_global_pthread'):
+            conf.ADD_CFLAGS(PTHREAD_CFLAGS)
+            conf.ADD_LDFLAGS(PTHREAD_LDFLAGS)
+        conf.CHECK_HEADERS('pthread.h')
+        conf.DEFINE('HAVE_PTHREAD', '1')
+
+    if conf.CONFIG_SET('HAVE_PTHREAD'):
+
+        conf.CHECK_DECLS('pthread_mutexattr_setrobust', headers='pthread.h')
+        if not conf.CONFIG_SET('HAVE_DECL_PTHREAD_MUTEXATTR_SETROBUST'):
+            conf.CHECK_DECLS('pthread_mutexattr_setrobust_np',
+                             headers='pthread.h')
+
+        conf.CHECK_FUNCS_IN('pthread_mutexattr_setrobust', 'pthread',
+                            checklibc=True, headers='pthread.h')
+        if not conf.CONFIG_SET('HAVE_PTHREAD_MUTEXATTR_SETROBUST'):
+            conf.CHECK_FUNCS_IN('pthread_mutexattr_setrobust_np', 'pthread',
+                                checklibc=True, headers='pthread.h')
+
+        conf.CHECK_DECLS('pthread_mutex_consistent', headers='pthread.h')
+        if not conf.CONFIG_SET('HAVE_DECL_PTHREAD_MUTEX_CONSISTENT'):
+            conf.CHECK_DECLS('pthread_mutex_consistent_np',
+                             headers='pthread.h')
+
+        conf.CHECK_FUNCS_IN('pthread_mutex_consistent', 'pthread',
+                            checklibc=True, headers='pthread.h')
+        if not conf.CONFIG_SET('HAVE_PTHREAD_MUTEX_CONSISTENT'):
+            conf.CHECK_FUNCS_IN('pthread_mutex_consistent_np', 'pthread',
+                                checklibc=True, headers='pthread.h')
+
+        if ((conf.CONFIG_SET('HAVE_PTHREAD_MUTEXATTR_SETROBUST') or
+             conf.CONFIG_SET('HAVE_PTHREAD_MUTEXATTR_SETROBUST_NP')) and
+            (conf.CONFIG_SET('HAVE_PTHREAD_MUTEX_CONSISTENT') or
+             conf.CONFIG_SET('HAVE_PTHREAD_MUTEX_CONSISTENT_NP'))):
+            conf.DEFINE('HAVE_ROBUST_MUTEXES', 1)
+
     conf.CHECK_FUNCS_IN('crypt', 'crypt', checklibc=True)
 
     conf.CHECK_VARIABLE('rl_event_hook', define='HAVE_DECL_RL_EVENT_HOOK', always=True,
diff --git a/lib/tdb/ABI/tdb-1.3.0.sigs b/lib/tdb/ABI/tdb-1.3.0.sigs
new file mode 100644
index 0000000..7d3e469
--- /dev/null
+++ b/lib/tdb/ABI/tdb-1.3.0.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/common/check.c b/lib/tdb/common/check.c
index 9f9d870..e632af5 100644
--- a/lib/tdb/common/check.c
+++ b/lib/tdb/common/check.c
@@ -39,7 +39,9 @@ static bool tdb_check_header(struct tdb_context *tdb, tdb_off_t *recovery)
 	if (hdr.version != TDB_VERSION)
 		goto corrupt;
 
-	if (hdr.rwlocks != 0 && hdr.rwlocks != TDB_HASH_RWLOCK_MAGIC)
+	if (hdr.rwlocks != 0 &&
+	    hdr.rwlocks != TDB_FEATURE_FLAG_MAGIC &&
+	    hdr.rwlocks != TDB_HASH_RWLOCK_MAGIC)
 		goto corrupt;
 
 	tdb_header_hash(tdb, &h1, &h2);
diff --git a/lib/tdb/common/io.c b/lib/tdb/common/io.c
index 11dfefd..fe47d18 100644
--- a/lib/tdb/common/io.c
+++ b/lib/tdb/common/io.c
@@ -28,6 +28,71 @@
 
 #include "tdb_private.h"
 
+/*
+ * We prepend the mutex area, so fixup offsets. See mutex.c for details.
+ * tdb->hdr_ofs is 0 or header.mutex_size.
+ *
+ * Note: that we only have the 4GB limit of tdb_off_t for
+ * tdb->map_size. The file size on disk can be 4GB + tdb->hdr_ofs!
+ */
+
+static bool tdb_adjust_offset(struct tdb_context *tdb, off_t *off)
+{
+	off_t tmp = tdb->hdr_ofs + *off;
+
+	if ((tmp < tdb->hdr_ofs) || (tmp < *off)) {
+		errno = EIO;
+		return false;
+	}
+
+	*off = tmp;
+	return true;
+}
+
+static ssize_t tdb_pwrite(struct tdb_context *tdb, const void *buf,
+			  size_t count, off_t offset)
+{
+	if (!tdb_adjust_offset(tdb, &offset)) {
+		return -1;
+	}
+	return pwrite(tdb->fd, buf, count, offset);
+}
+
+static ssize_t tdb_pread(struct tdb_context *tdb, void *buf,
+			 size_t count, off_t offset)
+{
+	if (!tdb_adjust_offset(tdb, &offset)) {
+		return -1;
+	}
+	return pread(tdb->fd, buf, count, offset);
+}
+
+static int tdb_ftruncate(struct tdb_context *tdb, off_t length)
+{
+	if (!tdb_adjust_offset(tdb, &length)) {
+		return -1;
+	}
+	return ftruncate(tdb->fd, length);
+}
+
+static int tdb_fstat(struct tdb_context *tdb, struct stat *buf)
+{
+	int ret;
+
+	ret = fstat(tdb->fd, buf);
+	if (ret == -1) {
+		return -1;
+	}
+
+	if (buf->st_size < tdb->hdr_ofs) {
+		errno = EIO;
+		return -1;
+	}
+	buf->st_size -= tdb->hdr_ofs;
+
+	return ret;
+}
+
 /* check for an out of bounds access - if it is out of bounds then
    see if the database has been expanded by someone else and expand
    if necessary
@@ -58,7 +123,7 @@ static int tdb_oob(struct tdb_context *tdb, tdb_off_t off, tdb_len_t len,
 		return -1;
 	}
 
-	if (fstat(tdb->fd, &st) == -1) {
+	if (tdb_fstat(tdb, &st) == -1) {
 		tdb->ecode = TDB_ERR_IO;
 		return -1;
 	}
@@ -122,16 +187,18 @@ static int tdb_write(struct tdb_context *tdb, tdb_off_t off,
 		tdb->ecode = TDB_ERR_IO;
 		return -1;
 #else
-		ssize_t written = pwrite(tdb->fd, buf, len, off);
+		ssize_t written;
+
+		written = tdb_pwrite(tdb, buf, len, off);
+
 		if ((written != (ssize_t)len) && (written != -1)) {
 			/* try once more */
 			tdb->ecode = TDB_ERR_IO;
 			TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_write: wrote only "
 				 "%zi of %u bytes at %u, trying once more\n",
 				 written, len, off));
-			written = pwrite(tdb->fd, (const char *)buf+written,
-					 len-written,
-					 off+written);
+			written = tdb_pwrite(tdb, (const char *)buf+written,
+					     len-written, off+written);
 		}
 		if (written == -1) {
 			/* Ensure ecode is set for log fn. */
@@ -176,7 +243,9 @@ static int tdb_read(struct tdb_context *tdb, tdb_off_t off, void *buf,
 		tdb->ecode = TDB_ERR_IO;
 		return -1;
 #else
-		ssize_t ret = pread(tdb->fd, buf, len, off);
+		ssize_t ret;
+
+		ret = tdb_pread(tdb, buf, len, off);
 		if (ret != (ssize_t)len) {
 			/* Ensure ecode is set for log fn. */
 			tdb->ecode = TDB_ERR_IO;
@@ -258,7 +327,8 @@ int tdb_mmap(struct tdb_context *tdb)
 	if (should_mmap(tdb)) {
 		tdb->map_ptr = mmap(NULL, tdb->map_size,
 				    PROT_READ|(tdb->read_only? 0:PROT_WRITE),
-				    MAP_SHARED|MAP_FILE, tdb->fd, 0);
+				    MAP_SHARED|MAP_FILE, tdb->fd,
+				    tdb->hdr_ofs);
 
 		/*
 		 * NB. When mmap fails it returns MAP_FAILED *NOT* NULL !!!!
@@ -303,12 +373,12 @@ static int tdb_expand_file(struct tdb_context *tdb, tdb_off_t size, tdb_off_t ad
 		return -1;
 	}
 
-	if (ftruncate(tdb->fd, new_size) == -1) {
+	if (tdb_ftruncate(tdb, new_size) == -1) {
 		char b = 0;
-		ssize_t written = pwrite(tdb->fd,  &b, 1, new_size - 1);
+		ssize_t written = tdb_pwrite(tdb, &b, 1, new_size - 1);
 		if (written == 0) {
 			/* try once more, potentially revealing errno */
-			written = pwrite(tdb->fd,  &b, 1, new_size - 1);
+			written = tdb_pwrite(tdb, &b, 1, new_size - 1);
 		}
 		if (written == 0) {
 			/* again - give up, guessing errno */
@@ -328,10 +398,10 @@ static int tdb_expand_file(struct tdb_context *tdb, tdb_off_t size, tdb_off_t ad
 	memset(buf, TDB_PAD_BYTE, sizeof(buf));
 	while (addition) {
 		size_t n = addition>sizeof(buf)?sizeof(buf):addition;
-		ssize_t written = pwrite(tdb->fd, buf, n, size);
+		ssize_t written = tdb_pwrite(tdb, buf, n, size);
 		if (written == 0) {
 			/* prevent infinite loops: try _once_ more */
-			written = pwrite(tdb->fd, buf, n, size);
+			written = tdb_pwrite(tdb, buf, n, size);
 		}
 		if (written == 0) {
 			/* give up, trying to provide a useful errno */
@@ -437,6 +507,14 @@ int tdb_expand(struct tdb_context *tdb, tdb_off_t size)
 	/* must know about any previous expansions by another process */
 	tdb->methods->tdb_oob(tdb, tdb->map_size, 1, 1);
 
+	/*
+	 * Note: that we don't care about tdb->hdr_ofs != 0 here
+	 *
+	 * The 4GB limitation is just related to tdb->map_size
+	 * and the offset calculation in the records.
+	 *
+	 * The file on disk can be up to 4GB + tdb->hdr_ofs
+	 */
 	size = tdb_expand_adjust(tdb->map_size, size, tdb->page_size);
 
 	if (!tdb_add_off_t(tdb->map_size, size, &new_size)) {
diff --git a/lib/tdb/common/lock.c b/lib/tdb/common/lock.c
index 486de79..6644c40 100644
--- a/lib/tdb/common/lock.c
+++ b/lib/tdb/common/lock.c
@@ -38,6 +38,15 @@ static int fcntl_lock(struct tdb_context *tdb,
 	struct flock fl;
 	int cmd;
 
+#ifdef USE_TDB_MUTEX_LOCKING
+	{
+		int ret;
+		if (tdb_mutex_lock(tdb, rw, off, len, waitflag, &ret)) {
+			return ret;
+		}
+	}
+#endif
+
 	fl.l_type = rw;
 	fl.l_whence = SEEK_SET;
 	fl.l_start = off;
@@ -110,6 +119,15 @@ static int fcntl_unlock(struct tdb_context *tdb, int rw, off_t off, off_t len)
 	fclose(locks);
 #endif
 
+#ifdef USE_TDB_MUTEX_LOCKING
+	{
+		int ret;
+		if (tdb_mutex_unlock(tdb, rw, off, len, &ret)) {
+			return ret;
+		}
+	}
+#endif
+
 	fl.l_type = F_UNLCK;
 	fl.l_whence = SEEK_SET;
 	fl.l_start = off;
@@ -248,13 +266,27 @@ int tdb_allrecord_upgrade(struct tdb_context *tdb)
 		return -1;
 	}
 
-	ret = tdb_brlock_retry(tdb, F_WRLCK, FREELIST_TOP, 0,
-			       TDB_LOCK_WAIT|TDB_LOCK_PROBE);
+	if (tdb_have_mutexes(tdb)) {
+		ret = tdb_mutex_allrecord_upgrade(tdb);
+		if (ret == -1) {
+			goto fail;
+		}
+		ret = tdb_brlock_retry(tdb, F_WRLCK, lock_offset(tdb->hash_size),
+				       0, TDB_LOCK_WAIT|TDB_LOCK_PROBE);
+		if (ret == -1) {
+			tdb_mutex_allrecord_downgrade(tdb);
+		}
+	} else {
+		ret = tdb_brlock_retry(tdb, F_WRLCK, FREELIST_TOP, 0,
+				       TDB_LOCK_WAIT|TDB_LOCK_PROBE);
+	}
+
 	if (ret == 0) {
 		tdb->allrecord_lock.ltype = F_WRLCK;
 		tdb->allrecord_lock.off = 0;
 		return 0;
 	}
+fail:
 	TDB_LOG((tdb, TDB_DEBUG_TRACE,"tdb_allrecord_upgrade failed\n"));
 	return -1;
 }
@@ -593,6 +625,8 @@ static int tdb_chainlock_gradual(struct tdb_context *tdb,
 int tdb_allrecord_lock(struct tdb_context *tdb, int ltype,
 		       enum tdb_lock_flags flags, bool upgradable)
 {
+	int ret;
+
 	switch (tdb_allrecord_check(tdb, ltype, flags, upgradable)) {
 	case -1:
 		return -1;
@@ -607,16 +641,27 @@ int tdb_allrecord_lock(struct tdb_context *tdb, int ltype,
 	 *
 	 * It is (1) which cause the starvation problem, so we're only
 	 * gradual for that. */
-	if (tdb_chainlock_gradual(tdb, ltype, flags, FREELIST_TOP,
-				  tdb->hash_size * 4) == -1) {
+
+	if (tdb_have_mutexes(tdb)) {
+		ret = tdb_mutex_allrecord_lock(tdb, ltype, flags);
+	} else {
+		ret = tdb_chainlock_gradual(tdb, ltype, flags, FREELIST_TOP,
+					    tdb->hash_size * 4);
+	}
+
+	if (ret == -1) {
 		return -1;
 	}
 
 	/* Grab individual record locks. */
 	if (tdb_brlock(tdb, ltype, lock_offset(tdb->hash_size), 0,
 		       flags) == -1) {
-		tdb_brunlock(tdb, ltype, FREELIST_TOP,
-			     tdb->hash_size * 4);
+		if (tdb_have_mutexes(tdb)) {
+			tdb_mutex_allrecord_unlock(tdb);
+		} else {
+			tdb_brunlock(tdb, ltype, FREELIST_TOP,
+				     tdb->hash_size * 4);
+		}
 		return -1;
 	}
 
@@ -672,9 +717,25 @@ int tdb_allrecord_unlock(struct tdb_context *tdb, int ltype, bool mark_lock)
 		return 0;
 	}


-- 
Samba Shared Repository


More information about the samba-cvs mailing list