messaging3: Add messaging_names_db
authorVolker Lendecke <vl@samba.org>
Fri, 17 Oct 2014 12:09:03 +0000 (12:09 +0000)
committerJeremy Allison <jra@samba.org>
Tue, 16 Dec 2014 17:56:03 +0000 (18:56 +0100)
This will enable messaging3 users to more easily register themselves
under a name

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/include/messages.h
source3/lib/messages.c
source3/wscript_build

index fac561bcf69c711698450b1f1f751398b290a81a..80b6c19bf1f6a10c0979bde485a7efb9d70fccee 100644 (file)
@@ -89,6 +89,7 @@ struct messaging_context *messaging_init(TALLOC_CTX *mem_ctx,
 struct server_id messaging_server_id(const struct messaging_context *msg_ctx);
 struct tevent_context *messaging_tevent_context(
        struct messaging_context *msg_ctx);
+struct server_id_db *messaging_names_db(struct messaging_context *msg_ctx);
 
 /*
  * re-init after a fork
index 1fd7601f829fe0bbcc5999d17e3200ff0a670b8d..27114687189ed8fcd86ba93c499cbf51913782f7 100644 (file)
@@ -53,6 +53,7 @@
 #include "lib/background.h"
 #include "lib/messages_dgm.h"
 #include "lib/iov_buf.h"
+#include "lib/util/server_id_db.h"
 
 struct messaging_callback {
        struct messaging_callback *prev, *next;
@@ -75,6 +76,8 @@ struct messaging_context {
        unsigned num_waiters;
 
        struct messaging_backend *remote;
+
+       struct server_id_db *names_db;
 };
 
 struct messaging_hdr {
@@ -314,6 +317,15 @@ struct messaging_context *messaging_init(TALLOC_CTX *mem_ctx,
                return NULL;
        }
 
+       ctx->names_db = server_id_db_init(
+               ctx, ctx->id, lp_cache_directory(), 0,
+               TDB_INCOMPATIBLE_HASH|TDB_CLEAR_IF_FIRST);
+       if (ctx->names_db == NULL) {
+               DEBUG(10, ("%s: server_id_db_init failed\n", __func__));
+               TALLOC_FREE(ctx);
+               return NULL;
+       }
+
        talloc_set_destructor(ctx, messaging_context_destructor);
 
        if (lp_clustering()) {
@@ -377,6 +389,8 @@ NTSTATUS messaging_reinit(struct messaging_context *msg_ctx)
                }
        }
 
+       server_id_db_reinit(msg_ctx->names_db, msg_ctx->id);
+
        return NT_STATUS_OK;
 }
 
@@ -963,4 +977,9 @@ struct tevent_context *messaging_tevent_context(
        return msg_ctx->event_ctx;
 }
 
+struct server_id_db *messaging_names_db(struct messaging_context *msg_ctx)
+{
+       return msg_ctx->names_db;
+}
+
 /** @} **/
index 5128b96bfd5345a90b37ab8fffe9f2bae2a9a0ce..937657689af234592fd82ea680d0708a3bde93fd 100755 (executable)
@@ -363,6 +363,7 @@ bld.SAMBA3_SUBSYSTEM('samba3core',
                         dbwrap
                         samba3-util
                         errors3
+                        server_id_db
                         TDB_LIB''')
 
 bld.SAMBA3_LIBRARY('smbd_shim',