1 #ifndef _LIBCTDB_PRIVATE_H
2 #define _LIBCTDB_PRIVATE_H
8 #include <ctdb_protocol.h>
13 #define offsetof(t,f) ((unsigned int)&((t *)0)->f)
16 #ifndef COLD_ATTRIBUTE
17 #if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
18 #define COLD_ATTRIBUTE __attribute__((cold))
20 #define COLD_ATTRIBUTE
22 #endif /* COLD_ATTRIBUTE */
24 #define DEBUG(ctdb, lvl, format, args...) do { if (lvl <= ctdb_log_level) { ctdb_do_debug(ctdb, lvl, format , ## args ); }} while(0)
26 struct message_handler_info;
27 struct ctdb_reply_call;
30 struct ctdb_connection *ctdb;
31 struct ctdb_request *next, *prev;
36 struct ctdb_req_header *hdr;
37 struct ctdb_req_call *call;
38 struct ctdb_req_control *control;
39 struct ctdb_req_message *message;
42 struct io_elem *reply;
44 ctdb_callback_t callback;
47 /* Extra per-request info. */
48 void (*extra_destructor)(struct ctdb_connection *,
49 struct ctdb_request *);
53 struct ctdb_connection {
54 /* Socket to ctdbd. */
56 /* Currently our failure mode is simple; return -1 from ctdb_service */
58 /* Linked list of pending outgoings. */
59 struct ctdb_request *outq;
60 /* Finished outgoings (awaiting response) */
61 struct ctdb_request *doneq;
62 /* Current incoming. */
64 /* Guess at a good reqid to try next. */
66 /* List of messages */
67 struct message_handler_info *message_handlers;
68 /* PNN of this ctdb: valid by the time we do our first db connection. */
70 /* Chain of locks we hold. */
71 struct ctdb_lock *locks;
78 struct ctdb_request *new_ctdb_request(size_t len, ctdb_callback_t, void *);
79 struct ctdb_request *new_ctdb_control_request(struct ctdb_connection *ctdb,
82 const void *extra_data,
84 ctdb_callback_t, void *);
85 uint32_t new_reqid(struct ctdb_connection *ctdb);
87 struct ctdb_reply_control *unpack_reply_control(struct ctdb_connection *ctdb,
88 struct ctdb_request *req,
89 enum ctdb_controls control);
90 void ctdb_cancel_callback(struct ctdb_connection *ctdb,
91 struct ctdb_request *req,
95 void ctdb_tdb_log_bridge(struct tdb_context *tdb,
96 enum tdb_debug_level level,
97 const char *format, ...) PRINTF_ATTRIBUTE(3, 4);
99 void ctdb_do_debug(struct ctdb_connection *, int, const char *format, ...)
100 PRINTF_ATTRIBUTE(3, 4) COLD_ATTRIBUTE;
102 #endif /* _LIBCTDB_PRIVATE_H */