ctdb-client: Add a disconnect callback for ctdb client
[obnox/samba/samba-obnox.git] / ctdb / client / client_private.h
1 /*
2    CTDB client code
3
4    Copyright (C) Amitay Isaacs  2015
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 #ifndef __CTDB_CLIENT_PRIVATE_H__
21 #define __CTDB_CLIENT_PRIVATE_H__
22
23 #include "protocol/protocol.h"
24 #include "client/client.h"
25
26 struct ctdb_db_context {
27         struct ctdb_db_context *prev, *next;
28         uint32_t db_id;
29         const char *db_name;
30         const char *db_path;
31         struct tdb_wrap *ltdb;
32         bool persistent;
33 };
34
35 struct ctdb_client_context {
36         struct reqid_context *idr;
37         struct srvid_context *srv;
38         struct comm_context *comm;
39         ctdb_client_callback_func_t callback;
40         void *private_data;
41         int fd;
42         uint32_t pnn;
43         struct ctdb_db_context *db;
44 };
45
46 struct ctdb_record_handle {
47         struct tevent_context *ev;
48         struct ctdb_client_context *client;
49         struct ctdb_db_context *db;
50         struct ctdb_ltdb_header header;
51         TDB_DATA key;
52         TDB_DATA data; /* This is returned from tdb_fetch() */
53         bool readonly;
54 };
55
56 struct ctdb_transaction_handle {
57         struct tevent_context *ev;
58         struct ctdb_client_context *client;
59         struct ctdb_db_context *db, *db_g_lock;
60         struct ctdb_rec_buffer *recbuf;
61         struct ctdb_server_id sid;
62         const char *lock_name;
63         bool readonly;
64         bool updated;
65 };
66
67 /* From client_call.c */
68
69 void ctdb_client_reply_call(struct ctdb_client_context *client,
70                             uint8_t *buf, size_t buflen, uint32_t reqid);
71
72 /* From client_message.c */
73
74 void ctdb_client_req_message(struct ctdb_client_context *client,
75                              uint8_t *buf, size_t buflen, uint32_t reqid);
76
77 /* From client_control.c */
78
79 void ctdb_client_reply_control(struct ctdb_client_context *client,
80                                uint8_t *buf, size_t buflen, uint32_t reqid);
81
82 #endif /* __CTDB_CLIENT_PRIVATE_H__ */