s3: Make sure our CLEAR_IF_FIRST optimization works for serverid.tdb
authorVolker Lendecke <vl@samba.org>
Thu, 25 Mar 2010 15:02:54 +0000 (16:02 +0100)
committerVolker Lendecke <vl@samba.org>
Thu, 25 Mar 2010 16:34:14 +0000 (17:34 +0100)
In the child, we fully re-open serverid.tdb, which leads to one fcntl lock for
CLEAR_IF_FIRST detection per smbd. This opens the tdb in the parent and holds
it, so that tdb_reopen_all correctly catches the CLEAR_IF_FIRST bit.

source3/include/serverid.h
source3/lib/serverid.c
source3/smbd/server.c

index 8e87c271ac2c10f8af246f5e1b7c375229c9f352..db2ce5ab87555c45fac9488d7844ae62652bbfac 100644 (file)
@@ -53,4 +53,9 @@ bool serverid_traverse_read(int (*fn)(const struct server_id *id,
                                      uint32_t msg_flags,
                                      void *private_data),
                            void *private_data);
+/*
+ * Ensure CLEAR_IF_FIRST works fine, to be called from the parent smbd
+ */
+bool serverid_parent_init(void);
+
 #endif
index ff08c3ad123968f4d3d4dbc3532d39e5e5932cbe..f497f202b80e75f2b1189104da9e9b3341a1bc4a 100644 (file)
@@ -27,6 +27,22 @@ struct serverid_key {
 #endif
 };
 
+bool serverid_parent_init(void)
+{
+       struct tdb_wrap *db;
+
+       db = tdb_wrap_open(talloc_autofree_context(),
+                          lock_path("serverid.tdb"),
+                          0, TDB_DEFAULT|TDB_CLEAR_IF_FIRST, O_RDWR|O_CREAT,
+                          0644);
+       if (db == NULL) {
+               DEBUG(1, ("could not open serverid.tdb: %s\n",
+                         strerror(errno)));
+               return false;
+       }
+       return true;
+}
+
 struct serverid_data {
        uint64_t unique_id;
        uint32_t msg_flags;
index 1ceed267daa0864982440754559c5d1ccd12cc63..bb197e59301642bf2d2a5e4e0642ea4eb77a1961 100644 (file)
@@ -1290,6 +1290,10 @@ extern void build_options(bool screen);
                exit(1);
        }
 
+       if (!serverid_parent_init()) {
+               exit(1);
+       }
+
        namecache_enable();
 
        if (!W_ERROR_IS_OK(registry_init_full()))