Zero out the out policy handler in lsa_Close
[Samba/gebeck_regimport.git] / source3 / lib / messages_ctdbd.c
blobf1a02e6af9fdb3d6cc8ff86c2c888b17b531b7b5
1 /*
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/>.
20 #include "includes.h"
22 #ifdef CLUSTER_SUPPORT
24 #include "librpc/gen_ndr/messaging.h"
25 #include "ctdb.h"
26 #include "ctdb_private.h"
27 #include "ctdbd_conn.h"
30 struct messaging_ctdbd_context {
31 struct ctdbd_connection *conn;
35 * This is a Samba3 hack/optimization. Routines like process_exists need to
36 * talk to ctdbd, and they don't get handed a messaging context.
38 struct ctdbd_connection *global_ctdbd_connection;
40 struct ctdbd_connection *messaging_ctdbd_connection(void)
42 return global_ctdbd_connection;
45 static NTSTATUS messaging_ctdb_send(struct messaging_context *msg_ctx,
46 struct server_id pid, int msg_type,
47 const DATA_BLOB *data,
48 struct messaging_backend *backend)
50 struct messaging_ctdbd_context *ctx = talloc_get_type_abort(
51 backend->private_data, struct messaging_ctdbd_context);
53 struct messaging_rec msg;
55 msg.msg_version = MESSAGE_VERSION;
56 msg.msg_type = msg_type;
57 msg.dest = pid;
58 msg.src = procid_self();
59 msg.buf = *data;
61 return ctdbd_messaging_send(ctx->conn, pid.vnn, pid.pid, &msg);
64 static int messaging_ctdbd_destructor(struct messaging_ctdbd_context *ctx)
67 * The global connection just went away
69 global_ctdbd_connection = NULL;
70 return 0;
73 NTSTATUS messaging_ctdbd_init(struct messaging_context *msg_ctx,
74 TALLOC_CTX *mem_ctx,
75 struct messaging_backend **presult)
77 struct messaging_backend *result;
78 struct messaging_ctdbd_context *ctx;
79 NTSTATUS status;
81 if (!(result = TALLOC_P(mem_ctx, struct messaging_backend))) {
82 DEBUG(0, ("talloc failed\n"));
83 return NT_STATUS_NO_MEMORY;
86 if (!(ctx = TALLOC_P(result, struct messaging_ctdbd_context))) {
87 DEBUG(0, ("talloc failed\n"));
88 TALLOC_FREE(result);
89 return NT_STATUS_NO_MEMORY;
92 status = ctdbd_messaging_connection(ctx, &ctx->conn);
94 if (!NT_STATUS_IS_OK(status)) {
95 DEBUG(10, ("ctdbd_messaging_connection failed: %s\n",
96 nt_errstr(status)));
97 TALLOC_FREE(result);
98 return status;
101 status = ctdbd_register_msg_ctx(ctx->conn, msg_ctx);
103 if (!NT_STATUS_IS_OK(status)) {
104 DEBUG(10, ("ctdbd_register_msg_ctx failed: %s\n",
105 nt_errstr(status)));
106 TALLOC_FREE(result);
107 return status;
110 global_ctdbd_connection = ctx->conn;
111 talloc_set_destructor(ctx, messaging_ctdbd_destructor);
113 set_my_vnn(ctdbd_vnn(ctx->conn));
115 result->send_fn = messaging_ctdb_send;
116 result->private_data = (void *)ctx;
118 *presult = result;
119 return NT_STATUS_OK;
122 #else
124 NTSTATUS messaging_ctdbd_init(struct messaging_context *msg_ctx,
125 TALLOC_CTX *mem_ctx,
126 struct messaging_backend **presult)
128 return NT_STATUS_NOT_IMPLEMENTED;
131 #endif