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;
63 /* Current incoming. */
65 /* Queue of received pdus */
66 struct io_elem *inqueue;
68 /* Guess at a good reqid to try next. */
70 /* List of messages */
71 struct message_handler_info *message_handlers;
72 /* PNN of this ctdb: valid by the time we do our first db connection. */
74 /* Chain of locks we hold. */
75 struct ctdb_lock *locks;
82 struct ctdb_request *new_ctdb_request(size_t len, ctdb_callback_t, void *);
83 struct ctdb_request *new_ctdb_control_request(struct ctdb_connection *ctdb,
86 const void *extra_data,
88 ctdb_callback_t, void *);
89 uint32_t new_reqid(struct ctdb_connection *ctdb);
91 struct ctdb_reply_control *unpack_reply_control(struct ctdb_connection *ctdb,
92 struct ctdb_request *req,
93 enum ctdb_controls control);
94 void ctdb_cancel_callback(struct ctdb_connection *ctdb,
95 struct ctdb_request *req,
99 void ctdb_tdb_log_bridge(struct tdb_context *tdb,
100 enum tdb_debug_level level,
101 const char *format, ...) PRINTF_ATTRIBUTE(3, 4);
103 void ctdb_do_debug(struct ctdb_connection *, int, const char *format, ...)
104 PRINTF_ATTRIBUTE(3, 4) COLD_ATTRIBUTE;
106 #endif /* _LIBCTDB_PRIVATE_H */