[SCM] Samba Shared Repository - branch master updated

Jeremy Allison jra at samba.org
Thu Apr 3 00:37:04 MDT 2014


The branch, master has been updated
       via  375d467 autorid: use the db argument in the initialize traverse action.
       via  837671f s3: messages: Implement cleanup of dead records.
      from  5cf6e9c autorid: make the whole initialization atomic with one transaction.

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 375d46791ce867d38e815e9a830a7e769e058327
Author: Michael Adam <obnox at samba.org>
Date:   Thu Apr 3 00:06:04 2014 +0200

    autorid: use the db argument in the initialize traverse action.
    
    By a copy and paste error, the global autorid_db was used.
    This was not currently a problem in behaviour, because this
    autorid_db is passed as the argument.
    
    This change fixes the callback function for consistency.
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    
    Autobuild-User(master): Jeremy Allison <jra at samba.org>
    Autobuild-Date(master): Thu Apr  3 08:36:55 CEST 2014 on sn-devel-104

commit 837671f47670b16726aa96ba7a0902974a1037eb
Author: Jeremy Allison <jra at samba.org>
Date:   Wed Apr 2 16:45:25 2014 -0700

    s3: messages: Implement cleanup of dead records.
    
    When a smbd process dies, pending messages.tdb records for this process
    might not get cleaned up. Implement a cleanup for dead records that is
    triggered after a smbd dies uncleanly; the records for that PID are
    deleted.
    
    Based on a patchset from Christof Schmitt <cs at samba.org>.
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Christof Schmitt <cs at samba.org>

-----------------------------------------------------------------------

Summary of changes:
 source3/include/messages.h       |    6 ++++++
 source3/lib/messages.c           |   17 +++++++++++++++++
 source3/lib/messages_local.c     |   38 ++++++++++++++++++++++++++++++++++++++
 source3/smbd/server.c            |    7 +++++++
 source3/winbindd/idmap_autorid.c |    4 ++--
 5 files changed, 70 insertions(+), 2 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/include/messages.h b/source3/include/messages.h
index d7a2853..47c5f7a 100644
--- a/source3/include/messages.h
+++ b/source3/include/messages.h
@@ -97,6 +97,9 @@ NTSTATUS messaging_tdb_init(struct messaging_context *msg_ctx,
 
 bool messaging_tdb_parent_init(TALLOC_CTX *mem_ctx);
 
+NTSTATUS messaging_tdb_cleanup(struct messaging_context *msg_ctx,
+			struct server_id pid);
+
 NTSTATUS messaging_ctdbd_init(struct messaging_context *msg_ctx,
 			      TALLOC_CTX *mem_ctx,
 			      struct messaging_backend **presult);
@@ -143,6 +146,9 @@ struct tevent_req *messaging_read_send(TALLOC_CTX *mem_ctx,
 int messaging_read_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
 			struct messaging_rec **presult);
 
+void messaging_cleanup_server(struct messaging_context *msg_ctx,
+				struct server_id pid);
+
 #include "librpc/gen_ndr/ndr_messaging.h"
 
 #endif
diff --git a/source3/lib/messages.c b/source3/lib/messages.c
index 96b6b88..4ff933d 100644
--- a/source3/lib/messages.c
+++ b/source3/lib/messages.c
@@ -567,4 +567,21 @@ void messaging_dispatch_rec(struct messaging_context *msg_ctx,
 	return;
 }
 
+/*
+  Call when a process has terminated abnormally.
+*/
+void messaging_cleanup_server(struct messaging_context *msg_ctx,
+				struct server_id server)
+{
+	if (server_id_is_disconnected(&server)) {
+		return;
+	}
+
+	if (!procid_is_local(&server)) {
+		return;
+	}
+
+	(void)messaging_tdb_cleanup(msg_ctx, server);
+
+}
 /** @} **/
diff --git a/source3/lib/messages_local.c b/source3/lib/messages_local.c
index 1fe89c3..d535df1 100644
--- a/source3/lib/messages_local.c
+++ b/source3/lib/messages_local.c
@@ -45,6 +45,7 @@
 #include "includes.h"
 #include "system/filesys.h"
 #include "messages.h"
+#include "serverid.h"
 #include "lib/tdb_wrap/tdb_wrap.h"
 #include "lib/param/param.h"
 
@@ -221,6 +222,43 @@ static TDB_DATA message_key_pid(TALLOC_CTX *mem_ctx, struct server_id pid)
 	return kbuf;
 }
 
+/*******************************************************************
+ Called when a process has terminated abnormally. Remove all messages
+ pending for it.
+******************************************************************/
+
+NTSTATUS messaging_tdb_cleanup(struct messaging_context *msg_ctx,
+				struct server_id pid)
+{
+	struct messaging_tdb_context *ctx = talloc_get_type(
+					msg_ctx->local->private_data,
+					struct messaging_tdb_context);
+	struct tdb_wrap *tdb = ctx->tdb;
+	TDB_DATA key;
+	TALLOC_CTX *frame = talloc_stackframe();
+
+	key = message_key_pid(frame, pid);
+	/*
+	 * We have to lock the key to avoid
+	 * races in case the server_id was
+	 * re-used and is active (a remote
+	 * possibility, true). We only
+	 * clean up the database if we
+	 * know server_id doesn't exist
+	 * while checked under the chainlock.
+	 */
+	if (tdb_chainlock(tdb->tdb, key) != 0) {
+		TALLOC_FREE(frame);
+		return NT_STATUS_LOCK_NOT_GRANTED;
+	}
+	if (!serverid_exists(&pid)) {
+		(void)tdb_delete(tdb->tdb, key);
+	}
+	tdb_chainunlock(tdb->tdb, key);
+	TALLOC_FREE(frame);
+	return NT_STATUS_OK;
+}
+
 /*
   Fetch the messaging array for a process
  */
diff --git a/source3/smbd/server.c b/source3/smbd/server.c
index 29e688d..bc9d293 100644
--- a/source3/smbd/server.c
+++ b/source3/smbd/server.c
@@ -481,6 +481,13 @@ static void remove_child_pid(struct smbd_parent_context *parent,
 						parent);
 			DEBUG(1,("Scheduled cleanup of brl and lock database after unclean shutdown\n"));
 		}
+
+		/*
+		 * Ensure we flush any stored messages
+		 * queued for the child process that
+		 * terminated uncleanly.
+		 */
+		messaging_cleanup_server(parent->msg_ctx, child_id);
 	}
 
 	if (!serverid_deregister(child_id)) {
diff --git a/source3/winbindd/idmap_autorid.c b/source3/winbindd/idmap_autorid.c
index 7e17b66..a0262fa 100644
--- a/source3/winbindd/idmap_autorid.c
+++ b/source3/winbindd/idmap_autorid.c
@@ -592,12 +592,12 @@ static NTSTATUS idmap_autorid_initialize_action(struct db_context *db,
 	common = (struct idmap_tdb_common_context *)dom->private_data;
 	config = (struct autorid_global_config *)common->private_data;
 
-	status = idmap_autorid_init_hwms(autorid_db);
+	status = idmap_autorid_init_hwms(db);
 	if (!NT_STATUS_IS_OK(status)) {
 		return status;
 	}
 
-	status = idmap_autorid_saveconfig(autorid_db, config);
+	status = idmap_autorid_saveconfig(db, config);
 	if (!NT_STATUS_IS_OK(status)) {
 		DEBUG(1, ("Failed to store configuration data!\n"));
 		return status;


-- 
Samba Shared Repository


More information about the samba-cvs mailing list