34 typedef struct cib_native_opaque_s {
37 void (*dnotify_fn) (gpointer user_data);
43 xmlNode *
data, xmlNode ** output_data,
int call_options);
46 const char *section, xmlNode *
data, xmlNode ** output_data,
47 int call_options,
const char *user_name);
70 native->source = NULL;
71 native->dnotify_fn = NULL;
93 cib_native_dispatch_internal(
const char *buffer, ssize_t length, gpointer userdata)
95 const char *
type = NULL;
98 cib_t *cib = userdata;
110 crm_warn(
"Received a NULL msg from CIB service.");
116 crm_trace(
"Activating %s callbacks...", type);
126 crm_err(
"Unknown message type: %s", type);
136 gboolean stay_connected = TRUE;
151 cib_native_dispatch_internal(msg, strlen(msg), cib);
156 stay_connected = FALSE;
160 return stay_connected;
164 cib_native_destroy(
void *userdata)
166 cib_t *cib = userdata;
171 native->source = NULL;
174 if (native->dnotify_fn) {
175 native->dnotify_fn(userdata);
183 const char *channel = NULL;
187 .
dispatch = cib_native_dispatch_internal,
188 .destroy = cib_native_destroy
209 crm_trace(
"Connecting %s channel", channel);
211 if (async_fd != NULL) {
217 }
else if (native->ipc) {
218 crm_perror(LOG_ERR,
"Connection to cluster information base failed");
230 crm_debug(
"Connection unsuccessful (%d %p)", rc, native->ipc);
235 xmlNode *reply = NULL;
250 crm_err(
"Invalid registration message: %s", msg_type);
255 if (native->token == NULL) {
269 crm_debug(
"Connection to CIB successful");
283 crm_debug(
"Signing out of the CIB Service");
285 if (native->source != NULL) {
288 native->source = NULL;
291 }
else if (native->ipc) {
329 xmlNode *
data, xmlNode ** output_data,
int call_options)
332 data, output_data, call_options, NULL);
337 xmlNode *
data, xmlNode ** output_data,
int call_options,
338 const char *user_name)
344 xmlNode *op_msg = NULL;
345 xmlNode *op_reply = NULL;
353 if (output_data != NULL) {
358 crm_err(
"No operation specified");
380 if (op_msg == NULL) {
389 crm_err(
"Couldn't perform %s operation (timeout=%ds): %s (%d)", op,
397 if (!(call_options & cib_sync_call)) {
406 if (reply_id == cib->
call_id) {
409 crm_trace(
"Synchronous reply %d received", reply_id);
417 }
else if (tmp != NULL) {
421 }
else if (reply_id <= 0) {
422 crm_err(
"Received bad reply: No id set");
428 crm_err(
"Received bad reply: %d (wanted %d)", reply_id, cib->
call_id);
437 }
else if (rc ==
pcmk_ok && op_reply == NULL) {
487 native->dnotify_fn = dnotify;
506 crm_trace(
"Notification not registered: %d", rc);
#define CRM_CHECK(expr, failure_action)
bool crm_ipc_connect(crm_ipc_t *client)
Establish an IPC connection to a Pacemaker component.
xmlNode * get_message_xml(xmlNode *msg, const char *field)
gboolean safe_str_neq(const char *a, const char *b)
int crm_ipc_get_fd(crm_ipc_t *client)
const char * pcmk_strerror(int rc)
struct mainloop_io_s mainloop_io_t
char * crm_element_value_copy(xmlNode *data, const char *name)
int(* signon_raw)(cib_t *cib, const char *name, enum cib_conn_type type, int *event_fd)
long crm_ipc_read(crm_ipc_t *client)
int(* set_connection_dnotify)(cib_t *cib, void(*dnotify)(gpointer user_data))
Wrappers for and extensions to glib mainloop.
xmlNode * string2xml(const char *input)
const char * crm_ipc_buffer(crm_ipc_t *client)
#define F_CIB_NOTIFY_ACTIVATE
xmlNode * cib_create_op(int call_id, const char *token, const char *op, const char *host, const char *section, xmlNode *data, int call_options, const char *user_name)
void cib_native_notify(gpointer data, gpointer user_data)
xmlNode * copy_xml(xmlNode *src_node)
int cib_native_set_connection_dnotify(cib_t *cib, void(*dnotify)(gpointer user_data))
cib_t * cib_new_variant(void)
#define pcmk_err_diff_resync
#define crm_warn(fmt, args...)
cib_api_operations_t * cmds
#define crm_debug(fmt, args...)
struct crm_ipc_s crm_ipc_t
int cib_native_register_notification(cib_t *cib, const char *callback, int enabled)
int cib_native_signoff(cib_t *cib)
#define crm_trace(fmt, args...)
#define crm_log_xml_explicit(xml, text)
int(* register_notification)(cib_t *cib, const char *callback, int enabled)
xmlNode * create_xml_node(xmlNode *parent, const char *name)
int crm_element_value_int(xmlNode *data, const char *name, int *dest)
const char * crm_element_value(xmlNode *data, const char *name)
void mainloop_del_ipc_client(mainloop_io_t *client)
void crm_ipc_destroy(crm_ipc_t *client)
cib_t * cib_native_new(void)
void free_xml(xmlNode *child)
int cib_native_signon(cib_t *cib, const char *name, enum cib_conn_type type)
#define F_CIB_NOTIFY_TYPE
bool crm_ipc_connected(crm_ipc_t *client)
int cib_native_perform_op_delegate(cib_t *cib, const char *op, const char *host, const char *section, xmlNode *data, xmlNode **output_data, int call_options, const char *user_name)
const char * crm_xml_add(xmlNode *node, const char *name, const char *value)
const char * crm_xml_add_int(xmlNode *node, const char *name, int value)
int cib_native_free(cib_t *cib)
int crm_ipc_ready(crm_ipc_t *client)
Check whether an IPC connection is ready to be read.
#define crm_log_xml_err(xml, text)
#define crm_perror(level, fmt, args...)
Log a system error message.
crm_ipc_t * mainloop_get_ipc_client(mainloop_io_t *client)
#define crm_err(fmt, args...)
int cib_native_perform_op(cib_t *cib, const char *op, const char *host, const char *section, xmlNode *data, xmlNode **output_data, int call_options)
struct cib_native_opaque_s cib_native_opaque_t
int crm_ipc_send(crm_ipc_t *client, xmlNode *message, enum crm_ipc_flags flags, int32_t ms_timeout, xmlNode **reply)
crm_ipc_t * crm_ipc_new(const char *name, size_t max_size)
int(* signon)(cib_t *cib, const char *name, enum cib_conn_type type)
void cib_native_callback(cib_t *cib, xmlNode *msg, int call_id, int rc)
#define crm_log_xml_trace(xml, text)
int(* signoff)(cib_t *cib)
mainloop_io_t * mainloop_add_ipc_client(const char *name, int priority, size_t max_size, void *userdata, struct ipc_client_callbacks *callbacks)
bool cib_native_dispatch(cib_t *cib)
#define safe_str_eq(a, b)
int cib_native_signon_raw(cib_t *cib, const char *name, enum cib_conn_type type, int *event_fd)
void crm_ipc_close(crm_ipc_t *client)
int(* dispatch)(const char *buffer, ssize_t length, gpointer userdata)
enum crm_ais_msg_types type