s3: use TDB_INCOMPATIBLE_HASH (the jenkins hash) on all TDB_CLEAR_IF_FIRST tdb's.
[obnox/samba-ctdb.git] / source3 / lib / messages_local.c
index be848ac8baca93903076bcfc888b4b19150a1bd0..4b8dc3f3cfb310b7c409d5557d009381bb9f40d1 100644 (file)
@@ -103,7 +103,7 @@ NTSTATUS messaging_tdb_init(struct messaging_context *msg_ctx,
        ctx->msg_ctx = msg_ctx;
 
        ctx->tdb = tdb_wrap_open(ctx, lock_path("messages.tdb"),
-                                0, TDB_CLEAR_IF_FIRST|TDB_DEFAULT,
+                                0, TDB_CLEAR_IF_FIRST|TDB_INCOMPATIBLE_HASH|TDB_DEFAULT,
                                 O_RDWR|O_CREAT,0600);
 
        if (!ctx->tdb) {
@@ -136,6 +136,28 @@ NTSTATUS messaging_tdb_init(struct messaging_context *msg_ctx,
        return NT_STATUS_OK;
 }
 
+bool messaging_tdb_parent_init(void)
+{
+       struct tdb_wrap *db;
+
+       /*
+        * Open the tdb in the parent process (smbd) so that our
+        * CLEAR_IF_FIRST optimization in tdb_reopen_all can properly
+        * work.
+        */
+
+       db = tdb_wrap_open(talloc_autofree_context(),
+                          lock_path("messages.tdb"), 0,
+                          TDB_CLEAR_IF_FIRST|TDB_INCOMPATIBLE_HASH|TDB_DEFAULT|TDB_VOLATILE,
+                          O_RDWR|O_CREAT,0600);
+       if (db == NULL) {
+               DEBUG(1, ("could not open messaging.tdb: %s\n",
+                         strerror(errno)));
+               return false;
+       }
+       return true;
+}
+
 /*******************************************************************
  Form a static tdb key from a pid.
 ******************************************************************/