mirror of
https://github.com/samba-team/samba.git
synced 2025-01-12 09:18:10 +03:00
messages_ctdbd: make sure a ctdbd connection is only used in the process that created it
metze
This commit is contained in:
parent
e1abff3014
commit
259786980a
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user