[PATCH] Remove serverid.tdb

Volker Lendecke Volker.Lendecke at SerNet.DE
Mon Nov 27 11:16:36 UTC 2017


Hi!

Attached find a patch that replaces the message_send_all
implementation with other mechanisms. This makes serverid.tdb
obsolete.

Review 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 4a05217af459aa6d5fea4467888a16b4fe260e2d Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Fri, 21 Jul 2017 19:08:43 +0200
Subject: [PATCH 01/11] messaging: Remove the "n_sent" arg from
 message_send_all

The only user of this is an informative message in smbcontrol. I don't think
that's worth the effort.

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 source3/include/serverid.h                  | 3 +--
 source3/lib/serverid.c                      | 8 +-------
 source3/passdb/pdb_interface.c              | 3 +--
 source3/printing/queue_process.c            | 2 +-
 source3/rpc_server/fss/srv_fss_agent.c      | 6 +++---
 source3/rpc_server/spoolss/srv_spoolss_nt.c | 4 ++--
 source3/rpc_server/srvsvc/srv_srvsvc_nt.c   | 8 +++-----
 source3/smbd/smbd_cleanupd.c                | 2 +-
 source3/smbd/statcache.c                    | 3 +--
 source3/utils/smbcontrol.c                  | 5 +----
 10 files changed, 15 insertions(+), 29 deletions(-)

diff --git a/source3/include/serverid.h b/source3/include/serverid.h
index 749b950f2c8..a73a6f6986c 100644
--- a/source3/include/serverid.h
+++ b/source3/include/serverid.h
@@ -75,7 +75,6 @@ struct messaging_context;
 
 bool message_send_all(struct messaging_context *msg_ctx,
 		      int msg_type,
-		      const void *buf, size_t len,
-		      int *n_sent);
+		      const void *buf, size_t len);
 
 #endif
diff --git a/source3/lib/serverid.c b/source3/lib/serverid.c
index 73004489bef..9fd506df5fd 100644
--- a/source3/lib/serverid.c
+++ b/source3/lib/serverid.c
@@ -371,15 +371,11 @@ static int traverse_fn(struct db_record *rec, const struct server_id *id,
  * applications that use it. When we need efficient broadcast we can add
  * it.
  *
- * @param n_sent Set to the number of messages sent.  This should be
- * equal to the number of processes, but be careful for races.
- *
  * @retval True for success.
  **/
 bool message_send_all(struct messaging_context *msg_ctx,
 		      int msg_type,
-		      const void *buf, size_t len,
-		      int *n_sent)
+		      const void *buf, size_t len)
 {
 	struct msg_all msg_all;
 
@@ -406,7 +402,5 @@ bool message_send_all(struct messaging_context *msg_ctx,
 	msg_all.msg_ctx = msg_ctx;
 
 	serverid_traverse(traverse_fn, &msg_all);
-	if (n_sent)
-		*n_sent = msg_all.n_sent;
 	return true;
 }
diff --git a/source3/passdb/pdb_interface.c b/source3/passdb/pdb_interface.c
index 49752dde659..9827046187e 100644
--- a/source3/passdb/pdb_interface.c
+++ b/source3/passdb/pdb_interface.c
@@ -651,8 +651,7 @@ NTSTATUS pdb_delete_user(TALLOC_CTX *mem_ctx, struct samu *sam_acct)
 	message_send_all(server_messaging_context(),
 			 ID_CACHE_DELETE,
 			 msg_data,
-			 strlen(msg_data) + 1,
-			 NULL);
+			 strlen(msg_data) + 1);
 
 	TALLOC_FREE(msg_data);
 	return status;
