summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorVolker Lendecke <vlendec@samba.org>2006-04-17 11:42:59 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:04:09 -0500
commitfce0dcf2450f68fdc201152bdd063569bdcf1770 (patch)
tree66b5f21dfe9f79d0531eb68690516712638fadba /source4
parent573b2f75fbc1de1572ac885804a94ff8ae7d499a (diff)
downloadsamba-fce0dcf2450f68fdc201152bdd063569bdcf1770.tar.gz
samba-fce0dcf2450f68fdc201152bdd063569bdcf1770.tar.bz2
samba-fce0dcf2450f68fdc201152bdd063569bdcf1770.zip
r15100: Port the bugfix for #3569 to Samba4
(This used to be commit 5f1d52f232051324082b840f29dd7719a9328bd5)
Diffstat (limited to 'source4')
-rw-r--r--source4/lib/tdb/common/open.c18
-rw-r--r--source4/lib/tdb/include/tdb.h2
-rw-r--r--source4/lib/tdb/tools/tdbtorture.c2
-rw-r--r--source4/smbd/process_standard.c4
4 files changed, 21 insertions, 5 deletions
diff --git a/source4/lib/tdb/common/open.c b/source4/lib/tdb/common/open.c
index 7ebc067175..cb4a9cd994 100644
--- a/source4/lib/tdb/common/open.c
+++ b/source4/lib/tdb/common/open.c
@@ -424,11 +424,27 @@ fail:
}
/* reopen all tdb's */
-int tdb_reopen_all(void)
+int tdb_reopen_all(int parent_longlived)
{
struct tdb_context *tdb;
for (tdb=tdbs; tdb; tdb = tdb->next) {
+ /*
+ * If the parent is longlived (ie. a
+ * parent daemon architecture), we know
+ * it will keep it's active lock on a
+ * tdb opened with CLEAR_IF_FIRST. Thus
+ * for child processes we don't have to
+ * add an active lock. This is essential
+ * to improve performance on systems that
+ * keep POSIX locks as a non-scalable data
+ * structure in the kernel.
+ */
+ if (parent_longlived) {
+ /* Ensure no clear-if-first. */
+ tdb->flags &= ~TDB_CLEAR_IF_FIRST;
+ }
+
if (tdb_reopen(tdb) != 0)
return -1;
}
diff --git a/source4/lib/tdb/include/tdb.h b/source4/lib/tdb/include/tdb.h
index ddde17850b..4004c73460 100644
--- a/source4/lib/tdb/include/tdb.h
+++ b/source4/lib/tdb/include/tdb.h
@@ -87,7 +87,7 @@ struct tdb_context *tdb_open_ex(const char *name, int hash_size, int tdb_flags,
tdb_hash_func hash_fn);
int tdb_reopen(struct tdb_context *tdb);
-int tdb_reopen_all(void);
+int tdb_reopen_all(int parent_longlived);
void tdb_logging_function(struct tdb_context *tdb, tdb_log_func);
enum TDB_ERROR tdb_error(struct tdb_context *tdb);
const char *tdb_errorstr(struct tdb_context *tdb);
diff --git a/source4/lib/tdb/tools/tdbtorture.c b/source4/lib/tdb/tools/tdbtorture.c
index 840397b73b..ac09898696 100644
--- a/source4/lib/tdb/tools/tdbtorture.c
+++ b/source4/lib/tdb/tools/tdbtorture.c
@@ -149,7 +149,7 @@ static void addrec_db(void)
#if REOPEN_PROB
if (in_transaction == 0 && random() % REOPEN_PROB == 0) {
- tdb_reopen_all();
+ tdb_reopen_all(0);
goto next;
}
#endif
diff --git a/source4/smbd/process_standard.c b/source4/smbd/process_standard.c
index 3708d034e1..e1affbbf89 100644
--- a/source4/smbd/process_standard.c
+++ b/source4/smbd/process_standard.c
@@ -105,7 +105,7 @@ static void standard_accept_connection(struct event_context *ev,
socket_dup(sock2);
/* tdb needs special fork handling */
- if (tdb_reopen_all() == -1) {
+ if (tdb_reopen_all(1) == -1) {
DEBUG(0,("standard_accept_connection: tdb_reopen_all failed.\n"));
}
@@ -169,7 +169,7 @@ static void standard_new_task(struct event_context *ev,
talloc_free(ev);
/* tdb needs special fork handling */
- if (tdb_reopen_all() == -1) {
+ if (tdb_reopen_all(1) == -1) {
DEBUG(0,("standard_accept_connection: tdb_reopen_all failed.\n"));
}