source: branches/samba-3.2.x/source/lib/messages_ctdbd.c@ 228

Last change on this file since 228 was 136, checked in by Paul Smedley, 18 years ago

Update trunk to 3.2.0rc1

File size: 4.2 KB
Line 
1/*
2 Unix SMB/CIFS implementation.
3 Samba internal messaging functions
4 Copyright (C) 2007 by Volker Lendecke
5
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.
10
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.
15
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/>.
18*/
19
20#include "includes.h"
21
22#ifdef CLUSTER_SUPPORT
23
24#include "librpc/gen_ndr/messaging.h"
25#include "ctdb.h"
26#include "ctdb_private.h"
27#include "ctdbd_conn.h"
28
29
30struct messaging_ctdbd_context {
31 struct ctdbd_connection *conn;
32};
33
34/*
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.
37 */
38static struct ctdbd_connection *global_ctdbd_connection;
39static int global_ctdb_connection_pid;
40
41struct ctdbd_connection *messaging_ctdbd_connection(void)
42{
43 if (global_ctdb_connection_pid == 0 &&
44 global_ctdbd_connection == NULL) {
45 struct event_context *ev;
46 struct messaging_context *msg;
47
48 ev = event_context_init(NULL);
49 if (!ev) {
50 DEBUG(0,("event_context_init failed\n"));
51 }
52
53 msg = messaging_init(NULL, procid_self(), ev);
54 if (!msg) {
55 DEBUG(0,("messaging_init failed\n"));
56 }
57
58 db_tdb2_setup_messaging(msg, false);
59 }
60
61 if (global_ctdb_connection_pid != getpid()) {
62 DEBUG(0,("messaging_ctdbd_connection():"
63 "valid for pid[%d] but it's [%d]\n",
64 global_ctdb_connection_pid, getpid()));
65 smb_panic("messaging_ctdbd_connection() invalid process\n");
66 }
67
68 return global_ctdbd_connection;
69}
70
71static NTSTATUS messaging_ctdb_send(struct messaging_context *msg_ctx,
72 struct server_id pid, int msg_type,
73 const DATA_BLOB *data,
74 struct messaging_backend *backend)