Author: vlendec
Date: 2006-04-17 11:42:59 +0000 (Mon, 17 Apr 2006)
New Revision: 15100

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=15100

Log:
Port the bugfix for #3569 to Samba4
Modified:
   branches/SAMBA_4_0/source/lib/tdb/common/open.c
   branches/SAMBA_4_0/source/lib/tdb/include/tdb.h
   branches/SAMBA_4_0/source/lib/tdb/tools/tdbtorture.c
   branches/SAMBA_4_0/source/smbd/process_standard.c


Changeset:
Modified: branches/SAMBA_4_0/source/lib/tdb/common/open.c
===================================================================
--- branches/SAMBA_4_0/source/lib/tdb/common/open.c     2006-04-17 07:04:56 UTC 
(rev 15099)
+++ branches/SAMBA_4_0/source/lib/tdb/common/open.c     2006-04-17 11:42:59 UTC 
(rev 15100)
@@ -424,11 +424,27 @@
 }
 
 /* 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;
        }

Modified: branches/SAMBA_4_0/source/lib/tdb/include/tdb.h
===================================================================
--- branches/SAMBA_4_0/source/lib/tdb/include/tdb.h     2006-04-17 07:04:56 UTC 
(rev 15099)
+++ branches/SAMBA_4_0/source/lib/tdb/include/tdb.h     2006-04-17 11:42:59 UTC 
(rev 15100)
@@ -87,7 +87,7 @@
                         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);

Modified: branches/SAMBA_4_0/source/lib/tdb/tools/tdbtorture.c
===================================================================
--- branches/SAMBA_4_0/source/lib/tdb/tools/tdbtorture.c        2006-04-17 
07:04:56 UTC (rev 15099)
+++ branches/SAMBA_4_0/source/lib/tdb/tools/tdbtorture.c        2006-04-17 
11:42:59 UTC (rev 15100)
@@ -149,7 +149,7 @@
 
 #if REOPEN_PROB
        if (in_transaction == 0 && random() % REOPEN_PROB == 0) {
-               tdb_reopen_all();
+               tdb_reopen_all(0);
                goto next;
        } 
 #endif

Modified: branches/SAMBA_4_0/source/smbd/process_standard.c
===================================================================
--- branches/SAMBA_4_0/source/smbd/process_standard.c   2006-04-17 07:04:56 UTC 
(rev 15099)
+++ branches/SAMBA_4_0/source/smbd/process_standard.c   2006-04-17 11:42:59 UTC 
(rev 15100)
@@ -105,7 +105,7 @@
        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 @@
        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"));
        }
 

Reply via email to