1 #ifndef _LIBCTDB_PRIVATE_H
2 #define _LIBCTDB_PRIVATE_H
8 #include <ctdb_protocol.h>
12 #define offsetof(t,f) ((unsigned int)&((t *)0)->f)
15 #ifndef COLD_ATTRIBUTE
16 #if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
17 #define COLD_ATTRIBUTE __attribute__((cold))
19 #define COLD_ATTRIBUTE
21 #endif /* COLD_ATTRIBUTE */
23 #define DEBUG(ctdb, lvl, format, args...) do { if (lvl <= ctdb_log_level) { ctdb_do_debug(ctdb, lvl, format , ## args ); }} while(0)
25 void ctdb_do_debug(struct ctdb_connection *, int, const char *format, ...)
26 PRINTF_ATTRIBUTE(3, 4) COLD_ATTRIBUTE;
28 struct message_handler_info;
29 struct ctdb_reply_call;
32 struct ctdb_connection *ctdb;
33 struct ctdb_request *next, *prev;
38 struct ctdb_req_header *hdr;
39 struct ctdb_req_call *call;
40 struct ctdb_req_control *control;
41 struct ctdb_req_message *message;
44 struct io_elem *reply;
46 ctdb_callback_t callback;
49 /* Extra per-request info. */
50 void (*extra_destructor)(struct ctdb_connection *,
51 struct ctdb_request *);
55 struct ctdb_connection {
56 /* Socket to ctdbd. */
58 /* Currently our failure mode is simple; return -1 from ctdb_service */
60 /* Linked list of pending outgoings. */
61 struct ctdb_request *outq;
62 /* Finished outgoings (awaiting response) */
63 struct ctdb_request *doneq;
64 /* Current incoming. */
66 /* Guess at a good reqid to try next. */
68 /* List of messages */
69 struct message_handler_info *message_handlers;
70 /* PNN of this ctdb: valid by the time we do our first db connection. */
72 /* Chain of locks we hold. */
73 struct ctdb_lock *locks;
80 struct ctdb_request *new_ctdb_request(size_t len, ctdb_callback_t, void *);
81 struct ctdb_request *new_ctdb_control_request(struct ctdb_connection *ctdb,
84 const void *extra_data,
86 ctdb_callback_t, void *);
87 uint32_t new_reqid(struct ctdb_connection *ctdb);
89 struct ctdb_reply_control *unpack_reply_control(struct ctdb_connection *ctdb,
90 struct ctdb_request *req,
91 enum ctdb_controls control);
92 void ctdb_cancel_callback(struct ctdb_connection *ctdb,
93 struct ctdb_request *req,
95 #endif /* _LIBCTDB_PRIVATE_H */