[PATCH] Streamline messaging and serverid handling
Volker Lendecke
Volker.Lendecke at SerNet.DE
Sat Oct 17 13:37:48 UTC 2015
Hi!
Attached find a patchset that moves generation of our unique
id down into messaging_dgm.c, removing the global
my_unique_id on its way.
This way every process gets a real unique id, not just the
ones that take special care.
Review&push appreciated!
Thanks,
Volker
--
SerNet GmbH, Bahnhofsallee 1b, 37081 Göttingen
phone: +49-551-370000-0, fax: +49-551-370000-9
AG Göttingen, HRB 2816, GF: Dr. Johannes Loxen
http://www.sernet.de, mailto:kontakt at sernet.de
-------------- next part --------------
From 1492a2ac83ba38855546cfcd0d265eb6f6ee7f06 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Mon, 12 Oct 2015 17:20:48 +0200
Subject: [PATCH 01/11] auth: Remove procid_self() from auth_samba4
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/auth/auth_samba4.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/source3/auth/auth_samba4.c b/source3/auth/auth_samba4.c
index 0a80d17..e68c702 100644
--- a/source3/auth/auth_samba4.c
+++ b/source3/auth/auth_samba4.c
@@ -20,6 +20,7 @@
#include "includes.h"
#include "source3/include/auth.h"
+#include "source3/include/messages.h"
#include "source4/auth/auth.h"
#include "auth/auth_sam_reply.h"
#include "param/param.h"
@@ -48,6 +49,7 @@ static int free_task_id(struct server_id *server_id)
* (ie, use talloc_free()) */
static struct server_id *new_server_id_task(TALLOC_CTX *mem_ctx)
{
+ struct messaging_context *msg_ctx;
struct server_id *server_id;
int task_id;
if (!task_id_tree) {
@@ -57,12 +59,17 @@ static struct server_id *new_server_id_task(TALLOC_CTX *mem_ctx)
}
}
+ msg_ctx = server_messaging_context();
+ if (msg_ctx == NULL) {
+ return NULL;
+ }
+
server_id = talloc(mem_ctx, struct server_id);
if (!server_id) {
return NULL;
}
- *server_id = procid_self();
+ *server_id = messaging_server_id(msg_ctx);
/* 0 is the default server_id, so we need to start with 1 */
task_id = idr_get_new_above(task_id_tree, server_id, 1, INT32_MAX);
--
1.9.1
From a2a46cbfa6da19e17c8125249d4397d05ebb3c33 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Mon, 12 Oct 2015 17:21:30 +0200
Subject: [PATCH 02/11] fssd: Remove reference to procid_self()
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/rpc_server/fssd.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/source3/rpc_server/fssd.c b/source3/rpc_server/fssd.c
index 1e96afe..8f55aff 100644
--- a/source3/rpc_server/fssd.c
+++ b/source3/rpc_server/fssd.c
@@ -182,7 +182,7 @@ void start_fssd(struct tevent_context *ev_ctx,
fssd_setup_sig_term_handler(ev_ctx);
fssd_setup_sig_hup_handler(ev_ctx, msg_ctx);
- ok = serverid_register(procid_self(),
+ ok = serverid_register(messaging_server_id(msg_ctx),
FLAG_MSG_GENERAL |
FLAG_MSG_PRINT_GENERAL);
if (!ok) {
--
1.9.1
From f2a7a928e0a996e02cac5ba09b8602032d062627 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Mon, 12 Oct 2015 17:21:55 +0200
Subject: [PATCH 03/11] winbindd: Remove reference to procid_self()
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/winbindd/winbindd.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/source3/winbindd/winbindd.c b/source3/winbindd/winbindd.c
index e6dd0e7..d555127 100644
--- a/source3/winbindd/winbindd.c
+++ b/source3/winbindd/winbindd.c
@@ -99,12 +99,20 @@ struct messaging_context *winbind_messaging_context(void)
struct imessaging_context *winbind_imessaging_context(void)
{
static struct imessaging_context *msg = NULL;
+ struct messaging_context *msg_ctx;
+ struct server_id myself;
struct loadparm_context *lp_ctx;
if (msg != NULL) {
return msg;
}
+ msg_ctx = server_messaging_context();
+ if (msg_ctx == NULL) {
+ smb_panic("server_messaging_context failed\n");
+ }
+ myself = messaging_server_id(msg_ctx);
+
lp_ctx = loadparm_init_s3(NULL, loadparm_s3_helpers());
if (lp_ctx == NULL) {
smb_panic("Could not load smb.conf to init winbindd's imessaging context.\n");
@@ -114,7 +122,8 @@ struct imessaging_context *winbind_imessaging_context(void)
* Note we MUST use the NULL context here, not the autofree context,
* to avoid side effects in forked children exiting.
*/
- msg = imessaging_init(NULL, lp_ctx, procid_self(), winbind_event_context(), false);
+ msg = imessaging_init(NULL, lp_ctx, myself, winbind_event_context(),
+ false);
talloc_unlink(NULL, lp_ctx);
if (msg == NULL) {
--
1.9.1
From 6db9b272ce0bf5304234d64d2cc3d69b091a1e28 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Fri, 16 Oct 2015 11:36:48 +0200
Subject: [PATCH 04/11] lib: Fix pid_to_procid()
Putting in my_unique_id is just wrong. Now that we have
a cheap way to read everyone's unique ids out of the lockfile,
we can fix it.
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/lib/util.c | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/source3/lib/util.c b/source3/lib/util.c
index a0da087..760c3cc 100644
--- a/source3/lib/util.c
+++ b/source3/lib/util.c
@@ -28,6 +28,7 @@
#include "ctdbd_conn.h"
#include "../lib/util/util_pw.h"
#include "messages.h"
+#include "messages_dgm.h"
#include "libcli/security/security.h"
#include "serverid.h"
#include "lib/util/sys_rw.h"
@@ -1968,12 +1969,17 @@ void set_my_unique_id(uint64_t unique_id)
struct server_id pid_to_procid(pid_t pid)
{
- struct server_id result;
- result.pid = pid;
- result.task_id = 0;
- result.unique_id = my_unique_id;
- result.vnn = my_vnn;
- return result;
+ uint64_t unique = 0;
+ int ret;
+
+ ret = messaging_dgm_get_unique(pid, &unique);
+ if (ret != 0) {
+ DBG_WARNING("%s: messaging_dgm_get_unique failed: %s\n",
+ __func__, strerror(ret));
+ }
+
+ return (struct server_id) {
+ .pid = pid, .unique_id = unique, .vnn = my_vnn };
}
struct server_id procid_self(void)
--
1.9.1
From 56b2e29d08db8faf07e2be6e116868b64c203a3d Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Mon, 12 Oct 2015 17:26:34 +0200
Subject: [PATCH 05/11] lib: Remove procid_self() from messages.c
This together with the removal of procid_self obsoletes the global
my_unique.
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/lib/messages.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/source3/lib/messages.c b/source3/lib/messages.c
index d059f23..9025d7b 100644
--- a/source3/lib/messages.c
+++ b/source3/lib/messages.c
@@ -300,7 +300,11 @@ struct messaging_context *messaging_init(TALLOC_CTX *mem_ctx,
return NULL;
}
- ctx->id = procid_self();
+ ctx->id = (struct server_id) {
+ .pid = getpid(), .vnn = NONCLUSTER_VNN
+ };
+ ctx->id.unique_id = serverid_get_random_unique_id();
+
ctx->event_ctx = ev;
sec_init();
@@ -393,7 +397,10 @@ NTSTATUS messaging_reinit(struct messaging_context *msg_ctx)
TALLOC_FREE(msg_ctx->msg_dgm_ref);
- msg_ctx->id = procid_self();
+ msg_ctx->id = (struct server_id) {
+ .pid = getpid(), .vnn = msg_ctx->id.vnn
+ };
+ msg_ctx->id.unique_id = serverid_get_random_unique_id();
msg_ctx->msg_dgm_ref = messaging_dgm_ref(
msg_ctx, msg_ctx->event_ctx, msg_ctx->id.unique_id,
--
1.9.1
From e86bb2c1dec44faae14afd8b1ad05ba40266283e Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Mon, 12 Oct 2015 17:28:14 +0200
Subject: [PATCH 06/11] lib: Remove unused procid_self()
---
source3/include/proto.h | 1 -
source3/lib/util.c | 5 -----
2 files changed, 6 deletions(-)
diff --git a/source3/include/proto.h b/source3/include/proto.h
index 5b63897..567e1d8 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -438,7 +438,6 @@ void set_my_vnn(uint32_t vnn);
uint32_t get_my_vnn(void);
void set_my_unique_id(uint64_t unique_id);
struct server_id pid_to_procid(pid_t pid);
-struct server_id procid_self(void);
#define serverid_equal(p1, p2) server_id_equal(p1,p2)
bool procid_is_me(const struct server_id *pid);
struct server_id interpret_pid(const char *pid_string);
diff --git a/source3/lib/util.c b/source3/lib/util.c
index 760c3cc..1714614 100644
--- a/source3/lib/util.c
+++ b/source3/lib/util.c
@@ -1982,11 +1982,6 @@ struct server_id pid_to_procid(pid_t pid)
.pid = pid, .unique_id = unique, .vnn = my_vnn };
}
-struct server_id procid_self(void)
-{
- return pid_to_procid(getpid());
-}
-
bool procid_is_me(const struct server_id *pid)
{
if (pid->pid != getpid())
--
1.9.1
From ab142f5ea68c8cf6f193737fdcf41db82eca6b4c Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Mon, 12 Oct 2015 17:37:14 +0200
Subject: [PATCH 07/11] lib: Remove unused procid_is_me()
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/include/proto.h | 1 -
source3/lib/util.c | 11 -----------
2 files changed, 12 deletions(-)
diff --git a/source3/include/proto.h b/source3/include/proto.h
index 567e1d8..4da638d 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -439,7 +439,6 @@ uint32_t get_my_vnn(void);
void set_my_unique_id(uint64_t unique_id);
struct server_id pid_to_procid(pid_t pid);
#define serverid_equal(p1, p2) server_id_equal(p1,p2)
-bool procid_is_me(const struct server_id *pid);
struct server_id interpret_pid(const char *pid_string);
bool procid_valid(const struct server_id *pid);
bool procid_is_local(const struct server_id *pid);
diff --git a/source3/lib/util.c b/source3/lib/util.c
index 1714614..22ad612 100644
--- a/source3/lib/util.c
+++ b/source3/lib/util.c
@@ -1982,17 +1982,6 @@ struct server_id pid_to_procid(pid_t pid)
.pid = pid, .unique_id = unique, .vnn = my_vnn };
}
-bool procid_is_me(const struct server_id *pid)
-{
- if (pid->pid != getpid())
- return False;
- if (pid->task_id != 0)
- return False;
- if (pid->vnn != my_vnn)
- return False;
- return True;
-}
-
struct server_id interpret_pid(const char *pid_string)
{
return server_id_from_string(get_my_vnn(), pid_string);
--
1.9.1
From f74a7177a87850367efe5edd95564271bf0a5bce Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Mon, 12 Oct 2015 20:59:57 +0200
Subject: [PATCH 08/11] lib: Remove unused global my_unique_id
The unique_id is now always attached to a messaging_context.
---
source3/include/proto.h | 1 -
source3/lib/util.c | 7 -------
source3/smbd/scavenger.c | 5 -----
source3/smbd/server.c | 11 -----------
4 files changed, 24 deletions(-)
diff --git a/source3/include/proto.h b/source3/include/proto.h
index 4da638d..c2d9166 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -436,7 +436,6 @@ uint32_t map_share_mode_to_deny_mode(uint32_t share_access, uint32_t private_opt
pid_t procid_to_pid(const struct server_id *proc);
void set_my_vnn(uint32_t vnn);
uint32_t get_my_vnn(void);
-void set_my_unique_id(uint64_t unique_id);
struct server_id pid_to_procid(pid_t pid);
#define serverid_equal(p1, p2) server_id_equal(p1,p2)
struct server_id interpret_pid(const char *pid_string);
diff --git a/source3/lib/util.c b/source3/lib/util.c
index 22ad612..7c24f8a 100644
--- a/source3/lib/util.c
+++ b/source3/lib/util.c
@@ -1960,13 +1960,6 @@ uint32_t get_my_vnn(void)
return my_vnn;
}
-static uint64_t my_unique_id = 0;
-
-void set_my_unique_id(uint64_t unique_id)
-{
- my_unique_id = unique_id;
-}
-
struct server_id pid_to_procid(pid_t pid)
{
uint64_t unique = 0;
diff --git a/source3/smbd/scavenger.c b/source3/smbd/scavenger.c
index ea0a894..6171c29 100644
--- a/source3/smbd/scavenger.c
+++ b/source3/smbd/scavenger.c
@@ -196,7 +196,6 @@ static bool smbd_scavenger_start(struct smbd_scavenger_state *state)
struct tevent_fd *fde = NULL;
int fds[2];
int ret;
- uint64_t unique_id;
bool ok;
SMB_ASSERT(server_id_equal(&state->parent_id, &self));
@@ -234,8 +233,6 @@ static bool smbd_scavenger_start(struct smbd_scavenger_state *state)
smb_set_close_on_exec(fds[0]);
smb_set_close_on_exec(fds[1]);
- unique_id = serverid_get_random_unique_id();
-
ret = fork();
if (ret == -1) {
int err = errno;
@@ -252,8 +249,6 @@ static bool smbd_scavenger_start(struct smbd_scavenger_state *state)
close(fds[0]);
- set_my_unique_id(unique_id);
-
status = smbd_reinit_after_fork(state->msg, state->ev,
true, "smbd-scavenger");
if (!NT_STATUS_IS_OK(status)) {
diff --git a/source3/smbd/server.c b/source3/smbd/server.c
index ca9fb9e..ceb9599 100644
--- a/source3/smbd/server.c
+++ b/source3/smbd/server.c
@@ -575,7 +575,6 @@ static void smbd_accept_connection(struct tevent_context *ev,
socklen_t in_addrlen = sizeof(addr);
int fd;
pid_t pid = 0;
- uint64_t unique_id;
fd = accept(s->fd, (struct sockaddr *)(void *)&addr,&in_addrlen);
if (fd == -1 && errno == EINTR)
@@ -599,12 +598,6 @@ static void smbd_accept_connection(struct tevent_context *ev,
return;
}
- /*
- * Generate a unique id in the parent process so that we use
- * the global random state in the parent.
- */
- unique_id = serverid_get_random_unique_id();
-
pid = fork();
if (pid == 0) {
NTSTATUS status = NT_STATUS_OK;
@@ -616,8 +609,6 @@ static void smbd_accept_connection(struct tevent_context *ev,
talloc_free(s->parent);
s = NULL;
- set_my_unique_id(unique_id);
-
/* Stop zombies, the parent explicitly handles
* them, counting worker smbds. */
CatchChild();
@@ -1363,8 +1354,6 @@ extern void build_options(bool screen);
become_daemon(Fork, no_process_group, log_stdout);
}
- set_my_unique_id(serverid_get_random_unique_id());
-
#if HAVE_SETPGID
/*
* If we're interactive we want to set our own process group for
--
1.9.1
From 951ef3881ec757873afc467d7dad917b1bdf9478 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Mon, 12 Oct 2015 21:30:30 +0200
Subject: [PATCH 09/11] lib: Push down unique generation one level
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/lib/messages.c | 6 ++----
source3/lib/messages_dgm.c | 22 +++++++++++++++++++---
source3/lib/messages_dgm.h | 2 +-
source3/lib/messages_dgm_ref.c | 10 +++++++++-
source3/lib/messages_dgm_ref.h | 2 +-
source3/wscript_build | 3 ++-
source4/lib/messaging/messaging.c | 2 +-
7 files changed, 35 insertions(+), 12 deletions(-)
diff --git a/source3/lib/messages.c b/source3/lib/messages.c
index 9025d7b..ef8e83d 100644
--- a/source3/lib/messages.c
+++ b/source3/lib/messages.c
@@ -303,7 +303,6 @@ struct messaging_context *messaging_init(TALLOC_CTX *mem_ctx,
ctx->id = (struct server_id) {
.pid = getpid(), .vnn = NONCLUSTER_VNN
};
- ctx->id.unique_id = serverid_get_random_unique_id();
ctx->event_ctx = ev;
@@ -340,7 +339,7 @@ struct messaging_context *messaging_init(TALLOC_CTX *mem_ctx,
}
ctx->msg_dgm_ref = messaging_dgm_ref(
- ctx, ctx->event_ctx, ctx->id.unique_id,
+ ctx, ctx->event_ctx, &ctx->id.unique_id,
priv_path, lck_path, messaging_recv_cb, ctx, &ret);
if (ctx->msg_dgm_ref == NULL) {
@@ -400,10 +399,9 @@ NTSTATUS messaging_reinit(struct messaging_context *msg_ctx)
msg_ctx->id = (struct server_id) {
.pid = getpid(), .vnn = msg_ctx->id.vnn
};
- msg_ctx->id.unique_id = serverid_get_random_unique_id();
msg_ctx->msg_dgm_ref = messaging_dgm_ref(
- msg_ctx, msg_ctx->event_ctx, msg_ctx->id.unique_id,
+ msg_ctx, msg_ctx->event_ctx, &msg_ctx->id.unique_id,
private_path("msg.sock"), lock_path("msg.lock"),
messaging_recv_cb, msg_ctx, &ret);
diff --git a/source3/lib/messages_dgm.c b/source3/lib/messages_dgm.c
index 1acd2d7..af31ffc 100644
--- a/source3/lib/messages_dgm.c
+++ b/source3/lib/messages_dgm.c
@@ -29,6 +29,7 @@
#include "lib/param/param.h"
#include "poll_funcs/poll_funcs_tevent.h"
#include "unix_msg/unix_msg.h"
+#include "lib/util/genrand.h"
struct sun_path_buf {
/*
@@ -67,12 +68,13 @@ static int messaging_dgm_context_destructor(struct messaging_dgm_context *c);
static int messaging_dgm_lockfile_create(struct messaging_dgm_context *ctx,
pid_t pid, int *plockfile_fd,
- uint64_t unique)
+ uint64_t *punique)
{
char buf[64];
int lockfile_fd;
struct sun_path_buf lockfile_name;
struct flock lck;
+ uint64_t unique;
int unique_len, ret;
ssize_t written;
@@ -104,6 +106,19 @@ static int messaging_dgm_lockfile_create(struct messaging_dgm_context *ctx,
goto fail_close;
}
+ /*
+ * Directly using the binary value for
+ * SERVERID_UNIQUE_ID_NOT_TO_VERIFY is a layering
+ * violation. But including all of ndr here just for this
+ * seems to be a bit overkill to me. Also, messages_dgm might
+ * be replaced sooner or later by something streams-based,
+ * where unique_id generation will be handled differently.
+ */
+
+ do {
+ generate_random_buffer((uint8_t *)&unique, sizeof(unique));
+ } while (unique == 0xFFFFFFFFFFFFFFFFULL); /* SERVERID_UNIQUE_ID_NOT_TO_VERIFY */
+
unique_len = snprintf(buf, sizeof(buf), "%ju\n", (uintmax_t)unique);
/* shorten a potentially preexisting file */
@@ -124,6 +139,7 @@ static int messaging_dgm_lockfile_create(struct messaging_dgm_context *ctx,
}
*plockfile_fd = lockfile_fd;
+ *punique = unique;
return 0;
fail_unlink:
@@ -134,7 +150,7 @@ fail_close:
}
int messaging_dgm_init(struct tevent_context *ev,
- uint64_t unique,
+ uint64_t *punique,
const char *socket_dir,
const char *lockfile_dir,
void (*recv_cb)(const uint8_t *msg,
@@ -186,7 +202,7 @@ int messaging_dgm_init(struct tevent_context *ev,
}
ret = messaging_dgm_lockfile_create(ctx, ctx->pid, &ctx->lockfile_fd,
- unique);
+ punique);
if (ret != 0) {
DEBUG(1, ("%s: messaging_dgm_create_lockfile failed: %s\n",
__func__, strerror(ret)));
diff --git a/source3/lib/messages_dgm.h b/source3/lib/messages_dgm.h
index d38cfcc..a9cbd81 100644
--- a/source3/lib/messages_dgm.h
+++ b/source3/lib/messages_dgm.h
@@ -25,7 +25,7 @@
#include <tevent.h>
int messaging_dgm_init(struct tevent_context *ev,
- uint64_t unique,
+ uint64_t *unique,
const char *socket_dir,
const char *lockfile_dir,
void (*recv_cb)(const uint8_t *msg,
diff --git a/source3/lib/messages_dgm_ref.c b/source3/lib/messages_dgm_ref.c
index 0a6cbf7..dd9b965 100644
--- a/source3/lib/messages_dgm_ref.c
+++ b/source3/lib/messages_dgm_ref.c
@@ -40,7 +40,7 @@ static void msg_dgm_ref_recv(const uint8_t *msg, size_t msg_len,
int *fds, size_t num_fds, void *private_data);
void *messaging_dgm_ref(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
- uint64_t unique,
+ uint64_t *unique,
const char *socket_dir,
const char *lockfile_dir,
void (*recv_cb)(const uint8_t *msg, size_t msg_len,
@@ -82,6 +82,14 @@ void *messaging_dgm_ref(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
}
dgm_pid = getpid();
} else {
+ int ret;
+ ret = messaging_dgm_get_unique(getpid(), unique);
+ if (ret != 0) {
+ TALLOC_FREE(result);
+ *err = ret;
+ return NULL;
+ }
+
result->tevent_handle = messaging_dgm_register_tevent_context(
result, ev);
if (result->tevent_handle == NULL) {
diff --git a/source3/lib/messages_dgm_ref.h b/source3/lib/messages_dgm_ref.h
index 3df0c06..8f0aff8 100644
--- a/source3/lib/messages_dgm_ref.h
+++ b/source3/lib/messages_dgm_ref.h
@@ -25,7 +25,7 @@
#include "replace.h"
void *messaging_dgm_ref(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
- uint64_t unique,
+ uint64_t *unique,
const char *socket_dir,
const char *lockfile_dir,
void (*recv_cb)(const uint8_t *msg, size_t msg_len,
diff --git a/source3/wscript_build b/source3/wscript_build
index be0b7e6..1f9f757 100755
--- a/source3/wscript_build
+++ b/source3/wscript_build
@@ -299,7 +299,8 @@ bld.SAMBA3_SUBSYSTEM('TDB_LIB',
bld.SAMBA3_LIBRARY('messages_dgm',
source='''lib/messages_dgm.c lib/messages_dgm_ref.c''',
- deps='talloc UNIX_MSG POLL_FUNCS_TEVENT samba-debug',
+ deps='''talloc UNIX_MSG POLL_FUNCS_TEVENT samba-debug
+ genrand''',
private_library=True)
bld.SAMBA3_LIBRARY('messages_util',
diff --git a/source4/lib/messaging/messaging.c b/source4/lib/messaging/messaging.c
index d91d175..bbc22ec 100644
--- a/source4/lib/messaging/messaging.c
+++ b/source4/lib/messaging/messaging.c
@@ -342,7 +342,7 @@ struct imessaging_context *imessaging_init(TALLOC_CTX *mem_ctx,
}
msg->msg_dgm_ref = messaging_dgm_ref(
- msg, ev, server_id.unique_id, msg->sock_dir, msg->lock_dir,
+ msg, ev, &server_id.unique_id, msg->sock_dir, msg->lock_dir,
imessaging_dgm_recv, msg, &ret);
if (msg->msg_dgm_ref == NULL) {
--
1.9.1
From 1962ed0a2e2727a19979df481c29a2b0903ddc10 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Wed, 14 Oct 2015 11:31:07 +0200
Subject: [PATCH 10/11] lib: Add some debug to dgm_ref
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/lib/messages_dgm_ref.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/source3/lib/messages_dgm_ref.c b/source3/lib/messages_dgm_ref.c
index dd9b965..e3b2d88 100644
--- a/source3/lib/messages_dgm_ref.c
+++ b/source3/lib/messages_dgm_ref.c
@@ -73,6 +73,8 @@ void *messaging_dgm_ref(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
ret = messaging_dgm_init(ev, unique, socket_dir, lockfile_dir,
msg_dgm_ref_recv, NULL);
+ DBG_DEBUG("%s: messaging_dgm_init returned %s\n", __func__,
+ strerror(ret));
if (ret != 0) {
DEBUG(10, ("messaging_dgm_init failed: %s\n",
strerror(ret)));
@@ -84,6 +86,8 @@ void *messaging_dgm_ref(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
} else {
int ret;
ret = messaging_dgm_get_unique(getpid(), unique);
+ DBG_DEBUG("%s: messaging_dgm_get_unique returned %s\n",
+ __func__, strerror(ret));
if (ret != 0) {
TALLOC_FREE(result);
*err = ret;
@@ -99,6 +103,8 @@ void *messaging_dgm_ref(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
}
}
+ DBG_DEBUG("%s: unique = %"PRIu64"\n", __func__, *unique);
+
refs = tmp_refs;
result->recv_cb = recv_cb;
@@ -134,6 +140,8 @@ static int msg_dgm_ref_destructor(struct msg_dgm_ref *r)
TALLOC_FREE(r->tevent_handle);
+ DBG_DEBUG("%s: refs=%p\n", __func__, refs);
+
if (refs == NULL) {
messaging_dgm_destroy();
}
--
1.9.1
From fc5343883b95620964ba7091eadcd386388b59c6 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Wed, 14 Oct 2015 11:41:23 +0200
Subject: [PATCH 11/11] lib: Remove unused serverid_get_random_unique_id
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/include/serverid.h | 6 ------
source3/lib/serverid.c | 12 ------------
2 files changed, 18 deletions(-)
diff --git a/source3/include/serverid.h b/source3/include/serverid.h
index 24ebcbe..03022dc 100644
--- a/source3/include/serverid.h
+++ b/source3/include/serverid.h
@@ -59,10 +59,4 @@ bool serverid_traverse_read(int (*fn)(const struct server_id *id,
*/
bool serverid_parent_init(TALLOC_CTX *mem_ctx);
-/*
- * Get a random unique_id and make sure that it is not
- * SERVERID_UNIQUE_ID_NOT_TO_VERIFY
- */
-uint64_t serverid_get_random_unique_id(void);
-
#endif
diff --git a/source3/lib/serverid.c b/source3/lib/serverid.c
index c219d21..5c2fa65 100644
--- a/source3/lib/serverid.c
+++ b/source3/lib/serverid.c
@@ -313,15 +313,3 @@ bool serverid_traverse(int (*fn)(struct db_record *rec,
status = dbwrap_traverse(db, serverid_traverse_fn, &state, NULL);
return NT_STATUS_IS_OK(status);
}
-
-uint64_t serverid_get_random_unique_id(void)
-{
- uint64_t unique_id = SERVERID_UNIQUE_ID_NOT_TO_VERIFY;
-
- while (unique_id == SERVERID_UNIQUE_ID_NOT_TO_VERIFY) {
- generate_random_buffer((uint8_t *)&unique_id,
- sizeof(unique_id));
- }
-
- return unique_id;
-}
--
1.9.1
More information about the samba-technical
mailing list