pacemaker  1.1.16-94ff4df
Scalable High-Availability cluster resource manager
ipc.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2004 Andrew Beekhof <andrew@beekhof.net>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18 
19 #include <crm_internal.h>
20 
21 #include <sys/param.h>
22 
23 #include <stdio.h>
24 #include <sys/types.h>
25 #include <sys/stat.h>
26 #include <unistd.h>
27 #include <grp.h>
28 
29 #include <errno.h>
30 #include <fcntl.h>
31 #include <bzlib.h>
32 
33 #include <crm/crm.h>
34 #include <crm/msg_xml.h>
35 #include <crm/common/ipc.h>
36 #include <crm/common/ipcs.h>
37 
38 #define PCMK_IPC_VERSION 1
39 
40 struct crm_ipc_response_header {
41  struct qb_ipc_response_header qb;
42  uint32_t size_uncompressed;
43  uint32_t size_compressed;
45  uint8_t version; /* Protect against version changes for anyone that might bother to statically link us */
46 };
47 
48 static int hdr_offset = 0;
49 static unsigned int ipc_buffer_max = 0;
50 static unsigned int pick_ipc_buffer(unsigned int max);
51 
52 static inline void
53 crm_ipc_init(void)
54 {
55  if (hdr_offset == 0) {
56  hdr_offset = sizeof(struct crm_ipc_response_header);
57  }
58  if (ipc_buffer_max == 0) {
59  ipc_buffer_max = pick_ipc_buffer(0);
60  }
61 }
62 
63 unsigned int
65 {
66  return pick_ipc_buffer(0);
67 }
68 
69 static char *
70 generateReference(const char *custom1, const char *custom2)
71 {
72  static uint ref_counter = 0;
73  const char *local_cust1 = custom1;
74  const char *local_cust2 = custom2;
75  int reference_len = 4;
76  char *since_epoch = NULL;
77 
78  reference_len += 20; /* too big */
79  reference_len += 40; /* too big */
80 
81  if (local_cust1 == NULL) {
82  local_cust1 = "_empty_";
83  }
84  reference_len += strlen(local_cust1);
85 
86  if (local_cust2 == NULL) {
87  local_cust2 = "_empty_";
88  }
89  reference_len += strlen(local_cust2);
90 
91  since_epoch = calloc(1, reference_len);
92 
93  if (since_epoch != NULL) {
94  sprintf(since_epoch, "%s-%s-%lu-%u",
95  local_cust1, local_cust2, (unsigned long)time(NULL), ref_counter++);
96  }
97 
98  return since_epoch;
99 }
100 
101 xmlNode *
102 create_request_adv(const char *task, xmlNode * msg_data,
103  const char *host_to, const char *sys_to,
104  const char *sys_from, const char *uuid_from, const char *origin)
105 {
106  char *true_from = NULL;
107  xmlNode *request = NULL;
108  char *reference = generateReference(task, sys_from);
109 
110  if (uuid_from != NULL) {
111  true_from = generate_hash_key(sys_from, uuid_from);
112  } else if (sys_from != NULL) {
113  true_from = strdup(sys_from);
114  } else {
115  crm_err("No sys from specified");
116  }
117 
118  /* host_from will get set for us if necessary by CRMd when routed */
119  request = create_xml_node(NULL, __FUNCTION__);
120  crm_xml_add(request, F_CRM_ORIGIN, origin);
121  crm_xml_add(request, F_TYPE, T_CRM);
124  crm_xml_add(request, F_CRM_REFERENCE, reference);
125  crm_xml_add(request, F_CRM_TASK, task);
126  crm_xml_add(request, F_CRM_SYS_TO, sys_to);
127  crm_xml_add(request, F_CRM_SYS_FROM, true_from);
128 
129  /* HOSTTO will be ignored if it is to the DC anyway. */
130  if (host_to != NULL && strlen(host_to) > 0) {
131  crm_xml_add(request, F_CRM_HOST_TO, host_to);
132  }
133 
134  if (msg_data != NULL) {
135  add_message_xml(request, F_CRM_DATA, msg_data);
136  }
137  free(reference);
138  free(true_from);
139 
140  return request;
141 }
142 
143 /*
144  * This method adds a copy of xml_response_data
145  */
146 xmlNode *
147 create_reply_adv(xmlNode * original_request, xmlNode * xml_response_data, const char *origin)
148 {
149  xmlNode *reply = NULL;
150 
151  const char *host_from = crm_element_value(original_request, F_CRM_HOST_FROM);
152  const char *sys_from = crm_element_value(original_request, F_CRM_SYS_FROM);
153  const char *sys_to = crm_element_value(original_request, F_CRM_SYS_TO);
154  const char *type = crm_element_value(original_request, F_CRM_MSG_TYPE);
155  const char *operation = crm_element_value(original_request, F_CRM_TASK);
156  const char *crm_msg_reference = crm_element_value(original_request, F_CRM_REFERENCE);
157 
158  if (type == NULL) {
159  crm_err("Cannot create new_message, no message type in original message");
160  CRM_ASSERT(type != NULL);
161  return NULL;
162 #if 0
163  } else if (strcasecmp(XML_ATTR_REQUEST, type) != 0) {
164  crm_err("Cannot create new_message, original message was not a request");
165  return NULL;
166 #endif
167  }
168  reply = create_xml_node(NULL, __FUNCTION__);
169  if (reply == NULL) {
170  crm_err("Cannot create new_message, malloc failed");
171  return NULL;
172  }
173 
174  crm_xml_add(reply, F_CRM_ORIGIN, origin);
175  crm_xml_add(reply, F_TYPE, T_CRM);
178  crm_xml_add(reply, F_CRM_REFERENCE, crm_msg_reference);
179  crm_xml_add(reply, F_CRM_TASK, operation);
180 
181  /* since this is a reply, we reverse the from and to */
182  crm_xml_add(reply, F_CRM_SYS_TO, sys_from);
183  crm_xml_add(reply, F_CRM_SYS_FROM, sys_to);
184 
185  /* HOSTTO will be ignored if it is to the DC anyway. */
186  if (host_from != NULL && strlen(host_from) > 0) {
187  crm_xml_add(reply, F_CRM_HOST_TO, host_from);
188  }
189 
190  if (xml_response_data != NULL) {
191  add_message_xml(reply, F_CRM_DATA, xml_response_data);
192  }
193 
194  return reply;
195 }
196 
197 /* Libqb based IPC */
198 
199 /* Server... */
200 
201 GHashTable *client_connections = NULL;
202 
203 crm_client_t *
204 crm_client_get(qb_ipcs_connection_t * c)
205 {
206  if (client_connections) {
207  return g_hash_table_lookup(client_connections, c);
208  }
209 
210  crm_trace("No client found for %p", c);
211  return NULL;
212 }
213 
214 crm_client_t *
215 crm_client_get_by_id(const char *id)
216 {
217  gpointer key;
218  crm_client_t *client;
219  GHashTableIter iter;
220 
221  if (client_connections && id) {
222  g_hash_table_iter_init(&iter, client_connections);
223  while (g_hash_table_iter_next(&iter, &key, (gpointer *) & client)) {
224  if (strcmp(client->id, id) == 0) {
225  return client;
226  }
227  }
228  }
229 
230  crm_trace("No client found with id=%s", id);
231  return NULL;
232 }
233 
234 const char *
236 {
237  if (c == NULL) {
238  return "null";
239  } else if (c->name == NULL && c->id == NULL) {
240  return "unknown";
241  } else if (c->name == NULL) {
242  return c->id;
243  } else {
244  return c->name;
245  }
246 }
247 
248 void
250 {
251  if (client_connections == NULL) {
252  crm_trace("Creating client hash table");
253  client_connections = g_hash_table_new(g_direct_hash, g_direct_equal);
254  }
255 }
256 
257 void
259 {
260  if (client_connections != NULL) {
261  int active = g_hash_table_size(client_connections);
262 
263  if (active) {
264  crm_err("Exiting with %d active connections", active);
265  }
266  g_hash_table_destroy(client_connections); client_connections = NULL;
267  }
268 }
269 
270 void
271 crm_client_disconnect_all(qb_ipcs_service_t *service)
272 {
273  qb_ipcs_connection_t *c = NULL;
274 
275  if (service == NULL) {
276  return;
277  }
278 
279  c = qb_ipcs_connection_first_get(service);
280 
281  while (c != NULL) {
282  qb_ipcs_connection_t *last = c;
283 
284  c = qb_ipcs_connection_next_get(service, last);
285 
286  /* There really shouldn't be anyone connected at this point */
287  crm_notice("Disconnecting client %p, pid=%d...", last, crm_ipcs_client_pid(last));
288  qb_ipcs_disconnect(last);
289  qb_ipcs_connection_unref(last);
290  }
291 }
292 
293 crm_client_t *
294 crm_client_new(qb_ipcs_connection_t * c, uid_t uid_client, gid_t gid_client)
295 {
296  static gid_t gid_cluster = 0;
297 
298  crm_client_t *client = NULL;
299 
300  CRM_LOG_ASSERT(c);
301  if (c == NULL) {
302  return NULL;
303  }
304 
305  if (gid_cluster == 0) {
306  if(crm_user_lookup(CRM_DAEMON_USER, NULL, &gid_cluster) < 0) {
307  static bool have_error = FALSE;
308  if(have_error == FALSE) {
309  crm_warn("Could not find group for user %s", CRM_DAEMON_USER);
310  have_error = TRUE;
311  }
312  }
313  }
314 
315  if (uid_client != 0) {
316  crm_trace("Giving access to group %u", gid_cluster);
317  /* Passing -1 to chown(2) means don't change */
318  qb_ipcs_connection_auth_set(c, -1, gid_cluster, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP);
319  }
320 
321  crm_client_init();
322 
323  /* TODO: Do our own auth checking, return NULL if unauthorized */
324  client = calloc(1, sizeof(crm_client_t));
325 
326  client->ipcs = c;
327  client->kind = CRM_CLIENT_IPC;
328  client->pid = crm_ipcs_client_pid(c);
329 
330  client->id = crm_generate_uuid();
331 
332  if (uid_client == 0) {
333  /* Remember when a connection came from root or hacluster */
335  }
336 
337  crm_debug("Connecting %p for uid=%d gid=%d pid=%u id=%s", c, uid_client, gid_client, client->pid, client->id);
338 
339 #if ENABLE_ACL
340  client->user = uid2username(uid_client);
341 #endif
342 
343  g_hash_table_insert(client_connections, c, client);
344  return client;
345 }
346 
347 void
349 {
350  if (c == NULL) {
351  return;
352  }
353 
354  if (client_connections) {
355  if (c->ipcs) {
356  crm_trace("Destroying %p/%p (%d remaining)",
357  c, c->ipcs, crm_hash_table_size(client_connections) - 1);
358  g_hash_table_remove(client_connections, c->ipcs);
359 
360  } else {
361  crm_trace("Destroying remote connection %p (%d remaining)",
362  c, crm_hash_table_size(client_connections) - 1);
363  g_hash_table_remove(client_connections, c->id);
364  }
365  }
366 
367  if (c->event_timer) {
368  g_source_remove(c->event_timer);
369  }
370 
371  crm_debug("Destroying %d events", g_list_length(c->event_queue));
372  while (c->event_queue) {
373  struct iovec *event = c->event_queue->data;
374 
375  c->event_queue = g_list_remove(c->event_queue, event);
376  free(event[0].iov_base);
377  free(event[1].iov_base);
378  free(event);
379  }
380 
381  free(c->id);
382  free(c->name);
383  free(c->user);
384  if (c->remote) {
385  if (c->remote->auth_timeout) {
386  g_source_remove(c->remote->auth_timeout);
387  }
388  free(c->remote->buffer);
389  free(c->remote);
390  }
391  free(c);
392 }
393 
394 int
395 crm_ipcs_client_pid(qb_ipcs_connection_t * c)
396 {
397  struct qb_ipcs_connection_stats stats;
398 
399  stats.client_pid = 0;
400  qb_ipcs_connection_stats_get(c, &stats, 0);
401  return stats.client_pid;
402 }
403 
404 xmlNode *
406 {
407  xmlNode *xml = NULL;
408  char *uncompressed = NULL;
409  char *text = ((char *)data) + sizeof(struct crm_ipc_response_header);
410  struct crm_ipc_response_header *header = data;
411 
412  if (id) {
413  *id = ((struct qb_ipc_response_header *)data)->id;
414  }
415  if (flags) {
416  *flags = header->flags;
417  }
418 
419  if (is_set(header->flags, crm_ipc_proxied)) {
420  /* mark this client as being the endpoint of a proxy connection.
421  * Proxy connections responses are sent on the event channel to avoid
422  * blocking the proxy daemon (crmd) */
424  }
425 
426  if(header->version > PCMK_IPC_VERSION) {
427  crm_err("Filtering incompatible v%d IPC message, we only support versions <= %d",
428  header->version, PCMK_IPC_VERSION);
429  return NULL;
430  }
431 
432  if (header->size_compressed) {
433  int rc = 0;
434  unsigned int size_u = 1 + header->size_uncompressed;
435  uncompressed = calloc(1, size_u);
436 
437  crm_trace("Decompressing message data %u bytes into %u bytes",
438  header->size_compressed, size_u);
439 
440  rc = BZ2_bzBuffToBuffDecompress(uncompressed, &size_u, text, header->size_compressed, 1, 0);
441  text = uncompressed;
442 
443  if (rc != BZ_OK) {
444  crm_err("Decompression failed: %s (%d)", bz2_strerror(rc), rc);
445  free(uncompressed);
446  return NULL;
447  }
448  }
449 
450  CRM_ASSERT(text[header->size_uncompressed - 1] == 0);
451 
452  crm_trace("Received %.200s", text);
453  xml = string2xml(text);
454 
455  free(uncompressed);
456  return xml;
457 }
458 
460 
461 static gboolean
462 crm_ipcs_flush_events_cb(gpointer data)
463 {
464  crm_client_t *c = data;
465 
466  c->event_timer = 0;
468  return FALSE;
469 }
470 
471 ssize_t
473 {
474  int sent = 0;
475  ssize_t rc = 0;
476  int queue_len = 0;
477 
478  if (c == NULL) {
479  return pcmk_ok;
480 
481  } else if (c->event_timer) {
482  /* There is already a timer, wait until it goes off */
483  crm_trace("Timer active for %p - %d", c->ipcs, c->event_timer);
484  return pcmk_ok;
485  }
486 
487  queue_len = g_list_length(c->event_queue);
488  while (c->event_queue && sent < 100) {
489  struct crm_ipc_response_header *header = NULL;
490  struct iovec *event = c->event_queue->data;
491 
492  rc = qb_ipcs_event_sendv(c->ipcs, event, 2);
493  if (rc < 0) {
494  break;
495  }
496 
497  sent++;
498  header = event[0].iov_base;
499  if (header->size_compressed) {
500  crm_trace("Event %d to %p[%d] (%lld compressed bytes) sent",
501  header->qb.id, c->ipcs, c->pid, (long long) rc);
502  } else {
503  crm_trace("Event %d to %p[%d] (%lld bytes) sent: %.120s",
504  header->qb.id, c->ipcs, c->pid, (long long) rc,
505  (char *) (event[1].iov_base));
506  }
507 
508  c->event_queue = g_list_remove(c->event_queue, event);
509  free(event[0].iov_base);
510  free(event[1].iov_base);
511  free(event);
512  }
513 
514  queue_len -= sent;
515  if (sent > 0 || c->event_queue) {
516  crm_trace("Sent %d events (%d remaining) for %p[%d]: %s (%lld)",
517  sent, queue_len, c->ipcs, c->pid,
518  pcmk_strerror(rc < 0 ? rc : 0), (long long) rc);
519  }
520 
521  if (c->event_queue) {
522  if (queue_len % 100 == 0 && queue_len > 99) {
523  crm_warn("Event queue for %p[%d] has grown to %d", c->ipcs, c->pid, queue_len);
524 
525  } else if (queue_len > 500) {
526  crm_err("Evicting slow client %p[%d]: event queue reached %d entries",
527  c->ipcs, c->pid, queue_len);
528  qb_ipcs_disconnect(c->ipcs);
529  return rc;
530  }
531 
532  c->event_timer = g_timeout_add(1000 + 100 * queue_len, crm_ipcs_flush_events_cb, c);
533  }
534 
535  return rc;
536 }
537 
538 ssize_t
539 crm_ipc_prepare(uint32_t request, xmlNode * message, struct iovec ** result, uint32_t max_send_size)
540 {
541  static unsigned int biggest = 0;
542  struct iovec *iov;
543  unsigned int total = 0;
544  char *compressed = NULL;
545  char *buffer = dump_xml_unformatted(message);
546  struct crm_ipc_response_header *header = calloc(1, sizeof(struct crm_ipc_response_header));
547 
548  CRM_ASSERT(result != NULL);
549 
550  crm_ipc_init();
551 
552  if (max_send_size == 0) {
553  max_send_size = ipc_buffer_max;
554  }
555 
556  CRM_LOG_ASSERT(max_send_size != 0);
557 
558  *result = NULL;
559  iov = calloc(2, sizeof(struct iovec));
560 
561 
562  iov[0].iov_len = hdr_offset;
563  iov[0].iov_base = header;
564 
565  header->version = PCMK_IPC_VERSION;
566  header->size_uncompressed = 1 + strlen(buffer);
567  total = iov[0].iov_len + header->size_uncompressed;
568 
569  if (total < max_send_size) {
570  iov[1].iov_base = buffer;
571  iov[1].iov_len = header->size_uncompressed;
572 
573  } else {
574  unsigned int new_size = 0;
575 
577  (buffer, header->size_uncompressed, max_send_size, &compressed, &new_size)) {
578 
579  header->flags |= crm_ipc_compressed;
580  header->size_compressed = new_size;
581 
582  iov[1].iov_len = header->size_compressed;
583  iov[1].iov_base = compressed;
584 
585  free(buffer);
586 
587  biggest = QB_MAX(header->size_compressed, biggest);
588 
589  } else {
590  ssize_t rc = -EMSGSIZE;
591 
592  crm_log_xml_trace(message, "EMSGSIZE");
593  biggest = QB_MAX(header->size_uncompressed, biggest);
594 
595  crm_err
596  ("Could not compress the message (%u bytes) into less than the configured ipc limit (%u bytes). "
597  "Set PCMK_ipc_buffer to a higher value (%u bytes suggested)",
598  header->size_uncompressed, max_send_size, 4 * biggest);
599 
600  free(compressed);
601  free(buffer);
602  free(header);
603  free(iov);
604 
605  return rc;
606  }
607  }
608 
609  header->qb.size = iov[0].iov_len + iov[1].iov_len;
610  header->qb.id = (int32_t)request; /* Replying to a specific request */
611 
612  *result = iov;
613  CRM_ASSERT(header->qb.size > 0);
614  return header->qb.size;
615 }
616 
617 ssize_t
618 crm_ipcs_sendv(crm_client_t * c, struct iovec * iov, enum crm_ipc_flags flags)
619 {
620  ssize_t rc;
621  static uint32_t id = 1;
622  struct crm_ipc_response_header *header = iov[0].iov_base;
623 
625  /* _ALL_ replies to proxied connections need to be sent as events */
626  if (is_not_set(flags, crm_ipc_server_event)) {
627  flags |= crm_ipc_server_event;
628  /* this flag lets us know this was originally meant to be a response.
629  * even though we're sending it over the event channel. */
631  }
632  }
633 
634  header->flags |= flags;
635  if (flags & crm_ipc_server_event) {
636  header->qb.id = id++; /* We don't really use it, but doesn't hurt to set one */
637 
638  if (flags & crm_ipc_server_free) {
639  crm_trace("Sending the original to %p[%d]", c->ipcs, c->pid);
640  c->event_queue = g_list_append(c->event_queue, iov);
641 
642  } else {
643  struct iovec *iov_copy = calloc(2, sizeof(struct iovec));
644 
645  crm_trace("Sending a copy to %p[%d]", c->ipcs, c->pid);
646  iov_copy[0].iov_len = iov[0].iov_len;
647  iov_copy[0].iov_base = malloc(iov[0].iov_len);
648  memcpy(iov_copy[0].iov_base, iov[0].iov_base, iov[0].iov_len);
649 
650  iov_copy[1].iov_len = iov[1].iov_len;
651  iov_copy[1].iov_base = malloc(iov[1].iov_len);
652  memcpy(iov_copy[1].iov_base, iov[1].iov_base, iov[1].iov_len);
653 
654  c->event_queue = g_list_append(c->event_queue, iov_copy);
655  }
656 
657  } else {
658  CRM_LOG_ASSERT(header->qb.id != 0); /* Replying to a specific request */
659 
660  rc = qb_ipcs_response_sendv(c->ipcs, iov, 2);
661  if (rc < header->qb.size) {
662  crm_notice("Response %d to %p[%d] (%u bytes) failed: %s (%d)",
663  header->qb.id, c->ipcs, c->pid, header->qb.size, pcmk_strerror(rc), rc);
664 
665  } else {
666  crm_trace("Response %d sent, %lld bytes to %p[%d]",
667  header->qb.id, (long long) rc, c->ipcs, c->pid);
668  }
669 
670  if (flags & crm_ipc_server_free) {
671  free(iov[0].iov_base);
672  free(iov[1].iov_base);
673  free(iov);
674  }
675  }
676 
677  if (flags & crm_ipc_server_event) {
678  rc = crm_ipcs_flush_events(c);
679  } else {
681  }
682 
683  if (rc == -EPIPE || rc == -ENOTCONN) {
684  crm_trace("Client %p disconnected", c->ipcs);
685  }
686 
687  return rc;
688 }
689 
690 ssize_t
691 crm_ipcs_send(crm_client_t * c, uint32_t request, xmlNode * message,
692  enum crm_ipc_flags flags)
693 {
694  struct iovec *iov = NULL;
695  ssize_t rc = 0;
696 
697  if(c == NULL) {
698  return -EDESTADDRREQ;
699  }
700  crm_ipc_init();
701 
702  rc = crm_ipc_prepare(request, message, &iov, ipc_buffer_max);
703  if (rc > 0) {
704  rc = crm_ipcs_sendv(c, iov, flags | crm_ipc_server_free);
705 
706  } else {
707  free(iov);
708  crm_notice("Message to %p[%d] failed: %s (%d)",
709  c->ipcs, c->pid, pcmk_strerror(rc), rc);
710  }
711 
712  return rc;
713 }
714 
715 void
716 crm_ipcs_send_ack(crm_client_t * c, uint32_t request, uint32_t flags, const char *tag, const char *function,
717  int line)
718 {
719  if (flags & crm_ipc_client_response) {
720  xmlNode *ack = create_xml_node(NULL, tag);
721 
722  crm_trace("Ack'ing msg from %s (%p)", crm_client_name(c), c);
723  c->request_id = 0;
724  crm_xml_add(ack, "function", function);
725  crm_xml_add_int(ack, "line", line);
726  crm_ipcs_send(c, request, ack, flags);
727  free_xml(ack);
728  }
729 }
730 
731 /* Client... */
732 
733 #define MIN_MSG_SIZE 12336 /* sizeof(struct qb_ipc_connection_response) */
734 #define MAX_MSG_SIZE 128*1024 /* 128k default */
735 
736 struct crm_ipc_s {
737  struct pollfd pfd;
738 
739  /* the max size we can send/receive over ipc */
740  unsigned int max_buf_size;
741  /* Size of the allocated 'buffer' */
742  unsigned int buf_size;
743  int msg_size;
744  int need_reply;
745  char *buffer;
746  char *name;
747  uint32_t buffer_flags;
748 
749  qb_ipcc_connection_t *ipc;
750 
751 };
752 
753 static unsigned int
754 pick_ipc_buffer(unsigned int max)
755 {
756  static unsigned int global_max = 0;
757 
758  if (global_max == 0) {
759  const char *env = getenv("PCMK_ipc_buffer");
760 
761  if (env) {
762  int env_max = crm_parse_int(env, "0");
763 
764  global_max = (env_max > 0)? QB_MAX(MIN_MSG_SIZE, env_max) : MAX_MSG_SIZE;
765 
766  } else {
767  global_max = MAX_MSG_SIZE;
768  }
769  }
770 
771  return QB_MAX(max, global_max);
772 }
773 
774 crm_ipc_t *
775 crm_ipc_new(const char *name, size_t max_size)
776 {
777  crm_ipc_t *client = NULL;
778 
779  client = calloc(1, sizeof(crm_ipc_t));
780 
781  client->name = strdup(name);
782  client->buf_size = pick_ipc_buffer(max_size);
783  client->buffer = malloc(client->buf_size);
784 
785  /* Clients initiating connection pick the max buf size */
786  client->max_buf_size = client->buf_size;
787 
788  client->pfd.fd = -1;
789  client->pfd.events = POLLIN;
790  client->pfd.revents = 0;
791 
792  return client;
793 }
794 
802 bool
804 {
805  client->need_reply = FALSE;
806  client->ipc = qb_ipcc_connect(client->name, client->buf_size);
807 
808  if (client->ipc == NULL) {
809  crm_debug("Could not establish %s connection: %s (%d)", client->name, pcmk_strerror(errno), errno);
810  return FALSE;
811  }
812 
813  client->pfd.fd = crm_ipc_get_fd(client);
814  if (client->pfd.fd < 0) {
815  crm_debug("Could not obtain file descriptor for %s connection: %s (%d)", client->name, pcmk_strerror(errno), errno);
816  return FALSE;
817  }
818 
819  qb_ipcc_context_set(client->ipc, client);
820 
821 #ifdef HAVE_IPCS_GET_BUFFER_SIZE
822  client->max_buf_size = qb_ipcc_get_buffer_size(client->ipc);
823  if (client->max_buf_size > client->buf_size) {
824  free(client->buffer);
825  client->buffer = calloc(1, client->max_buf_size);
826  client->buf_size = client->max_buf_size;
827  }
828 #endif
829 
830  return TRUE;
831 }
832 
833 void
835 {
836  if (client) {
837  crm_trace("Disconnecting %s IPC connection %p (%p)", client->name, client, client->ipc);
838 
839  if (client->ipc) {
840  qb_ipcc_connection_t *ipc = client->ipc;
841 
842  client->ipc = NULL;
843  qb_ipcc_disconnect(ipc);
844  }
845  }
846 }
847 
848 void
850 {
851  if (client) {
852  if (client->ipc && qb_ipcc_is_connected(client->ipc)) {
853  crm_notice("Destroying an active IPC connection to %s", client->name);
854  /* The next line is basically unsafe
855  *
856  * If this connection was attached to mainloop and mainloop is active,
857  * the 'disconnected' callback will end up back here and we'll end
858  * up free'ing the memory twice - something that can still happen
859  * even without this if we destroy a connection and it closes before
860  * we call exit
861  */
862  /* crm_ipc_close(client); */
863  }
864  crm_trace("Destroying IPC connection to %s: %p", client->name, client);
865  free(client->buffer);
866  free(client->name);
867  free(client);
868  }
869 }
870 
871 int
873 {
874  int fd = 0;
875 
876  if (client && client->ipc && (qb_ipcc_fd_get(client->ipc, &fd) == 0)) {
877  return fd;
878  }
879  errno = EINVAL;
880  crm_perror(LOG_ERR, "Could not obtain file IPC descriptor for %s",
881  (client? client->name : "unspecified client"));
882  return -errno;
883 }
884 
885 bool
887 {
888  bool rc = FALSE;
889 
890  if (client == NULL) {
891  crm_trace("No client");
892  return FALSE;
893 
894  } else if (client->ipc == NULL) {
895  crm_trace("No connection");
896  return FALSE;
897 
898  } else if (client->pfd.fd < 0) {
899  crm_trace("Bad descriptor");
900  return FALSE;
901  }
902 
903  rc = qb_ipcc_is_connected(client->ipc);
904  if (rc == FALSE) {
905  client->pfd.fd = -EINVAL;
906  }
907  return rc;
908 }
909 
917 int
919 {
920  int rc;
921 
922  CRM_ASSERT(client != NULL);
923 
924  if (crm_ipc_connected(client) == FALSE) {
925  return -ENOTCONN;
926  }
927 
928  client->pfd.revents = 0;
929  rc = poll(&(client->pfd), 1, 0);
930  return (rc < 0)? -errno : rc;
931 }
932 
933 static int
934 crm_ipc_decompress(crm_ipc_t * client)
935 {
936  struct crm_ipc_response_header *header = (struct crm_ipc_response_header *)(void*)client->buffer;
937 
938  if (header->size_compressed) {
939  int rc = 0;
940  unsigned int size_u = 1 + header->size_uncompressed;
941  /* never let buf size fall below our max size required for ipc reads. */
942  unsigned int new_buf_size = QB_MAX((hdr_offset + size_u), client->max_buf_size);
943  char *uncompressed = calloc(1, new_buf_size);
944 
945  crm_trace("Decompressing message data %u bytes into %u bytes",
946  header->size_compressed, size_u);
947 
948  rc = BZ2_bzBuffToBuffDecompress(uncompressed + hdr_offset, &size_u,
949  client->buffer + hdr_offset, header->size_compressed, 1, 0);
950 
951  if (rc != BZ_OK) {
952  crm_err("Decompression failed: %s (%d)", bz2_strerror(rc), rc);
953  free(uncompressed);
954  return -EILSEQ;
955  }
956 
957  /*
958  * This assert no longer holds true. For an identical msg, some clients may
959  * require compression, and others may not. If that same msg (event) is sent
960  * to multiple clients, it could result in some clients receiving a compressed
961  * msg even though compression was not explicitly required for them.
962  *
963  * CRM_ASSERT((header->size_uncompressed + hdr_offset) >= ipc_buffer_max);
964  */
965  CRM_ASSERT(size_u == header->size_uncompressed);
966 
967  memcpy(uncompressed, client->buffer, hdr_offset); /* Preserve the header */
968  header = (struct crm_ipc_response_header *)(void*)uncompressed;
969 
970  free(client->buffer);
971  client->buf_size = new_buf_size;
972  client->buffer = uncompressed;
973  }
974 
975  CRM_ASSERT(client->buffer[hdr_offset + header->size_uncompressed - 1] == 0);
976  return pcmk_ok;
977 }
978 
979 long
981 {
982  struct crm_ipc_response_header *header = NULL;
983 
984  CRM_ASSERT(client != NULL);
985  CRM_ASSERT(client->ipc != NULL);
986  CRM_ASSERT(client->buffer != NULL);
987 
988  crm_ipc_init();
989 
990  client->buffer[0] = 0;
991  client->msg_size = qb_ipcc_event_recv(client->ipc, client->buffer, client->buf_size - 1, 0);
992  if (client->msg_size >= 0) {
993  int rc = crm_ipc_decompress(client);
994 
995  if (rc != pcmk_ok) {
996  return rc;
997  }
998 
999  header = (struct crm_ipc_response_header *)(void*)client->buffer;
1000  if(header->version > PCMK_IPC_VERSION) {
1001  crm_err("Filtering incompatible v%d IPC message, we only support versions <= %d",
1002  header->version, PCMK_IPC_VERSION);
1003  return -EBADMSG;
1004  }
1005 
1006  crm_trace("Received %s event %d, size=%u, rc=%d, text: %.100s",
1007  client->name, header->qb.id, header->qb.size, client->msg_size,
1008  client->buffer + hdr_offset);
1009 
1010  } else {
1011  crm_trace("No message from %s received: %s", client->name, pcmk_strerror(client->msg_size));
1012  }
1013 
1014  if (crm_ipc_connected(client) == FALSE || client->msg_size == -ENOTCONN) {
1015  crm_err("Connection to %s failed", client->name);
1016  }
1017 
1018  if (header) {
1019  /* Data excluding the header */
1020  return header->size_uncompressed;
1021  }
1022  return -ENOMSG;
1023 }
1024 
1025 const char *
1027 {
1028  CRM_ASSERT(client != NULL);
1029  return client->buffer + sizeof(struct crm_ipc_response_header);
1030 }
1031 
1032 uint32_t
1034 {
1035  struct crm_ipc_response_header *header = NULL;
1036 
1037  CRM_ASSERT(client != NULL);
1038  if (client->buffer == NULL) {
1039  return 0;
1040  }
1041 
1042  header = (struct crm_ipc_response_header *)(void*)client->buffer;
1043  return header->flags;
1044 }
1045 
1046 const char *
1048 {
1049  CRM_ASSERT(client != NULL);
1050  return client->name;
1051 }
1052 
1053 static int
1054 internal_ipc_send_recv(crm_ipc_t * client, const void *iov)
1055 {
1056  int rc = 0;
1057 
1058  do {
1059  rc = qb_ipcc_sendv_recv(client->ipc, iov, 2, client->buffer, client->buf_size, -1);
1060  } while (rc == -EAGAIN && crm_ipc_connected(client));
1061 
1062  return rc;
1063 }
1064 
1065 static int
1066 internal_ipc_send_request(crm_ipc_t * client, const void *iov, int ms_timeout)
1067 {
1068  int rc = 0;
1069  time_t timeout = time(NULL) + 1 + (ms_timeout / 1000);
1070 
1071  do {
1072  rc = qb_ipcc_sendv(client->ipc, iov, 2);
1073  } while (rc == -EAGAIN && time(NULL) < timeout && crm_ipc_connected(client));
1074 
1075  return rc;
1076 }
1077 
1078 static int
1079 internal_ipc_get_reply(crm_ipc_t * client, int request_id, int ms_timeout)
1080 {
1081  time_t timeout = time(NULL) + 1 + (ms_timeout / 1000);
1082  int rc = 0;
1083 
1084  crm_ipc_init();
1085 
1086  /* get the reply */
1087  crm_trace("client %s waiting on reply to msg id %d", client->name, request_id);
1088  do {
1089 
1090  rc = qb_ipcc_recv(client->ipc, client->buffer, client->buf_size, 1000);
1091  if (rc > 0) {
1092  struct crm_ipc_response_header *hdr = NULL;
1093 
1094  int rc = crm_ipc_decompress(client);
1095 
1096  if (rc != pcmk_ok) {
1097  return rc;
1098  }
1099 
1100  hdr = (struct crm_ipc_response_header *)(void*)client->buffer;
1101  if (hdr->qb.id == request_id) {
1102  /* Got it */
1103  break;
1104  } else if (hdr->qb.id < request_id) {
1105  xmlNode *bad = string2xml(crm_ipc_buffer(client));
1106 
1107  crm_err("Discarding old reply %d (need %d)", hdr->qb.id, request_id);
1108  crm_log_xml_notice(bad, "OldIpcReply");
1109 
1110  } else {
1111  xmlNode *bad = string2xml(crm_ipc_buffer(client));
1112 
1113  crm_err("Discarding newer reply %d (need %d)", hdr->qb.id, request_id);
1114  crm_log_xml_notice(bad, "ImpossibleReply");
1115  CRM_ASSERT(hdr->qb.id <= request_id);
1116  }
1117  } else if (crm_ipc_connected(client) == FALSE) {
1118  crm_err("Server disconnected client %s while waiting for msg id %d", client->name,
1119  request_id);
1120  break;
1121  }
1122 
1123  } while (time(NULL) < timeout);
1124 
1125  return rc;
1126 }
1127 
1128 int
1129 crm_ipc_send(crm_ipc_t * client, xmlNode * message, enum crm_ipc_flags flags, int32_t ms_timeout,
1130  xmlNode ** reply)
1131 {
1132  long rc = 0;
1133  struct iovec *iov;
1134  static uint32_t id = 0;
1135  static int factor = 8;
1136  struct crm_ipc_response_header *header;
1137 
1138  crm_ipc_init();
1139 
1140  if (client == NULL) {
1141  crm_notice("Invalid connection");
1142  return -ENOTCONN;
1143 
1144  } else if (crm_ipc_connected(client) == FALSE) {
1145  /* Don't even bother */
1146  crm_notice("Connection to %s closed", client->name);
1147  return -ENOTCONN;
1148  }
1149 
1150  if (ms_timeout == 0) {
1151  ms_timeout = 5000;
1152  }
1153 
1154  if (client->need_reply) {
1155  crm_trace("Trying again to obtain pending reply from %s", client->name);
1156  rc = qb_ipcc_recv(client->ipc, client->buffer, client->buf_size, ms_timeout);
1157  if (rc < 0) {
1158  crm_warn("Sending to %s (%p) is disabled until pending reply is received", client->name,
1159  client->ipc);
1160  return -EALREADY;
1161 
1162  } else {
1163  crm_notice("Lost reply from %s (%p) finally arrived, sending re-enabled", client->name,
1164  client->ipc);
1165  client->need_reply = FALSE;
1166  }
1167  }
1168 
1169  id++;
1170  CRM_LOG_ASSERT(id != 0); /* Crude wrap-around detection */
1171  rc = crm_ipc_prepare(id, message, &iov, client->max_buf_size);
1172  if(rc < 0) {
1173  return rc;
1174  }
1175 
1176  header = iov[0].iov_base;
1177  header->flags |= flags;
1178 
1179  if(is_set(flags, crm_ipc_proxied)) {
1180  /* Don't look for a synchronous response */
1182  }
1183 
1184  if(header->size_compressed) {
1185  if(factor < 10 && (client->max_buf_size / 10) < (rc / factor)) {
1186  crm_notice("Compressed message exceeds %d0%% of the configured ipc limit (%u bytes), "
1187  "consider setting PCMK_ipc_buffer to %u or higher",
1188  factor, client->max_buf_size, 2 * client->max_buf_size);
1189  factor++;
1190  }
1191  }
1192 
1193  crm_trace("Sending from client: %s request id: %d bytes: %u timeout:%d msg...",
1194  client->name, header->qb.id, header->qb.size, ms_timeout);
1195 
1196  if (ms_timeout > 0 || is_not_set(flags, crm_ipc_client_response)) {
1197 
1198  rc = internal_ipc_send_request(client, iov, ms_timeout);
1199 
1200  if (rc <= 0) {
1201  crm_trace("Failed to send from client %s request %d with %u bytes...",
1202  client->name, header->qb.id, header->qb.size);
1203  goto send_cleanup;
1204 
1205  } else if (is_not_set(flags, crm_ipc_client_response)) {
1206  crm_trace("Message sent, not waiting for reply to %d from %s to %u bytes...",
1207  header->qb.id, client->name, header->qb.size);
1208 
1209  goto send_cleanup;
1210  }
1211 
1212  rc = internal_ipc_get_reply(client, header->qb.id, ms_timeout);
1213  if (rc < 0) {
1214  /* No reply, for now, disable sending
1215  *
1216  * The alternative is to close the connection since we don't know
1217  * how to detect and discard out-of-sequence replies
1218  *
1219  * TODO - implement the above
1220  */
1221  client->need_reply = TRUE;
1222  }
1223 
1224  } else {
1225  rc = internal_ipc_send_recv(client, iov);
1226  }
1227 
1228  if (rc > 0) {
1229  struct crm_ipc_response_header *hdr = (struct crm_ipc_response_header *)(void*)client->buffer;
1230 
1231  crm_trace("Received response %d, size=%u, rc=%ld, text: %.200s", hdr->qb.id, hdr->qb.size,
1232  rc, crm_ipc_buffer(client));
1233 
1234  if (reply) {
1235  *reply = string2xml(crm_ipc_buffer(client));
1236  }
1237 
1238  } else {
1239  crm_trace("Response not received: rc=%ld, errno=%d", rc, errno);
1240  }
1241 
1242  send_cleanup:
1243  if (crm_ipc_connected(client) == FALSE) {
1244  crm_notice("Connection to %s closed: %s (%ld)", client->name, pcmk_strerror(rc), rc);
1245 
1246  } else if (rc == -ETIMEDOUT) {
1247  crm_warn("Request %d to %s (%p) failed: %s (%ld) after %dms",
1248  header->qb.id, client->name, client->ipc, pcmk_strerror(rc), rc, ms_timeout);
1249  crm_write_blackbox(0, NULL);
1250 
1251  } else if (rc <= 0) {
1252  crm_warn("Request %d to %s (%p) failed: %s (%ld)",
1253  header->qb.id, client->name, client->ipc, pcmk_strerror(rc), rc);
1254  }
1255 
1256  free(header);
1257  free(iov[1].iov_base);
1258  free(iov);
1259  return rc;
1260 }
1261 
1262 /* Utils */
1263 
1264 xmlNode *
1265 create_hello_message(const char *uuid,
1266  const char *client_name, const char *major_version, const char *minor_version)
1267 {
1268  xmlNode *hello_node = NULL;
1269  xmlNode *hello = NULL;
1270 
1271  if (uuid == NULL || strlen(uuid) == 0
1272  || client_name == NULL || strlen(client_name) == 0
1273  || major_version == NULL || strlen(major_version) == 0
1274  || minor_version == NULL || strlen(minor_version) == 0) {
1275  crm_err("Missing fields, Hello message will not be valid.");
1276  return NULL;
1277  }
1278 
1279  hello_node = create_xml_node(NULL, XML_TAG_OPTIONS);
1280  crm_xml_add(hello_node, "major_version", major_version);
1281  crm_xml_add(hello_node, "minor_version", minor_version);
1282  crm_xml_add(hello_node, "client_name", client_name);
1283  crm_xml_add(hello_node, "client_uuid", uuid);
1284 
1285  crm_trace("creating hello message");
1286  hello = create_request(CRM_OP_HELLO, hello_node, NULL, NULL, client_name, uuid);
1287  free_xml(hello_node);
1288 
1289  return hello;
1290 }
#define F_CRM_TASK
Definition: msg_xml.h:56
const char * crm_ipc_buffer(crm_ipc_t *client)
Definition: ipc.c:1026
#define F_CRM_REFERENCE
Definition: msg_xml.h:62
void crm_write_blackbox(int nsig, struct qb_log_callsite *callsite)
Definition: logging.c:419
A dumping ground.
#define F_TYPE
Definition: msg_xml.h:34
void crm_ipc_close(crm_ipc_t *client)
Definition: ipc.c:834
#define crm_notice(fmt, args...)
Definition: logging.h:250
char * crm_generate_uuid(void)
Definition: utils.c:2078
uint32_t crm_ipc_buffer_flags(crm_ipc_t *client)
Definition: ipc.c:1033
int crm_ipc_send(crm_ipc_t *client, xmlNode *message, enum crm_ipc_flags flags, int32_t ms_timeout, xmlNode **reply)
Definition: ipc.c:1129
#define F_CRM_HOST_TO
Definition: msg_xml.h:57
#define XML_TAG_OPTIONS
Definition: msg_xml.h:120
const char * pcmk_strerror(int rc)
Definition: logging.c:1128
crm_client_t * crm_client_get(qb_ipcs_connection_t *c)
Definition: ipc.c:204
uint32_t flags
Definition: ipcs.h:80
qb_ipcs_connection_t * ipcs
Definition: ipcs.h:91
#define F_CRM_MSG_TYPE
Definition: msg_xml.h:58
uint32_t size
Definition: internal.h:52
int request_id
Definition: ipcs.h:79
#define CRM_FEATURE_SET
Definition: crm.h:36
#define F_CRM_HOST_FROM
Definition: msg_xml.h:61
#define pcmk_ok
Definition: error.h:42
#define T_CRM
Definition: msg_xml.h:46
crm_client_t * crm_client_get_by_id(const char *id)
Definition: ipc.c:215
xmlNode * create_reply_adv(xmlNode *original_request, xmlNode *xml_response_data, const char *origin)
Definition: ipc.c:147
char * buffer
Definition: ipcs.h:43
bool crm_ipc_connect(crm_ipc_t *client)
Establish an IPC connection to a Pacemaker component.
Definition: ipc.c:803
int crm_parse_int(const char *text, const char *default_text)
Definition: strings.c:125
#define PCMK_IPC_VERSION
Definition: ipc.c:38
struct crm_remote_s * remote
Definition: ipcs.h:93
int crm_user_lookup(const char *name, uid_t *uid, gid_t *gid)
Definition: utils.c:413
#define CRM_LOG_ASSERT(expr)
Definition: logging.h:150
void crm_client_destroy(crm_client_t *c)
Definition: ipc.c:348
int crm_ipc_get_fd(crm_ipc_t *client)
Definition: ipc.c:872
void crm_client_init(void)
Definition: ipc.c:249
#define clear_bit(word, bit)
Definition: crm_internal.h:192
void crm_client_disconnect_all(qb_ipcs_service_t *service)
Definition: ipc.c:271
ssize_t crm_ipc_prepare(uint32_t request, xmlNode *message, struct iovec **result, uint32_t max_send_size)
Definition: ipc.c:539
char * user
Definition: ipcs.h:75
ssize_t crm_ipcs_flush_events(crm_client_t *c)
Definition: ipc.c:472
xmlNode * string2xml(const char *input)
Definition: xml.c:2696
char version[256]
Definition: plugin.c:84
#define MAX_MSG_SIZE
Definition: ipc.c:734
#define XML_ATTR_REQUEST
Definition: msg_xml.h:125
ssize_t crm_ipcs_sendv(crm_client_t *c, struct iovec *iov, enum crm_ipc_flags flags)
Definition: ipc.c:618
#define crm_warn(fmt, args...)
Definition: logging.h:249
crm_client_t * crm_client_new(qb_ipcs_connection_t *c, uid_t uid_client, gid_t gid_client)
Definition: ipc.c:294
#define set_bit(word, bit)
Definition: crm_internal.h:191
#define crm_debug(fmt, args...)
Definition: logging.h:253
#define F_CRM_SYS_TO
Definition: msg_xml.h:59
struct crm_ipc_s crm_ipc_t
Definition: ipc.h:61
const char * crm_ipc_name(crm_ipc_t *client)
Definition: ipc.c:1047
GList * event_queue
Definition: ipcs.h:84
GHashTable * client_connections
Definition: ipc.c:201
unsigned int crm_ipc_default_buffer_size(void)
Definition: ipc.c:64
#define crm_trace(fmt, args...)
Definition: logging.h:254
void crm_ipc_destroy(crm_ipc_t *client)
Definition: ipc.c:849
xmlNode * create_xml_node(xmlNode *parent, const char *name)
Definition: xml.c:2532
const char * crm_element_value(xmlNode *data, const char *name)
Definition: xml.c:4987
#define CRM_DAEMON_USER
Definition: config.h:47
gboolean add_message_xml(xmlNode *msg, const char *field, xmlNode *xml)
Definition: xml.c:3072
void free_xml(xmlNode *child)
Definition: xml.c:2587
void crm_ipcs_send_ack(crm_client_t *c, uint32_t request, uint32_t flags, const char *tag, const char *function, int line)
Definition: ipc.c:716
xmlNode * crm_ipcs_recv(crm_client_t *c, void *data, size_t size, uint32_t *id, uint32_t *flags)
Definition: ipc.c:405
int auth_timeout
Definition: ipcs.h:46
#define F_CRM_DATA
Definition: msg_xml.h:55
const char * crm_xml_add(xmlNode *node, const char *name, const char *value)
Definition: xml.c:2434
const char * crm_xml_add_int(xmlNode *node, const char *name, int value)
Definition: xml.c:2522
bool crm_compress_string(const char *data, int length, int max, char **result, unsigned int *result_len)
Definition: strings.c:311
ssize_t crm_ipcs_send(crm_client_t *c, uint32_t request, xmlNode *message, enum crm_ipc_flags flags)
Definition: ipc.c:691
uint pid
Definition: ipcs.h:68
int event_timer
Definition: ipcs.h:83
#define crm_perror(level, fmt, args...)
Log a system error message.
Definition: logging.h:226
xmlNode * create_hello_message(const char *uuid, const char *client_name, const char *major_version, const char *minor_version)
Definition: ipc.c:1265
#define CRM_OP_HELLO
Definition: crm.h:112
#define crm_err(fmt, args...)
Definition: logging.h:248
const char * bz2_strerror(int rc)
Definition: logging.c:1191
#define F_CRM_SYS_FROM
Definition: msg_xml.h:60
#define crm_log_xml_notice(xml, text)
Definition: logging.h:259
char * dump_xml_unformatted(xmlNode *msg)
Definition: xml.c:3726
int crm_ipc_ready(crm_ipc_t *client)
Check whether an IPC connection is ready to be read.
Definition: ipc.c:918
#define uint32_t
Definition: stdint.in.h:158
#define XML_ATTR_RESPONSE
Definition: msg_xml.h:126
#define CRM_ASSERT(expr)
Definition: error.h:35
char data[0]
Definition: internal.h:58
long crm_ipc_read(crm_ipc_t *client)
Definition: ipc.c:980
char * id
Definition: ipcs.h:73
#define uint8_t
Definition: stdint.in.h:144
Wrappers for and extensions to libqb IPC.
char * generate_hash_key(const char *crm_msg_reference, const char *sys)
Definition: utils.c:403
#define F_CRM_ORIGIN
Definition: msg_xml.h:64
int crm_ipcs_client_pid(qb_ipcs_connection_t *c)
Definition: ipc.c:395
#define crm_log_xml_trace(xml, text)
Definition: logging.h:262
void crm_client_cleanup(void)
Definition: ipc.c:258
enum client_type kind
Definition: ipcs.h:89
const char * crm_client_name(crm_client_t *c)
Definition: ipc.c:235
bool crm_ipc_connected(crm_ipc_t *client)
Definition: ipc.c:886
crm_ipc_t * crm_ipc_new(const char *name, size_t max_size)
Definition: ipc.c:775
char * name
Definition: ipcs.h:74
crm_ipc_flags
Definition: ipc.h:41
xmlNode * create_request_adv(const char *task, xmlNode *msg_data, const char *host_to, const char *sys_to, const char *sys_from, const char *uuid_from, const char *origin)
Definition: ipc.c:102
#define create_request(task, xml_data, host_to, sys_to, sys_from, uuid_from)
Definition: ipc.h:34
char * uid2username(uid_t uid)
#define F_CRM_VERSION
Definition: msg_xml.h:63
uint64_t flags
Definition: remote.c:121
#define MIN_MSG_SIZE
Definition: ipc.c:733
enum crm_ais_msg_types type
Definition: internal.h:51
#define int32_t
Definition: stdint.in.h:157