From 259786980a3a65fa67a4de12a65d33095fa53ce2 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 15 Apr 2008 01:18:06 +0200 Subject: [PATCH] messages_ctdbd: make sure a ctdbd connection is only used in the process that created it metze --- source/lib/messages_ctdbd.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/source/lib/messages_ctdbd.c b/source/lib/messages_ctdbd.c index f1a02e6af9f..0c8a2aa8e44 100644 --- a/source/lib/messages_ctdbd.c +++ b/source/lib/messages_ctdbd.c @@ -35,10 +35,18 @@ struct messaging_ctdbd_context { * This is a Samba3 hack/optimization. Routines like process_exists need to * talk to ctdbd, and they don't get handed a messaging context. */ -struct ctdbd_connection *global_ctdbd_connection; +static struct ctdbd_connection *global_ctdbd_connection; +static int global_ctdb_connection_pid; struct ctdbd_connection *messaging_ctdbd_connection(void) { + if (global_ctdb_connection_pid != getpid()) { + DEBUG(0,("messaging_ctdbd_connection():" + "valid for pid[%d] but it's [%d]\n", + global_ctdb_connection_pid, getpid())); + smb_panic("messaging_ctdbd_connection() invalid process\n"); + } + return global_ctdbd_connection; } @@ -66,6 +74,7 @@ static int messaging_ctdbd_destructor(struct messaging_ctdbd_context *ctx) /* * The global connection just went away */ + global_ctdb_connection_pid = 0; global_ctdbd_connection = NULL; return 0; } @@ -107,6 +116,7 @@ NTSTATUS messaging_ctdbd_init(struct messaging_context *msg_ctx, return status; } + global_ctdb_connection_pid = getpid(); global_ctdbd_connection = ctx->conn; talloc_set_destructor(ctx, messaging_ctdbd_destructor); -- 2.11.4.GIT