diff --git a/source3/printing/queue_process.c b/source3/printing/queue_process.c
index e07aca036fa..381ef348805 100644
--- a/source3/printing/queue_process.c
+++ b/source3/printing/queue_process.c
@@ -144,7 +144,7 @@ static void reload_pcap_change_notify(struct tevent_context *ev,
 	 */
 	delete_and_reload_printers_full(ev, msg_ctx);
 
-	message_send_all(msg_ctx, MSG_PRINTER_PCAP, NULL, 0, NULL);
+	message_send_all(msg_ctx, MSG_PRINTER_PCAP, NULL, 0);
 }
 
 struct bq_state {
diff --git a/source3/rpc_server/fss/srv_fss_agent.c b/source3/rpc_server/fss/srv_fss_agent.c
index 0fc974bb455..c0bf7ddd11a 100644
--- a/source3/rpc_server/fss/srv_fss_agent.c
+++ b/source3/rpc_server/fss/srv_fss_agent.c
@@ -1235,7 +1235,7 @@ uint32_t _fss_ExposeShadowCopySet(struct pipes_struct *p,
 	}
 	unbecome_root();
 
-	message_send_all(p->msg_ctx, MSG_SMB_CONF_UPDATED, NULL, 0, NULL);
+	message_send_all(p->msg_ctx, MSG_SMB_CONF_UPDATED, NULL, 0);
 	for (sc = sc_set->scs; sc; sc = sc->next) {
 		struct fss_sc_smap *sm;
 		for (sm = sc->smaps; sm; sm = sm->next)
@@ -1577,7 +1577,7 @@ static NTSTATUS sc_smap_unexpose(struct messaging_context *msg_ctx,
 			ret = NT_STATUS_UNSUCCESSFUL;
 			goto err_cancel;
 		}
-		message_send_all(msg_ctx, MSG_SMB_CONF_UPDATED, NULL, 0, NULL);
+		message_send_all(msg_ctx, MSG_SMB_CONF_UPDATED, NULL, 0);
 	} else {
 		ret = NT_STATUS_OK;
 		goto err_cancel;
@@ -1661,7 +1661,7 @@ uint32_t _fss_DeleteShareMapping(struct pipes_struct *p,
 	}
 
 	message_send_all(p->msg_ctx, MSG_SMB_FORCE_TDIS, sc_smap->sc_share_name,
-			 strlen(sc_smap->sc_share_name) + 1, NULL);
+			 strlen(sc_smap->sc_share_name) + 1);
 
 	if (sc->smaps_count > 1) {
 		/* do not delete the underlying snapshot - still in use */
diff --git a/source3/rpc_server/spoolss/srv_spoolss_nt.c b/source3/rpc_server/spoolss/srv_spoolss_nt.c
index 1476dc6bf15..d8b6023e5e9 100644
--- a/source3/rpc_server/spoolss/srv_spoolss_nt.c
+++ b/source3/rpc_server/spoolss/srv_spoolss_nt.c
@@ -368,7 +368,7 @@ static WERROR delete_printer_hook(TALLOC_CTX *ctx, struct security_token *token,
 	ret = smbrun(command, NULL, NULL);
 	if (ret == 0) {
 		/* Tell everyone we updated smb.conf. */
-		message_send_all(msg_ctx, MSG_SMB_CONF_UPDATED, NULL, 0, NULL);
+		message_send_all(msg_ctx, MSG_SMB_CONF_UPDATED, NULL, 0);
 	}
 
 	if ( is_print_op )
@@ -6433,7 +6433,7 @@ static bool add_printer_hook(TALLOC_CTX *ctx, struct security_token *token,
 	ret = smbrun(command, &fd, NULL);
 	if (ret == 0) {
 		/* Tell everyone we updated smb.conf. */
-		message_send_all(msg_ctx, MSG_SMB_CONF_UPDATED, NULL, 0, NULL);
+		message_send_all(msg_ctx, MSG_SMB_CONF_UPDATED, NULL, 0);
 	}
 
 	if ( is_print_op )
diff --git a/source3/rpc_server/srvsvc/srv_srvsvc_nt.c b/source3/rpc_server/srvsvc/srv_srvsvc_nt.c
index 2a8cf8de650..899feb22da9 100644
--- a/source3/rpc_server/srvsvc/srv_srvsvc_nt.c
+++ b/source3/rpc_server/srvsvc/srv_srvsvc_nt.c
@@ -1909,7 +1909,7 @@ WERROR _srvsvc_NetShareSetInfo(struct pipes_struct *p,
 		if (ret == 0) {
 			/* Tell everyone we updated smb.conf. */
 			message_send_all(p->msg_ctx, MSG_SMB_CONF_UPDATED,
-					 NULL, 0, NULL);
+					 NULL, 0);
 		}
 
 		if ( is_disk_op )
@@ -2111,8 +2111,7 @@ WERROR _srvsvc_NetShareAdd(struct pipes_struct *p,
 	ret = smbrun(command, NULL, NULL);
 	if (ret == 0) {
 		/* Tell everyone we updated smb.conf. */
-		message_send_all(p->msg_ctx, MSG_SMB_CONF_UPDATED, NULL, 0,
-				 NULL);
+		message_send_all(p->msg_ctx, MSG_SMB_CONF_UPDATED, NULL, 0);
 	}
 
 	if ( is_disk_op )
@@ -2219,8 +2218,7 @@ WERROR _srvsvc_NetShareDel(struct pipes_struct *p,
 	ret = smbrun(command, NULL, NULL);
 	if (ret == 0) {
 		/* Tell everyone we updated smb.conf. */
-		message_send_all(p->msg_ctx, MSG_SMB_CONF_UPDATED, NULL, 0,
-				 NULL);
+		message_send_all(p->msg_ctx, MSG_SMB_CONF_UPDATED, NULL, 0);
 	}
 
 	if ( is_disk_op )
diff --git a/source3/smbd/smbd_cleanupd.c b/source3/smbd/smbd_cleanupd.c
index 152f63c31ce..90c12cdcd7c 100644
--- a/source3/smbd/smbd_cleanupd.c
+++ b/source3/smbd/smbd_cleanupd.c
@@ -98,7 +98,7 @@ static void smbd_cleanupd_unlock(struct messaging_context *msg,
 	DBG_WARNING("Cleaning up brl and lock database after unclean "
 		    "shutdown\n");
 
-	message_send_all(msg, MSG_SMB_UNLOCK, NULL, 0, NULL);
+	message_send_all(msg, MSG_SMB_UNLOCK, NULL, 0);
 
 	brl_revalidate(msg, private_data, msg_type, server_id, data);
 }
diff --git a/source3/smbd/statcache.c b/source3/smbd/statcache.c
index 89a4a3d2237..2023d52fb84 100644
--- a/source3/smbd/statcache.c
+++ b/source3/smbd/statcache.c
@@ -357,8 +357,7 @@ void smbd_send_stat_cache_delete_message(struct messaging_context *msg_ctx,
 	message_send_all(msg_ctx,
 			MSG_SMB_STAT_CACHE_DELETE,
 			name,
-			strlen(name)+1,
-			NULL);
+			strlen(name)+1);
 #endif
 }
 
diff --git a/source3/utils/smbcontrol.c b/source3/utils/smbcontrol.c
index 4c4bfcb4e5b..08c1530cdff 100644
--- a/source3/utils/smbcontrol.c
+++ b/source3/utils/smbcontrol.c
@@ -62,16 +62,13 @@ static bool send_message(struct messaging_context *msg_ctx,
 			 const void *buf, int len)
 {
 	bool ret;
-	int n_sent = 0;
 
 	if (procid_to_pid(&pid) != 0)
 		return NT_STATUS_IS_OK(
 			messaging_send_buf(msg_ctx, pid, msg_type,
 					   (const uint8_t *)buf, len));
 
-	ret = message_send_all(msg_ctx, msg_type, buf, len, &n_sent);
-	DEBUG(10,("smbcontrol/send_message: broadcast message to "
-		  "%d processes\n", n_sent));
+	ret = message_send_all(msg_ctx, msg_type, buf, len);
 
 	return ret;
 }
-- 
2.11.0


From 337492caa06799c31e01d4d6bcf56137e227401e Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Fri, 21 Jul 2017 19:03:26 +0200
Subject: [PATCH 02/11] messaging: Add messaging_dgm_forall

This factors out the traversal function from _wipe. It will be used to
replace message_send_all soon.

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 source3/lib/messages_dgm.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++
 source3/lib/messages_dgm.h |  2 ++
 2 files changed, 48 insertions(+)

diff --git a/source3/lib/messages_dgm.c b/source3/lib/messages_dgm.c
index 15c83f75c47..2b0190a4b45 100644
--- a/source3/lib/messages_dgm.c
+++ b/source3/lib/messages_dgm.c
@@ -1614,6 +1614,52 @@ int messaging_dgm_wipe(void)
 	return 0;
 }
 
+int messaging_dgm_forall(int (*fn)(pid_t pid, void *private_data),
+			 void *private_data)
+{
+	struct messaging_dgm_context *ctx = global_dgm_context;
+	DIR *msgdir;
+	struct dirent *dp;
+
+	if (ctx == NULL) {
+		return ENOTCONN;
+	}
+
+	messaging_dgm_validate(ctx);
+
+	/*
+	 * We scan the socket directory and not the lock directory. Otherwise
+	 * we would race against messaging_dgm_lockfile_create's open(O_CREAT)
+	 * and fcntl(SETLK).
+	 */
+
+	msgdir = opendir(ctx->socket_dir.buf);
+	if (msgdir == NULL) {
+		return errno;
+	}
+
+	while ((dp = readdir(msgdir)) != NULL) {
+		unsigned long pid;
+		int ret;
+
+		pid = strtoul(dp->d_name, NULL, 10);
+		if (pid == 0) {
+			/*
+			 * . and .. and other malformed entries
+			 */
+			continue;
+		}
+
+		ret = fn(pid, private_data);
+		if (ret != 0) {
+			break;
+		}
+	}
+	closedir(msgdir);
+
+	return 0;
+}
+
 struct messaging_dgm_fde {
 	struct tevent_fd *fde;
 };
diff --git a/source3/lib/messages_dgm.h b/source3/lib/messages_dgm.h
index ca11db1dacf..7221c72660b 100644
--- a/source3/lib/messages_dgm.h
+++ b/source3/lib/messages_dgm.h
@@ -42,6 +42,8 @@ int messaging_dgm_send(pid_t pid,
 		       const int *fds, size_t num_fds);
 int messaging_dgm_cleanup(pid_t pid);
 int messaging_dgm_wipe(void);
+int messaging_dgm_forall(int (*fn)(pid_t pid, void *private_data),
+			 void *private_data);
 
 struct messaging_dgm_fde;
 struct messaging_dgm_fde *messaging_dgm_register_tevent_context(
-- 
2.11.0


From da8c746b8b516db20088038287b5848d7ee49ba8 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Mon, 16 Oct 2017 21:52:35 +0200
Subject: [PATCH 03/11] messaging_dgm: Use messaging_dgm_forall in dgm_wipe

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 source3/lib/messages_dgm.c | 59 +++++++++++++---------------------------------
 1 file changed, 17 insertions(+), 42 deletions(-)

diff --git a/source3/lib/messages_dgm.c b/source3/lib/messages_dgm.c
index 2b0190a4b45..f3e4e742fc0 100644
--- a/source3/lib/messages_dgm.c
+++ b/source3/lib/messages_dgm.c
@@ -1562,55 +1562,30 @@ int messaging_dgm_cleanup(pid_t pid)
 	return 0;
 }
 
-int messaging_dgm_wipe(void)
+static int messaging_dgm_wipe_fn(pid_t pid, void *private_data)
 {
-	struct messaging_dgm_context *ctx = global_dgm_context;
-	DIR *msgdir;
-	struct dirent *dp;
-	pid_t our_pid = getpid();
+	pid_t *our_pid = (pid_t *)private_data;
 	int ret;
 
-	if (ctx == NULL) {
-		return ENOTCONN;
+	if (pid == *our_pid) {
+		/*
+		 * fcntl(F_GETLK) will succeed for ourselves, we hold
+		 * that lock ourselves.
+		 */
+		return 0;
 	}
 
-	messaging_dgm_validate(ctx);
-
-	/*
-	 * We scan the socket directory and not the lock directory. Otherwise
-	 * we would race against messaging_dgm_lockfile_create's open(O_CREAT)
-	 * and fcntl(SETLK).
-	 */
+	ret = messaging_dgm_cleanup(pid);
+	DEBUG(10, ("messaging_dgm_cleanup(%lu) returned %s\n",
+		   (unsigned long)pid, ret ? strerror(ret) : "ok"));
 
-	msgdir = opendir(ctx->socket_dir.buf);
-	if (msgdir == NULL) {
-		return errno;
-	}
-
-	while ((dp = readdir(msgdir)) != NULL) {
-		unsigned long pid;
-
-		pid = strtoul(dp->d_name, NULL, 10);
-		if (pid == 0) {
-			/*
-			 * . and .. and other malformed entries
-			 */
-			continue;
-		}
-		if ((pid_t)pid == our_pid) {
-			/*
-			 * fcntl(F_GETLK) will succeed for ourselves, we hold
-			 * that lock ourselves.
-			 */
-			continue;
-		}
-
-		ret = messaging_dgm_cleanup(pid);
-		DEBUG(10, ("messaging_dgm_cleanup(%lu) returned %s\n",
-			   pid, ret ? strerror(ret) : "ok"));
-	}
-	closedir(msgdir);
+	return 0;
+}
 
+int messaging_dgm_wipe(void)
+{
+	pid_t pid = getpid();
+	messaging_dgm_forall(messaging_dgm_wipe_fn, &pid);
 	return 0;
 }
 
-- 
2.11.0


From e44c142aa543f9aebfa583a10d1f481c87502004 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Thu, 26 Oct 2017 17:18:36 +0200
Subject: [PATCH 04/11] smbcontrol: Use messaging_dgm_forall

Doing stacktraces can be done locally only anyway

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 source3/utils/smbcontrol.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/source3/utils/smbcontrol.c b/source3/utils/smbcontrol.c
index 08c1530cdff..417358b7d5b 100644
--- a/source3/utils/smbcontrol.c
+++ b/source3/utils/smbcontrol.c
@@ -319,13 +319,9 @@ cleanup:
 	ptrace(PTRACE_DETACH, pid, NULL, NULL);
 }
 
-static int stack_trace_server(const struct server_id *id,
-			      uint32_t msg_flags,
-			      void *priv)
+static int stack_trace_server(pid_t pid, void *priv)
 {
-	if (procid_is_local(id)) {
-		print_stack_trace(procid_to_pid(id), (int *)priv);
-	}
+	print_stack_trace(pid, (int *)priv);
 	return 0;
 }
 
@@ -352,7 +348,7 @@ static bool do_daemon_stack_trace(struct tevent_context *ev_ctx,
 		 */
 		print_stack_trace(dest, &count);
 	} else {
-		serverid_traverse_read(stack_trace_server, &count);
+		messaging_dgm_forall(stack_trace_server, &count);
 	}
 
 	return True;
-- 
2.11.0


From 4966abd6b34ae7173934813c4f045222a8b3d5e8 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Sun, 5 Nov 2017 12:02:26 +0100
Subject: [PATCH 05/11] net: Remove "net serverid wipe"

This used to be a hygiene command for clustered node startup. In
clustered mode, CLEAR_IF_FIRST does not work, records can stay alive
by means of recovery. serverid.tdb will soon die, so remove this
command.

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 source3/utils/net_serverid.c | 33 ---------------------------------
 1 file changed, 33 deletions(-)

diff --git a/source3/utils/net_serverid.c b/source3/utils/net_serverid.c
index 942f7a49024..0fc7a0118d2 100644
--- a/source3/utils/net_serverid.c
+++ b/source3/utils/net_serverid.c
@@ -46,31 +46,6 @@ static int net_serverid_list(struct net_context *c, int argc,
 	return serverid_traverse_read(net_serverid_list_fn, NULL) ? 0 : -1;
 }
 
-static int net_serverid_wipe_fn(struct db_record *rec,
-				const struct server_id *id,
-				uint32_t msg_flags, void *private_data)
-{
-	NTSTATUS status;
-
-	if (!procid_is_local(id)) {
-		return 0;
-	}
-	status = dbwrap_record_delete(rec);
-	if (!NT_STATUS_IS_OK(status)) {
-		struct server_id_buf idbuf;
-		DEBUG(1, ("Could not delete serverid.tdb record %s: %s\n",
-			  server_id_str_buf(*id, &idbuf), nt_errstr(status)));
-	}
-	return 0;
-}
-
-static int net_serverid_wipe(struct net_context *c, int argc,
-			     const char **argv)
-{
-	return serverid_traverse(net_serverid_wipe_fn, NULL) ? 0 : -1;
-}
-
-
 struct wipedbs_record_marker {
 	struct wipedbs_record_marker *prev, *next;
 	TDB_DATA key, val;
@@ -705,14 +680,6 @@ int net_serverid(struct net_context *c, int argc, const char **argv)
 			   "    List all entries from serverid.tdb")
 		},
 		{
-			"wipe",
-			net_serverid_wipe,
-			NET_TRANSPORT_LOCAL,
-			N_("Wipe the serverid.tdb for the current node"),
-			N_("net serverid wipe\n"
-			   "    Wipe the serverid.tdb for the current node")
-		},
-		{
 			"wipedbs",
 			net_serverid_wipedbs,
 			NET_TRANSPORT_LOCAL,
-- 
2.11.0


From 8015c82751825458203acd14203229a59b19ed50 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Sun, 5 Nov 2017 12:09:08 +0100
Subject: [PATCH 06/11] net: Remove "net serverid list"

Traversing a clustered tdb is a pretty expensive operation. If someone
really needs this command-line interface, we can re-add it for the local
node using messaging_dgm_forall. If someone needs that globally, there's
the "onnode all" script that could be used. Alternatively, we could
implement an enhanced ping broadcast message also returning a processes
unique id.

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 source3/utils/net_serverid.c | 25 -------------------------
 1 file changed, 25 deletions(-)

diff --git a/source3/utils/net_serverid.c b/source3/utils/net_serverid.c
index 0fc7a0118d2..c826f95cc0d 100644
--- a/source3/utils/net_serverid.c
+++ b/source3/utils/net_serverid.c
@@ -29,23 +29,6 @@
 #include "util_tdb.h"
 #include "librpc/gen_ndr/ndr_open_files.h"
 
-static int net_serverid_list_fn(const struct server_id *id,
-				uint32_t msg_flags, void *priv)
-{
-	struct server_id_buf idbuf;
-	d_printf("%s %llu 0x%x\n", server_id_str_buf(*id, &idbuf),
-		 (unsigned long long)id->unique_id,
-		 (unsigned int)msg_flags);
-	return 0;
-}
-
-static int net_serverid_list(struct net_context *c, int argc,
-			     const char **argv)
-{
-	d_printf("pid unique_id msg_flags\n");
-	return serverid_traverse_read(net_serverid_list_fn, NULL) ? 0 : -1;
-}
-
 struct wipedbs_record_marker {
 	struct wipedbs_record_marker *prev, *next;
 	TDB_DATA key, val;
@@ -672,14 +655,6 @@ int net_serverid(struct net_context *c, int argc, const char **argv)
 {
 	struct functable func[] = {
 		{
-			"list",
-			net_serverid_list,
-			NET_TRANSPORT_LOCAL,
-			N_("List all entries from serverid.tdb"),
-			N_("net serverid list\n"
-			   "    List all entries from serverid.tdb")
-		},
-		{
 			"wipedbs",
 			net_serverid_wipedbs,
 			NET_TRANSPORT_LOCAL,
-- 
2.11.0


From bf751a871549f03e81b9646c62f19e2e83dedb53 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Tue, 25 Jul 2017 16:24:04 +0200
Subject: [PATCH 07/11] messaging: Remove an unused #define

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 source3/include/messages.h | 12 ------------
 1 file changed, 12 deletions(-)

diff --git a/source3/include/messages.h b/source3/include/messages.h
index 8d3b1d86e75..6a0340f5a7f 100644
--- a/source3/include/messages.h
+++ b/source3/include/messages.h
@@ -35,18 +35,6 @@
  */
 #define MSG_FLAG_LOWPRIORITY		0x80000000
 
-
-/*
- * ctdb gives us 64-bit server ids for messaging_send. This is done to avoid
- * pid clashes and to be able to register for special messages like "all
- * smbds".
- *
- * Normal individual server id's have the upper 32 bits to 0, I picked "1" for
- * Samba, other subsystems might use something else.
- */
-
-#define MSG_SRVID_SAMBA 0x0000000100000000LL
-
 #include "librpc/gen_ndr/server_id.h"
 #include "lib/util/data_blob.h"
 #include "system/network.h"
-- 
2.11.0


From 5792dad8d471cfcd3475bacb6c055957cb8af695 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Tue, 25 Jul 2017 17:10:27 +0200
Subject: [PATCH 08/11] messaging: Always register CTDB_SRVID_SAMBA_PROCESS

This will be used to broadcast to all processes, avoiding the costly
traverse of serverid.tdb.

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 source3/include/ctdb_srvids.h | 6 ++++++
 source3/lib/messages_ctdb.c   | 9 +++++++++
 2 files changed, 15 insertions(+)

diff --git a/source3/include/ctdb_srvids.h b/source3/include/ctdb_srvids.h
index 500b5069e67..b51a4585060 100644
--- a/source3/include/ctdb_srvids.h
+++ b/source3/include/ctdb_srvids.h
@@ -38,3 +38,9 @@
  * locally according to the non-clustered local notify.tdb
  */
 #define CTDB_SRVID_SAMBA_NOTIFY_PROXY  0xFE00000000000001LL
+
+/*
+ * SRVID for all processes that come from Samba. Used to be
+ * MSG_SRVID_SAMBA in the past. Now used for message_send_all.
+ */
+#define CTDB_SRVID_SAMBA_PROCESS  0xFE00000000000002LL
diff --git a/source3/lib/messages_ctdb.c b/source3/lib/messages_ctdb.c
index a2a7c215f23..66b9f55d256 100644
--- a/source3/lib/messages_ctdb.c
+++ b/source3/lib/messages_ctdb.c
@@ -26,6 +26,7 @@
 #include "lib/messages_util.h"
 #include "ctdbd_conn.h"
 #include "lib/cluster_support.h"
+#include "ctdb_srvids.h"
 
 struct messaging_ctdb_context;
 
@@ -111,6 +112,14 @@ int messaging_ctdb_init(const char *sockname, int timeout, uint64_t unique_id,
 		goto fail;
 	}
 
+	ret = register_with_ctdbd(ctx->conn, CTDB_SRVID_SAMBA_PROCESS,
+				  messaging_ctdb_recv, ctx);
+	if (ret != 0) {
+		DBG_DEBUG("register_with_ctdbd returned %s (%d)\n",
+			  strerror(ret), ret);
+		goto fail;
+	}
+
 	ret = register_with_ctdbd(ctx->conn, unique_id, NULL, NULL);
 	if (ret != 0) {
 		DBG_DEBUG("register_with_ctdbd returned %s (%d)\n",
-- 
2.11.0


From 594edfcab4399c9eee5d96d62aa4e498fec50916 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Sun, 5 Nov 2017 12:44:01 +0100
Subject: [PATCH 09/11] lib: Add messaging_send_all

This will replace message_send_all. With messaging_dgm_forall we have
a local broadcast mechanism, and ctdb can also broadcast
everywhere. So there's no need for a separate traverse/send mechanism.

There's no good error reporting mechanism for broadcasting, so make
this function void.

This drops the message_type filtering. I believe that this does not matter in
practice, since messaging is a lot cheaper with dgm instead of the old tdb
based messaging. If someone presents a use case where this matters, nowadays
I'd much rather extend the messaging_dgm lock file format (where the unique id
lives right now) with the filter bits.

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 source3/include/messages.h |  2 ++
 source3/lib/messages.c     | 74 ++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 76 insertions(+)

diff --git a/source3/include/messages.h b/source3/include/messages.h
index 6a0340f5a7f..29c394af317 100644
--- a/source3/include/messages.h
+++ b/source3/include/messages.h
@@ -96,6 +96,8 @@ NTSTATUS messaging_send_iov(struct messaging_context *msg_ctx,
 			    struct server_id server, uint32_t msg_type,
 			    const struct iovec *iov, int iovlen,
 			    const int *fds, size_t num_fds);
+void messaging_send_all(struct messaging_context *msg_ctx,
+			int msg_type, const void *buf, size_t len);
 
 struct tevent_req *messaging_filtered_read_send(
 	TALLOC_CTX *mem_ctx, struct tevent_context *ev,
diff --git a/source3/lib/messages.c b/source3/lib/messages.c
index 01029b2d68b..a0a3f9fb1ba 100644
--- a/source3/lib/messages.c
+++ b/source3/lib/messages.c
@@ -60,6 +60,12 @@
 #include "lib/messages_ctdb_ref.h"
 #include "lib/messages_util.h"
 #include "cluster_support.h"
+#include "ctdbd_conn.h"
+#include "ctdb_srvids.h"
+
+#ifdef CLUSTER_SUPPORT
+#include "ctdb_protocol.h"
+#endif
 
 struct messaging_callback {
 	struct messaging_callback *prev, *next;
@@ -513,6 +519,7 @@ static NTSTATUS messaging_init_internal(TALLOC_CTX *mem_ctx,
 	}
 	talloc_set_destructor(ctx, messaging_context_destructor);
 
+#ifdef CLUSTER_SUPPORT
 	if (lp_clustering()) {
 		ctx->msg_ctdb_ref = messaging_ctdb_ref(
 			ctx, ctx->event_ctx,
@@ -525,6 +532,8 @@ static NTSTATUS messaging_init_internal(TALLOC_CTX *mem_ctx,
 			goto done;
 		}
 	}
+#endif
+
 	ctx->id.vnn = get_my_vnn();
 
 	ctx->names_db = server_id_db_init(ctx,
@@ -836,6 +845,71 @@ NTSTATUS messaging_send_iov(struct messaging_context *msg_ctx,
 	return NT_STATUS_OK;
 }
 
+struct send_all_state {
+	struct messaging_context *msg_ctx;
+	int msg_type;
+	const void *buf;
+	size_t len;
+};
+
+static int send_all_fn(pid_t pid, void *private_data)
+{
+	struct send_all_state *state = private_data;
+	NTSTATUS status;
+
+	status = messaging_send_buf(state->msg_ctx, pid_to_procid(pid),
+				    state->msg_type, state->buf, state->len);
+	if (!NT_STATUS_IS_OK(status)) {
+		DBG_WARNING("messaging_send_buf to %ju failed: %s\n",
+			    (uintmax_t)pid, nt_errstr(status));
+	}
+
+	return 0;
+}
+
+void messaging_send_all(struct messaging_context *msg_ctx,
+			int msg_type, const void *buf, size_t len)
+{
+	struct send_all_state state = {
+		.msg_ctx = msg_ctx, .msg_type = msg_type,
+		.buf = buf, .len = len
+	};
+	int ret;
+
+#ifdef CLUSTER_SUPPORT
+	if (lp_clustering()) {
+		struct ctdbd_connection *conn = messaging_ctdb_connection();
+		uint8_t msghdr[MESSAGE_HDR_LENGTH];
+		struct iovec iov[] = {
+			{ .iov_base = msghdr,
+			  .iov_len = sizeof(msghdr) },
+			{ .iov_base = discard_const_p(void, buf),
+			  .iov_len = len }
+		};
+
+		message_hdr_put(msghdr, msg_type, messaging_server_id(msg_ctx),
+				(struct server_id) {0});
+
+		ret = ctdbd_messaging_send_iov(
+			conn, CTDB_BROADCAST_CONNECTED,
+			CTDB_SRVID_SAMBA_PROCESS,
+			iov, ARRAY_SIZE(iov));
+		if (ret != 0) {
+			DBG_WARNING("ctdbd_messaging_send_iov failed: %s\n",
+				    strerror(ret));
+		}
+
+		return;
+	}
+#endif
+
+	ret = messaging_dgm_forall(send_all_fn, &state);
+	if (ret != 0) {
+		DBG_WARNING("messaging_dgm_forall failed: %s\n",
+			    strerror(ret));
+	}
+}
+
 static struct messaging_rec *messaging_rec_dup(TALLOC_CTX *mem_ctx,
 					       struct messaging_rec *rec)
 {
-- 
2.11.0


From 70d427395131b6d916013e57e1f8ff9ad683ef5b Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Sun, 5 Nov 2017 12:54:10 +0100
Subject: [PATCH 10/11] lib: Use messaging_send_all instead of message_send_all

Just a global search&replace

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 source3/passdb/pdb_interface.c              | 8 ++++----
 source3/printing/queue_process.c            | 2 +-
 source3/rpc_server/fss/srv_fss_agent.c      | 9 +++++----
 source3/rpc_server/spoolss/srv_spoolss_nt.c | 4 ++--
 source3/rpc_server/srvsvc/srv_srvsvc_nt.c   | 8 ++++----
 source3/smbd/smbd_cleanupd.c                | 2 +-
 source3/smbd/statcache.c                    | 8 ++++----
 source3/utils/smbcontrol.c                  | 6 ++----
 8 files changed, 23 insertions(+), 24 deletions(-)

diff --git a/source3/passdb/pdb_interface.c b/source3/passdb/pdb_interface.c
index 9827046187e..7fdc33c4fa7 100644
--- a/source3/passdb/pdb_interface.c
+++ b/source3/passdb/pdb_interface.c
@@ -648,10 +648,10 @@ NTSTATUS pdb_delete_user(TALLOC_CTX *mem_ctx, struct samu *sam_acct)
 		 * just return */
 		return status;
 	}
-	message_send_all(server_messaging_context(),
-			 ID_CACHE_DELETE,
-			 msg_data,
-			 strlen(msg_data) + 1);
+	messaging_send_all(server_messaging_context(),
+			   ID_CACHE_DELETE,
+			   msg_data,
+			   strlen(msg_data) + 1);
 
 	TALLOC_FREE(msg_data);
 	return status;
diff --git a/source3/printing/queue_process.c b/source3/printing/queue_process.c
index 381ef348805..7a3b80aae0c 100644
--- a/source3/printing/queue_process.c
+++ b/source3/printing/queue_process.c
@@ -144,7 +144,7 @@ static void reload_pcap_change_notify(struct tevent_context *ev,
 	 */
 	delete_and_reload_printers_full(ev, msg_ctx);
 
-	message_send_all(msg_ctx, MSG_PRINTER_PCAP, NULL, 0);
+	messaging_send_all(msg_ctx, MSG_PRINTER_PCAP, NULL, 0);
 }
 
 struct bq_state {
diff --git a/source3/rpc_server/fss/srv_fss_agent.c b/source3/rpc_server/fss/srv_fss_agent.c
index c0bf7ddd11a..0e5c82ec5e9 100644
--- a/source3/rpc_server/fss/srv_fss_agent.c
+++ b/source3/rpc_server/fss/srv_fss_agent.c
@@ -1235,7 +1235,7 @@ uint32_t _fss_ExposeShadowCopySet(struct pipes_struct *p,
 	}
 	unbecome_root();
 
-	message_send_all(p->msg_ctx, MSG_SMB_CONF_UPDATED, NULL, 0);
+	messaging_send_all(p->msg_ctx, MSG_SMB_CONF_UPDATED, NULL, 0);
 	for (sc = sc_set->scs; sc; sc = sc->next) {
 		struct fss_sc_smap *sm;
 		for (sm = sc->smaps; sm; sm = sm->next)
@@ -1577,7 +1577,7 @@ static NTSTATUS sc_smap_unexpose(struct messaging_context *msg_ctx,
 			ret = NT_STATUS_UNSUCCESSFUL;
 			goto err_cancel;
 		}
-		message_send_all(msg_ctx, MSG_SMB_CONF_UPDATED, NULL, 0);
+		messaging_send_all(msg_ctx, MSG_SMB_CONF_UPDATED, NULL, 0);
 	} else {
 		ret = NT_STATUS_OK;
 		goto err_cancel;
@@ -1660,8 +1660,9 @@ uint32_t _fss_DeleteShareMapping(struct pipes_struct *p,
 		goto err_tmp_free;
 	}
 
-	message_send_all(p->msg_ctx, MSG_SMB_FORCE_TDIS, sc_smap->sc_share_name,
-			 strlen(sc_smap->sc_share_name) + 1);
+	messaging_send_all(p->msg_ctx, MSG_SMB_FORCE_TDIS,
+			   sc_smap->sc_share_name,
+			   strlen(sc_smap->sc_share_name) + 1);
 
 	if (sc->smaps_count > 1) {
 		/* do not delete the underlying snapshot - still in use */
diff --git a/source3/rpc_server/spoolss/srv_spoolss_nt.c b/source3/rpc_server/spoolss/srv_spoolss_nt.c
index d8b6023e5e9..f0226ba9441 100644
--- a/source3/rpc_server/spoolss/srv_spoolss_nt.c
+++ b/source3/rpc_server/spoolss/srv_spoolss_nt.c
@@ -368,7 +368,7 @@ static WERROR delete_printer_hook(TALLOC_CTX *ctx, struct security_token *token,
 	ret = smbrun(command, NULL, NULL);
 	if (ret == 0) {
 		/* Tell everyone we updated smb.conf. */
-		message_send_all(msg_ctx, MSG_SMB_CONF_UPDATED, NULL, 0);
+		messaging_send_all(msg_ctx, MSG_SMB_CONF_UPDATED, NULL, 0);
 	}
 
 	if ( is_print_op )
@@ -6433,7 +6433,7 @@ static bool add_printer_hook(TALLOC_CTX *ctx, struct security_token *token,
 	ret = smbrun(command, &fd, NULL);
 	if (ret == 0) {
 		/* Tell everyone we updated smb.conf. */
-		message_send_all(msg_ctx, MSG_SMB_CONF_UPDATED, NULL, 0);
+		messaging_send_all(msg_ctx, MSG_SMB_CONF_UPDATED, NULL, 0);
 	}
 
 	if ( is_print_op )
diff --git a/source3/rpc_server/srvsvc/srv_srvsvc_nt.c b/source3/rpc_server/srvsvc/srv_srvsvc_nt.c
index 899feb22da9..2ff8e64fccc 100644
--- a/source3/rpc_server/srvsvc/srv_srvsvc_nt.c
+++ b/source3/rpc_server/srvsvc/srv_srvsvc_nt.c
@@ -1908,8 +1908,8 @@ WERROR _srvsvc_NetShareSetInfo(struct pipes_struct *p,
 		ret = smbrun(command, NULL, NULL);
 		if (ret == 0) {
 			/* Tell everyone we updated smb.conf. */
-			message_send_all(p->msg_ctx, MSG_SMB_CONF_UPDATED,
-					 NULL, 0);
+			messaging_send_all(p->msg_ctx, MSG_SMB_CONF_UPDATED,
+					   NULL, 0);
 		}
 
 		if ( is_disk_op )
@@ -2111,7 +2111,7 @@ WERROR _srvsvc_NetShareAdd(struct pipes_struct *p,
 	ret = smbrun(command, NULL, NULL);
 	if (ret == 0) {
 		/* Tell everyone we updated smb.conf. */
-		message_send_all(p->msg_ctx, MSG_SMB_CONF_UPDATED, NULL, 0);
+		messaging_send_all(p->msg_ctx, MSG_SMB_CONF_UPDATED, NULL, 0);
 	}
 
 	if ( is_disk_op )
@@ -2218,7 +2218,7 @@ WERROR _srvsvc_NetShareDel(struct pipes_struct *p,
 	ret = smbrun(command, NULL, NULL);
 	if (ret == 0) {
 		/* Tell everyone we updated smb.conf. */
-		message_send_all(p->msg_ctx, MSG_SMB_CONF_UPDATED, NULL, 0);
+		messaging_send_all(p->msg_ctx, MSG_SMB_CONF_UPDATED, NULL, 0);
 	}
 
 	if ( is_disk_op )
diff --git a/source3/smbd/smbd_cleanupd.c b/source3/smbd/smbd_cleanupd.c
index 90c12cdcd7c..cfb75c971be 100644
--- a/source3/smbd/smbd_cleanupd.c
+++ b/source3/smbd/smbd_cleanupd.c
@@ -98,7 +98,7 @@ static void smbd_cleanupd_unlock(struct messaging_context *msg,
 	DBG_WARNING("Cleaning up brl and lock database after unclean "
 		    "shutdown\n");
 
-	message_send_all(msg, MSG_SMB_UNLOCK, NULL, 0);
+	messaging_send_all(msg, MSG_SMB_UNLOCK, NULL, 0);
 
 	brl_revalidate(msg, private_data, msg_type, server_id, data);
 }
diff --git a/source3/smbd/statcache.c b/source3/smbd/statcache.c
index 2023d52fb84..d49f5eebdf0 100644
--- a/source3/smbd/statcache.c
+++ b/source3/smbd/statcache.c
@@ -354,10 +354,10 @@ void smbd_send_stat_cache_delete_message(struct messaging_context *msg_ctx,
 					 const char *name)
 {
 #ifdef DEVELOPER
-	message_send_all(msg_ctx,
-			MSG_SMB_STAT_CACHE_DELETE,
-			name,
-			strlen(name)+1);
+	messaging_send_all(msg_ctx,
+			   MSG_SMB_STAT_CACHE_DELETE,
+			   name,
+			   strlen(name)+1);
 #endif
 }
 
diff --git a/source3/utils/smbcontrol.c b/source3/utils/smbcontrol.c
index 417358b7d5b..0f6dacce20d 100644
--- a/source3/utils/smbcontrol.c
+++ b/source3/utils/smbcontrol.c
@@ -61,16 +61,14 @@ static bool send_message(struct messaging_context *msg_ctx,
 			 struct server_id pid, int msg_type,
 			 const void *buf, int len)
 {
-	bool ret;
-
 	if (procid_to_pid(&pid) != 0)
 		return NT_STATUS_IS_OK(
 			messaging_send_buf(msg_ctx, pid, msg_type,
 					   (const uint8_t *)buf, len));
 
-	ret = message_send_all(msg_ctx, msg_type, buf, len);
+	messaging_send_all(msg_ctx, msg_type, buf, len);
 
-	return ret;
+	return true;
 }
 
 static void smbcontrol_timeout(struct tevent_context *event_ctx,
-- 
2.11.0


From bebc8201be2f3c5255b631d67e20fd2227380b1d Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Sun, 5 Nov 2017 12:58:09 +0100
Subject: [PATCH 11/11] lib: Remove unused serverid.tdb

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 source3/include/serverid.h       |  49 ------
 source3/lib/serverid.c           | 344 ---------------------------------------
 source3/nmbd/nmbd.c              |  10 --
 source3/printing/nt_printing.c   |   4 -
 source3/printing/queue_process.c |   7 -
 source3/printing/spoolssd.c      |  13 --
 source3/rpc_server/epmd.c        |   9 -
 source3/rpc_server/fssd.c        |   9 -
 source3/rpc_server/lsasd.c       |  11 --
 source3/rpc_server/mdssd.c       |  11 --
 source3/smbd/negprot.c           |   8 -
 source3/smbd/process.c           |   9 -
 source3/smbd/scavenger.c         |   8 -
 source3/smbd/server.c            |  20 ---
 source3/smbd/server_exit.c       |   8 -
 source3/smbd/smbd_cleanupd.c     |  14 --
 source3/torture/vfstest.c        |   2 -
 source3/winbindd/winbindd.c      |  14 --
 18 files changed, 550 deletions(-)

diff --git a/source3/include/serverid.h b/source3/include/serverid.h
index a73a6f6986c..89487cfa62d 100644
--- a/source3/include/serverid.h
+++ b/source3/include/serverid.h
@@ -21,60 +21,11 @@
 #define __SERVERID_H__
 
 #include "replace.h"
-#include "lib/dbwrap/dbwrap.h"
 #include "librpc/gen_ndr/server_id.h"
 
-/* Flags to classify messages - used in message_send_all() */
-/* Sender will filter by flag. */
-
-#define FLAG_MSG_GENERAL		0x0001
-#define FLAG_MSG_SMBD			0x0002
-#define FLAG_MSG_NMBD			0x0004
-#define FLAG_MSG_WINBIND		0x0008
-#define FLAG_MSG_PRINT_GENERAL		0x0010
-/* dbwrap messages 4001-4999 */
-#define FLAG_MSG_DBWRAP			0x0020
-
-/*
- * Register a server with its unique id
- */
-bool serverid_register(const struct server_id id, uint32_t msg_flags);
-
-/*
- * De-register a server with its unique id
- */
-bool serverid_deregister(const struct server_id id);
-
 /*
  * Check existence of a server id
  */
 bool serverid_exists(const struct server_id *id);
 
-/*
- * Walk the list of server_ids registered
- */
-bool serverid_traverse(int (*fn)(struct db_record *rec,
-				 const struct server_id *id,
-				 uint32_t msg_flags,
-				 void *private_data),
-		       void *private_data);
-
-/*
- * Walk the list of server_ids registered read-only
- */
-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(TALLOC_CTX *mem_ctx);
-
-struct messaging_context;
-
-bool message_send_all(struct messaging_context *msg_ctx,
-		      int msg_type,
-		      const void *buf, size_t len);
-
 #endif
diff --git a/source3/lib/serverid.c b/source3/lib/serverid.c
index 9fd506df5fd..b4125cb9142 100644
--- a/source3/lib/serverid.c
+++ b/source3/lib/serverid.c
@@ -18,157 +18,13 @@
 */
 
 #include "includes.h"
-#include "system/filesys.h"
 #include "lib/util/server_id.h"
 #include "serverid.h"
-#include "util_tdb.h"
-#include "dbwrap/dbwrap.h"
-#include "dbwrap/dbwrap_open.h"
-#include "lib/tdb_wrap/tdb_wrap.h"
 #include "lib/param/param.h"
 #include "ctdbd_conn.h"
-#include "messages.h"
 #include "lib/messages_ctdb.h"
 #include "lib/messages_dgm.h"
 
-struct serverid_key {
-	pid_t pid;
-	uint32_t task_id;
-	uint32_t vnn;
-};
-
-struct serverid_data {
-	uint64_t unique_id;
-	uint32_t msg_flags;
-};
-
-static struct db_context *serverid_db(void)
-{
-	static struct db_context *db;
-	char *db_path;
-
-	if (db != NULL) {
-		return db;
-	}
-
-	db_path = lock_path("serverid.tdb");
-	if (db_path == NULL) {
-		return NULL;
-	}
-
-	db = db_open(NULL, db_path, 0,
-		     TDB_DEFAULT|TDB_CLEAR_IF_FIRST|TDB_INCOMPATIBLE_HASH,
-		     O_RDWR|O_CREAT, 0644, DBWRAP_LOCK_ORDER_2,
-		     DBWRAP_FLAG_NONE);
-	TALLOC_FREE(db_path);
-	return db;
-}
-
-bool serverid_parent_init(TALLOC_CTX *mem_ctx)
-{
-	struct db_context *db;
-
-	db = serverid_db();
-	if (db == NULL) {
-		DEBUG(1, ("could not open serverid.tdb: %s\n",
-			  strerror(errno)));
-		return false;
-	}
-
-	return true;
-}
-
-static void serverid_fill_key(const struct server_id *id,
-			      struct serverid_key *key)
-{
-	ZERO_STRUCTP(key);
-	key->pid = id->pid;
-	key->task_id = id->task_id;
-	key->vnn = id->vnn;
-}
-
-bool serverid_register(const struct server_id id, uint32_t msg_flags)
-{
-	struct db_context *db;
-	struct serverid_key key;
-	struct serverid_data data;
-	struct db_record *rec;
-	TDB_DATA tdbkey, tdbdata;
-	NTSTATUS status;
-	bool ret = false;
-
-	db = serverid_db();
-	if (db == NULL) {
-		return false;
-	}
-
-	serverid_fill_key(&id, &key);
-	tdbkey = make_tdb_data((uint8_t *)&key, sizeof(key));
-
-	rec = dbwrap_fetch_locked(db, talloc_tos(), tdbkey);
-	if (rec == NULL) {
-		DEBUG(1, ("Could not fetch_lock serverid.tdb record\n"));
-		return false;
-	}
-
-	ZERO_STRUCT(data);
-	data.unique_id = id.unique_id;
-	data.msg_flags = msg_flags;
-
-	tdbdata = make_tdb_data((uint8_t *)&data, sizeof(data));
-	status = dbwrap_record_store(rec, tdbdata, 0);
-	if (!NT_STATUS_IS_OK(status)) {
-		DEBUG(1, ("Storing serverid.tdb record failed: %s\n",
-			  nt_errstr(status)));
-		goto done;
-	}
-
-	if (lp_clustering()) {
-		register_with_ctdbd(messaging_ctdb_connection(), id.unique_id,
-				    NULL, NULL);
-	}
-
-	ret = true;
-done:
-	TALLOC_FREE(rec);
-	return ret;
-}
-
-bool serverid_deregister(struct server_id id)
-{
-	struct db_context *db;
-	struct serverid_key key;
-	struct db_record *rec;
-	TDB_DATA tdbkey;
-	NTSTATUS status;
-	bool ret = false;
-
-	db = serverid_db();
-	if (db == NULL) {
-		return false;
-	}
-
-	serverid_fill_key(&id, &key);
-	tdbkey = make_tdb_data((uint8_t *)&key, sizeof(key));
-
-	rec = dbwrap_fetch_locked(db, talloc_tos(), tdbkey);
-	if (rec == NULL) {
-		DEBUG(1, ("Could not fetch_lock serverid.tdb record\n"));
-		return false;
-	}
-
-	status = dbwrap_record_delete(rec);
-	if (!NT_STATUS_IS_OK(status)) {
-		DEBUG(1, ("Deleting serverid.tdb record failed: %s\n",
-			  nt_errstr(status)));
-		goto done;
-	}
-	ret = true;
-done:
-	TALLOC_FREE(rec);
-	return ret;
-}
-
 static bool serverid_exists_local(const struct server_id *id)
 {
 	bool exists = process_exists_by_pid(id->pid);
@@ -204,203 +60,3 @@ bool serverid_exists(const struct server_id *id)
 
 	return false;
 }
-
-static bool serverid_rec_parse(const struct db_record *rec,
-			       struct server_id *id, uint32_t *msg_flags)
-{
-	struct serverid_key key;
-	struct serverid_data data;
-	TDB_DATA tdbkey;
-	TDB_DATA tdbdata;
-
-	tdbkey = dbwrap_record_get_key(rec);
-	tdbdata = dbwrap_record_get_value(rec);
-
-	if (tdbkey.dsize != sizeof(key)) {
-		DEBUG(1, ("Found invalid key length %d in serverid.tdb\n",
-			  (int)tdbkey.dsize));
-		return false;
-	}
-	if (tdbdata.dsize != sizeof(data)) {
-		DEBUG(1, ("Found invalid value length %d in serverid.tdb\n",
-			  (int)tdbdata.dsize));
-		return false;
-	}
-
-	memcpy(&key, tdbkey.dptr, sizeof(key));
-	memcpy(&data, tdbdata.dptr, sizeof(data));
-
-	id->pid = key.pid;
-	id->task_id = key.task_id;
-	id->vnn = key.vnn;
-	id->unique_id = data.unique_id;
-	*msg_flags = data.msg_flags;
-	return true;
-}
-
-struct serverid_traverse_read_state {
-	int (*fn)(const struct server_id *id, uint32_t msg_flags,
-		  void *private_data);
-	void *private_data;
-};
-
-static int serverid_traverse_read_fn(struct db_record *rec, void *private_data)
-{
-	struct serverid_traverse_read_state *state =
-		(struct serverid_traverse_read_state *)private_data;
-	struct server_id id;
-	uint32_t msg_flags;
-
-	if (!serverid_rec_parse(rec, &id, &msg_flags)) {
-		return 0;
-	}
-	return state->fn(&id, msg_flags,state->private_data);
-}
-
-bool serverid_traverse_read(int (*fn)(const struct server_id *id,
-				      uint32_t msg_flags, void *private_data),
-			    void *private_data)
-{
-	struct db_context *db;
-	struct serverid_traverse_read_state state;
-	NTSTATUS status;
-
-	db = serverid_db();
-	if (db == NULL) {
-		return false;
-	}
-	state.fn = fn;
-	state.private_data = private_data;
-
-	status = dbwrap_traverse_read(db, serverid_traverse_read_fn, &state,
-				      NULL);
-	return NT_STATUS_IS_OK(status);
-}
-
-struct serverid_traverse_state {
-	int (*fn)(struct db_record *rec, const struct server_id *id,
-		  uint32_t msg_flags, void *private_data);
-	void *private_data;
-};
-
-static int serverid_traverse_fn(struct db_record *rec, void *private_data)
-{
-	struct serverid_traverse_state *state =
-		(struct serverid_traverse_state *)private_data;
-	struct server_id id;
-	uint32_t msg_flags;
-
-	if (!serverid_rec_parse(rec, &id, &msg_flags)) {
-		return 0;
-	}
-	return state->fn(rec, &id, msg_flags, state->private_data);
-}
-
-bool serverid_traverse(int (*fn)(struct db_record *rec,
-				 const struct server_id *id,
-				 uint32_t msg_flags, void *private_data),
-			    void *private_data)
-{
-	struct db_context *db;
-	struct serverid_traverse_state state;
-	NTSTATUS status;
-
-	db = serverid_db();
-	if (db == NULL) {
-		return false;
-	}
-	state.fn = fn;
-	state.private_data = private_data;
-
-	status = dbwrap_traverse(db, serverid_traverse_fn, &state, NULL);
-	return NT_STATUS_IS_OK(status);
-}
-
-struct msg_all {
-	struct messaging_context *msg_ctx;
-	int msg_type;
-	uint32_t msg_flag;
-	const void *buf;
-	size_t len;
-	int n_sent;
-};
-
-/****************************************************************************
- Send one of the messages for the broadcast.
-****************************************************************************/
-
-static int traverse_fn(struct db_record *rec, const struct server_id *id,
-		       uint32_t msg_flags, void *state)
-{
-	struct msg_all *msg_all = (struct msg_all *)state;
-	NTSTATUS status;
-
-	/* Don't send if the receiver hasn't registered an interest. */
-
-	if((msg_flags & msg_all->msg_flag) == 0) {
-		return 0;
-	}
-
-	/* If the msg send fails because the pid was not found (i.e. smbd died),
-	 * the msg has already been deleted from the messages.tdb.*/
-
-	status = messaging_send_buf(msg_all->msg_ctx, *id, msg_all->msg_type,
-				    (const uint8_t *)msg_all->buf, msg_all->len);
-
-	if (NT_STATUS_EQUAL(status, NT_STATUS_INVALID_HANDLE)) {
-		struct server_id_buf idbuf;
-
-		/*
-		 * If the pid was not found delete the entry from
-		 * serverid.tdb
-		 */
-
-		DEBUG(2, ("pid %s doesn't exist\n",
-			  server_id_str_buf(*id, &idbuf)));
-
-		dbwrap_record_delete(rec);
-	}
-	msg_all->n_sent++;
-	return 0;
-}
-
-/**
- * Send a message to all smbd processes.
- *
- * It isn't very efficient, but should be OK for the sorts of
- * applications that use it. When we need efficient broadcast we can add
- * it.
- *
- * @retval True for success.
- **/
-bool message_send_all(struct messaging_context *msg_ctx,
-		      int msg_type,
-		      const void *buf, size_t len)
-{
-	struct msg_all msg_all;
-
-	msg_all.msg_type = msg_type;
-	if (msg_type < 0x100) {
-		msg_all.msg_flag = FLAG_MSG_GENERAL;
-	} else if (msg_type > 0x100 && msg_type < 0x200) {
-		msg_all.msg_flag = FLAG_MSG_NMBD;
-	} else if (msg_type > 0x200 && msg_type < 0x300) {
-		msg_all.msg_flag = FLAG_MSG_PRINT_GENERAL;
-	} else if (msg_type > 0x300 && msg_type < 0x400) {
-		msg_all.msg_flag = FLAG_MSG_SMBD;
-	} else if (msg_type > 0x400 && msg_type < 0x600) {
-		msg_all.msg_flag = FLAG_MSG_WINBIND;
-	} else if (msg_type > 4000 && msg_type < 5000) {
-		msg_all.msg_flag = FLAG_MSG_DBWRAP;
-	} else {
-		return false;
-	}
-
-	msg_all.buf = buf;
-	msg_all.len = len;
-	msg_all.n_sent = 0;
-	msg_all.msg_ctx = msg_ctx;
-
-	serverid_traverse(traverse_fn, &msg_all);
-	return true;
-}
diff --git a/source3/nmbd/nmbd.c b/source3/nmbd/nmbd.c
index 14eaef647d0..9be708a9c02 100644
--- a/source3/nmbd/nmbd.c
+++ b/source3/nmbd/nmbd.c
@@ -70,7 +70,6 @@ static void terminate(struct messaging_context *msg)
 	kill_async_dns_child();
 
 	gencache_stabilize();
-	serverid_deregister(messaging_server_id(msg));
 
 	pidfile_unlink(lp_pid_directory(), "nmbd");
 
@@ -1015,15 +1014,6 @@ static bool open_sockets(bool isdaemon, int port)
 		exit(1);
 	}
 
-	/* get broadcast messages */
-
-	if (!serverid_register(messaging_server_id(msg),
-				FLAG_MSG_GENERAL |
-				FLAG_MSG_NMBD |
-				FLAG_MSG_DBWRAP)) {
-		exit_daemon("Could not register NMBD process in serverid.tdb", EACCES);
-	}
-
 	messaging_register(msg, NULL, MSG_FORCE_ELECTION,
 			   nmbd_message_election);
 #if 0
diff --git a/source3/printing/nt_printing.c b/source3/printing/nt_printing.c
index 932d4d76df0..2e500f18c7d 100644
--- a/source3/printing/nt_printing.c
+++ b/source3/printing/nt_printing.c
@@ -243,10 +243,6 @@ bool nt_printing_init(struct messaging_context *msg_ctx)
 	messaging_register(msg_ctx, NULL, MSG_PRINTER_DRVUPGRADE,
 			forward_drv_upgrade_printer_msg);
 
-	/* of course, none of the message callbacks matter if you don't
-	   tell messages.c that you interested in receiving PRINT_GENERAL
-	   msgs.  This is done in serverid_register() */
-
 	if ( lp_security() == SEC_ADS ) {
 		win_rc = check_published_printers(msg_ctx);
 		if (!W_ERROR_IS_OK(win_rc))
diff --git a/source3/printing/queue_process.c b/source3/printing/queue_process.c
index 7a3b80aae0c..24708c19537 100644
--- a/source3/printing/queue_process.c
+++ b/source3/printing/queue_process.c
@@ -27,7 +27,6 @@
 #include "printing.h"
 #include "printing/pcap.h"
 #include "printing/queue_process.h"
-#include "serverid.h"
 #include "locking/proto.h"
 #include "smbd/smbd.h"
 #include "rpc_server/rpc_config.h"
@@ -392,12 +391,6 @@ pid_t start_background_queue(struct tevent_context *ev,
 			exit(1);
 		}
 
-		if (!serverid_register(messaging_server_id(msg_ctx),
-				       FLAG_MSG_GENERAL |
-				       FLAG_MSG_PRINT_GENERAL)) {
-			exit(1);
-		}
-
 		if (!locking_init()) {
 			exit(1);
 		}
diff --git a/source3/printing/spoolssd.c b/source3/printing/spoolssd.c
index 48a914ef6de..2b08d580f35 100644
--- a/source3/printing/spoolssd.c
+++ b/source3/printing/spoolssd.c
@@ -17,7 +17,6 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 #include "includes.h"
-#include "serverid.h"
 #include "smbd/smbd.h"
 
 #include "messages.h"
@@ -280,12 +279,6 @@ static bool spoolss_child_init(struct tevent_context *ev_ctx,
 		return false;
 	}
 
-	if (!serverid_register(messaging_server_id(msg_ctx),
-				FLAG_MSG_GENERAL |
-				FLAG_MSG_PRINT_GENERAL)) {
-		return false;
-	}
-
 	if (!locking_init()) {
 		return false;
 	}
@@ -694,12 +687,6 @@ pid_t start_spoolssd(struct tevent_context *ev_ctx,
 		exit(1);
 	}
 
-	if (!serverid_register(messaging_server_id(msg_ctx),
-				FLAG_MSG_GENERAL |
-				FLAG_MSG_PRINT_GENERAL)) {
-		exit(1);
-	}
-
 	if (!locking_init()) {
 		exit(1);
 	}
diff --git a/source3/rpc_server/epmd.c b/source3/rpc_server/epmd.c
index faf60f5c95b..0b94a1cf4ef 100644
--- a/source3/rpc_server/epmd.c
+++ b/source3/rpc_server/epmd.c
@@ -21,7 +21,6 @@
 
 #include "includes.h"
 
-#include "serverid.h"
 #include "ntdomain.h"
 #include "messages.h"
 
@@ -171,14 +170,6 @@ void start_epmd(struct tevent_context *ev_ctx,
 	epmd_setup_sig_term_handler(ev_ctx);
 	epmd_setup_sig_hup_handler(ev_ctx, msg_ctx);
 
-	ok = serverid_register(messaging_server_id(msg_ctx),
-			       FLAG_MSG_GENERAL |
-			       FLAG_MSG_PRINT_GENERAL);
-	if (!ok) {
-		DEBUG(0, ("Failed to register serverid in epmd!\n"));
-		exit(1);
-	}
-
 	messaging_register(msg_ctx,
 			   ev_ctx,
 			   MSG_SMB_CONF_UPDATED,
diff --git a/source3/rpc_server/fssd.c b/source3/rpc_server/fssd.c
index 8f55aff6f85..3116679179a 100644
--- a/source3/rpc_server/fssd.c
+++ b/source3/rpc_server/fssd.c
@@ -22,7 +22,6 @@
 
 #include "includes.h"
 
-#include "serverid.h"
 #include "ntdomain.h"
 #include "messages.h"
 
@@ -182,14 +181,6 @@ 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(messaging_server_id(msg_ctx),
-			       FLAG_MSG_GENERAL |
-			       FLAG_MSG_PRINT_GENERAL);
-	if (!ok) {
-		DEBUG(0, ("Failed to register serverid in fssd!\n"));
-		exit(1);
-	}
-
 	messaging_register(msg_ctx,
 			   ev_ctx,
 			   MSG_SMB_CONF_UPDATED,
diff --git a/source3/rpc_server/lsasd.c b/source3/rpc_server/lsasd.c
index 8cd89a9fd38..08e9fe26a74 100644
--- a/source3/rpc_server/lsasd.c
+++ b/source3/rpc_server/lsasd.c
@@ -20,7 +20,6 @@
  */
 
 #include "includes.h"
-#include "serverid.h"
 #include "messages.h"
 #include "ntdomain.h"
 
@@ -261,11 +260,6 @@ static bool lsasd_child_init(struct tevent_context *ev_ctx,
 		return false;
 	}
 
-	if (!serverid_register(messaging_server_id(msg_ctx),
-			       FLAG_MSG_GENERAL)) {
-		return false;
-	}
-
 	messaging_register(msg_ctx, ev_ctx,
 			   MSG_SMB_CONF_UPDATED, lsasd_smb_conf_updated);
 	messaging_register(msg_ctx, ev_ctx,
@@ -897,11 +891,6 @@ void start_lsasd(struct tevent_context *ev_ctx,
 		exit(1);
 	}
 
-	if (!serverid_register(messaging_server_id(msg_ctx),
-			       FLAG_MSG_GENERAL)) {
-		exit(1);
-	}
-
 	messaging_register(msg_ctx,
 			   ev_ctx,
 			   MSG_SMB_CONF_UPDATED,
diff --git a/source3/rpc_server/mdssd.c b/source3/rpc_server/mdssd.c
index daff5f02e67..d5c05c7e8e9 100644
--- a/source3/rpc_server/mdssd.c
+++ b/source3/rpc_server/mdssd.c
@@ -20,7 +20,6 @@
  */
 
 #include "includes.h"
-#include "serverid.h"
 #include "messages.h"
 #include "ntdomain.h"
 
@@ -219,11 +218,6 @@ static bool mdssd_child_init(struct tevent_context *ev_ctx,
 		return false;
 	}
 
-	if (!serverid_register(messaging_server_id(msg_ctx),
-			       FLAG_MSG_GENERAL)) {
-		return false;
-	}
-
 	messaging_register(msg_ctx, ev_ctx,
 			   MSG_SMB_CONF_UPDATED, mdssd_smb_conf_updated);
 	messaging_register(msg_ctx, ev_ctx,
@@ -686,11 +680,6 @@ void start_mdssd(struct tevent_context *ev_ctx,
 		exit(1);
 	}
 
-	if (!serverid_register(messaging_server_id(msg_ctx),
-			       FLAG_MSG_GENERAL)) {
-		exit(1);
-	}
-
 	messaging_register(msg_ctx,
 			   ev_ctx,
 			   MSG_SMB_CONF_UPDATED,
diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c
index d3f4776076f..cdbc2c4089e 100644
--- a/source3/smbd/negprot.c
+++ b/source3/smbd/negprot.c
@@ -691,14 +691,6 @@ void reply_negprot(struct smb_request *req)
 	/* possibly reload - change of architecture */
 	reload_services(sconn, conn_snum_used, true);
 
-	/* moved from the netbios session setup code since we don't have that 
-	   when the client connects to port 445.  Of course there is a small
-	   window where we are listening to messages   -- jerry */
-
-	serverid_register(messaging_server_id(sconn->msg_ctx),
-			  FLAG_MSG_GENERAL|FLAG_MSG_SMBD
-			  |FLAG_MSG_PRINT_GENERAL);
-
 	/*
 	 * Anything higher than PROTOCOL_SMB2_10 still
 	 * needs to go via "SMB 2.???", which is marked
diff --git a/source3/smbd/process.c b/source3/smbd/process.c
index b5f528fc78a..4376f2eff99 100644
--- a/source3/smbd/process.c
+++ b/source3/smbd/process.c
@@ -41,7 +41,6 @@
 #include "../libcli/security/security_token.h"
 #include "lib/id_cache.h"
 #include "lib/util/sys_rw_data.h"
-#include "serverid.h"
 #include "system/threads.h"
 
 /* Internal message queue for deferred opens. */
@@ -3947,14 +3946,6 @@ void smbd_process(struct tevent_context *ev_ctx,
 	if (!interactive) {
 		smbd_setup_sig_term_handler(sconn);
 		smbd_setup_sig_hup_handler(sconn);
-
-		if (!serverid_register(messaging_server_id(msg_ctx),
-				       FLAG_MSG_GENERAL|FLAG_MSG_SMBD
-				       |FLAG_MSG_DBWRAP
-				       |FLAG_MSG_PRINT_GENERAL)) {
-			exit_server_cleanly("Could not register myself in "
-					    "serverid.tdb");
-		}
 	}
 
 	status = smbd_add_connection(client, sock_fd, &xconn);
diff --git a/source3/smbd/scavenger.c b/source3/smbd/scavenger.c
index 9b479a621e3..a9fda7f0641 100644
--- a/source3/smbd/scavenger.c
+++ b/source3/smbd/scavenger.c
@@ -138,7 +138,6 @@ static bool smbd_scavenger_running(struct smbd_scavenger_state *state)
 
 static int smbd_scavenger_server_id_destructor(struct server_id *id)
 {
-	serverid_deregister(*id);
 	return 0;
 }
 
@@ -256,13 +255,6 @@ static bool smbd_scavenger_start(struct smbd_scavenger_state *state)
 
 		scavenger_setup_sig_term_handler(state->ev);
 
-		if (!serverid_register(*state->scavenger_id,
-				       FLAG_MSG_GENERAL)) {
-			DBG_WARNING("serverid_register failed");
-			exit_server("serverid_register failed");
-			return false;
-		}
-
 		ok = scavenger_say_hello(fds[1], *state->scavenger_id);
 		if (!ok) {
 			DEBUG(2, ("scavenger_say_hello failed\n"));
diff --git a/source3/smbd/server.c b/source3/smbd/server.c
index 916727635f9..e3f19f3cec1 100644
--- a/source3/smbd/server.c
+++ b/source3/smbd/server.c
@@ -36,7 +36,6 @@
 #include "printing/queue_process.h"
 #include "rpc_server/rpc_service_setup.h"
 #include "rpc_server/rpc_config.h"
-#include "serverid.h"
 #include "passdb.h"
 #include "auth.h"
 #include "messages.h"
@@ -1263,21 +1262,6 @@ static bool open_sockets_smbd(struct smbd_parent_context *parent,
 		return false;
 	}
 
-	/* Setup the main smbd so that we can get messages. Note that
-	   do this after starting listening. This is needed as when in
-	   clustered mode, ctdb won't allow us to start doing database
-	   operations until it has gone thru a full startup, which
-	   includes checking to see that smbd is listening. */
-
-	if (!serverid_register(messaging_server_id(msg_ctx),
-			       FLAG_MSG_GENERAL|FLAG_MSG_SMBD
-			       |FLAG_MSG_PRINT_GENERAL
-			       |FLAG_MSG_DBWRAP)) {
-		DEBUG(0, ("open_sockets_smbd: Failed to register "
-			  "myself in serverid.tdb\n"));
-		return false;
-	}
-
         /* Listen to messages */
 
 	messaging_register(msg_ctx, NULL, MSG_SHUTDOWN, msg_exit_server);
@@ -1986,10 +1970,6 @@ extern void build_options(bool screen);
 		exit_daemon("Samba cannot init scavenging", EACCES);
 	}
 
-	if (!serverid_parent_init(ev_ctx)) {
-		exit_daemon("Samba cannot init server id", EACCES);
-	}
-
 	if (!W_ERROR_IS_OK(registry_init_full()))
 		exit_daemon("Samba cannot init registry", EACCES);
 
diff --git a/source3/smbd/server_exit.c b/source3/smbd/server_exit.c
index 74ddd70bd3a..a9ef37f49e2 100644
--- a/source3/smbd/server_exit.c
+++ b/source3/smbd/server_exit.c
@@ -171,14 +171,6 @@ static void exit_server_common(enum server_exit_reason how,
 	/* 3 second timeout. */
 	print_notify_send_messages(msg_ctx, 3);
 
-	/* delete our entry in the serverid database. */
-	if (am_parent) {
-		/*
-		 * For children the parent takes care of cleaning up
-		 */
-		serverid_deregister(messaging_server_id(msg_ctx));
-	}
-
 #ifdef USE_DMAPI
 	/* Destroy Samba DMAPI session only if we are master smbd process */
 	if (am_parent) {
diff --git a/source3/smbd/smbd_cleanupd.c b/source3/smbd/smbd_cleanupd.c
index cfb75c971be..5bd18c1411c 100644
--- a/source3/smbd/smbd_cleanupd.c
+++ b/source3/smbd/smbd_cleanupd.c
@@ -177,7 +177,6 @@ static void smbd_cleanupd_process_exited(struct messaging_context *msg,
 	     child != NULL;
 	     child = child->next)
 	{
-		struct server_id child_id;
 		bool ok;
 
 		ok = cleanupdb_delete_child(child->pid);
@@ -185,14 +184,6 @@ static void smbd_cleanupd_process_exited(struct messaging_context *msg,
 			DBG_ERR("failed to delete pid %d\n", (int)child->pid);
 		}
 
-		/*
-		 * Get child_id before messaging_cleanup which wipes
-		 * the unique_id. Not that it really matters here for
-		 * functionality (the child should have properly
-		 * cleaned up :-)) though, but it looks nicer.
-		 */
-		child_id = pid_to_procid(child->pid);
-
 		smbprofile_cleanup(child->pid, state->parent_pid);
 
 		ret = messaging_cleanup(msg, child->pid);
@@ -202,11 +193,6 @@ static void smbd_cleanupd_process_exited(struct messaging_context *msg,
 				  strerror(ret));
 		}
 
-		if (!serverid_deregister(child_id)) {
-			DBG_ERR("Could not remove pid %d from serverid.tdb\n",
-				(int)child->pid);
-		}
-
 		DBG_DEBUG("cleaned up pid %d\n", (int)child->pid);
 	}
 
diff --git a/source3/torture/vfstest.c b/source3/torture/vfstest.c
index b6ef2f2e438..f156def4647 100644
--- a/source3/torture/vfstest.c
+++ b/source3/torture/vfstest.c
@@ -527,7 +527,6 @@ int main(int argc, const char *argv[])
 	sec_init();
 	init_guest_info();
 	locking_init();
-	serverid_parent_init(NULL);
 	vfs = talloc_zero(NULL, struct vfs_state);
 	if (vfs == NULL) {
 		return 1;
@@ -553,7 +552,6 @@ int main(int argc, const char *argv[])
 	vfs->conn->share_access = FILE_GENERIC_ALL;
 	vfs->conn->read_only = false;
 
-	serverid_register(messaging_server_id(vfs->conn->sconn->msg_ctx), 0);
 	file_init(vfs->conn->sconn);
 	for (i=0; i < 1024; i++)
 		vfs->files[i] = NULL;
diff --git a/source3/winbindd/winbindd.c b/source3/winbindd/winbindd.c
index ceb131e9b32..23e8a5ede5e 100644
--- a/source3/winbindd/winbindd.c
+++ b/source3/winbindd/winbindd.c
@@ -34,7 +34,6 @@
 #include "rpc_client/cli_netlogon.h"
 #include "idmap.h"
 #include "lib/addrchange.h"
-#include "serverid.h"
 #include "auth.h"
 #include "messages.h"
 #include "../lib/util/pidfile.h"
@@ -221,9 +220,6 @@ static void terminate(bool is_parent)
 #endif
 
 	if (is_parent) {
-		struct messaging_context *msg = server_messaging_context();
-		struct server_id self = messaging_server_id(msg);
-		serverid_deregister(self);
 		pidfile_unlink(lp_pid_directory(), "winbindd");
 	}
 
@@ -1305,16 +1301,6 @@ static void winbindd_register_handlers(struct messaging_context *msg_ctx,
 		exit(1);
 	}
 
-	/* get broadcast messages */
-
-	if (!serverid_register(messaging_server_id(msg_ctx),
-			       FLAG_MSG_GENERAL |
-			       FLAG_MSG_WINBIND |
-			       FLAG_MSG_DBWRAP)) {
-		DEBUG(1, ("Could not register myself in serverid.tdb\n"));
-		exit(1);
-	}
-
 	/* React on 'smbcontrol winbindd reload-config' in the same way
 	   as to SIGHUP signal */
 	messaging_register(msg_ctx, NULL,
-- 
2.11.0



More information about the samba-technical mailing list