2 Unix SMB/CIFS implementation.
3 Samba internal messaging functions
4 Copyright (C) 2007 by Volker Lendecke
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
22 #ifdef CLUSTER_SUPPORT
24 #include "librpc/gen_ndr/messaging.h"
26 struct messaging_ctdbd_context
{
27 struct ctdbd_connection
*conn
;
31 * This is a Samba3 hack/optimization. Routines like process_exists need to
32 * talk to ctdbd, and they don't get handed a messaging context.
34 struct ctdbd_connection
*global_ctdbd_connection
;
36 struct ctdbd_connection
*messaging_ctdbd_connection(void)
38 return global_ctdbd_connection
;
41 static NTSTATUS
messaging_ctdb_send(struct messaging_context
*msg_ctx
,
42 struct server_id pid
, int msg_type
,
43 const DATA_BLOB
*data
,
44 struct messaging_backend
*backend
)
46 struct messaging_ctdbd_context
*ctx
= talloc_get_type_abort(
47 backend
->private_data
, struct messaging_ctdbd_context
);
49 struct messaging_rec msg
;
51 msg
.msg_version
= MESSAGE_VERSION
;
52 msg
.msg_type
= msg_type
;
54 msg
.src
= procid_self();
57 return ctdbd_messaging_send(ctx
->conn
, pid
.vnn
, pid
.pid
, &msg
);
60 static int messaging_ctdbd_destructor(struct messaging_ctdbd_context
*ctx
)
63 * The global connection just went away
65 global_ctdbd_connection
= NULL
;
69 NTSTATUS
messaging_ctdbd_init(struct messaging_context
*msg_ctx
,
71 struct messaging_backend
**presult
)
73 struct messaging_backend
*result
;
74 struct messaging_ctdbd_context
*ctx
;
77 if (!(result
= TALLOC_P(mem_ctx
, struct messaging_backend
))) {
78 DEBUG(0, ("talloc failed\n"));
79 return NT_STATUS_NO_MEMORY
;
82 if (!(ctx
= TALLOC_P(result
, struct messaging_ctdbd_context
))) {
83 DEBUG(0, ("talloc failed\n"));
85 return NT_STATUS_NO_MEMORY
;
88 status
= ctdbd_messaging_connection(ctx
, &ctx
->conn
);
90 if (!NT_STATUS_IS_OK(status
)) {
91 DEBUG(10, ("ctdbd_init_connection failed: %s\n",
97 global_ctdbd_connection
= ctx
->conn
;
98 talloc_set_destructor(ctx
, messaging_ctdbd_destructor
);
100 set_my_vnn(ctdbd_vnn(ctx
->conn
));
102 result
->send_fn
= messaging_ctdb_send
;
103 result
->private_data
= (void *)ctx
;
111 NTSTATUS
messaging_ctdbd_init(struct messaging_context
*msg_ctx
,
113 struct messaging_backend
**presult
)
115 return NT_STATUS_NOT_IMPLEMENTED
;