pacemaker  1.1.14-70404b0
Scalable High-Availability cluster resource manager
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
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 = qb_ipcs_connection_first_get(service);
274 
275  while (c != NULL) {
276  qb_ipcs_connection_t *last = c;
277 
278  c = qb_ipcs_connection_next_get(service, last);
279 
280  /* There really shouldn't be anyone connected at this point */
281  crm_notice("Disconnecting client %p, pid=%d...", last, crm_ipcs_client_pid(last));
282  qb_ipcs_disconnect(last);
283  qb_ipcs_connection_unref(last);
284  }
285 }
286 
287 crm_client_t *
288 crm_client_new(qb_ipcs_connection_t * c, uid_t uid_client, gid_t gid_client)
289 {
290  static gid_t gid_cluster = 0;
291 
292  crm_client_t *client = NULL;
293 
294  CRM_LOG_ASSERT(c);
295  if (c == NULL) {
296  return NULL;
297  }
298 
299  if (gid_cluster == 0) {
300  if(crm_user_lookup(CRM_DAEMON_USER, NULL, &gid_cluster) < 0) {
301  static bool have_error = FALSE;
302  if(have_error == FALSE) {
303  crm_warn("Could not find group for user %s", CRM_DAEMON_USER);
304  have_error = TRUE;
305  }
306  }
307  }
308 
309  if (uid_client != 0) {
310  crm_trace("Giving access to group %u", gid_cluster);
311  /* Passing -1 to chown(2) means don't change */
312  qb_ipcs_connection_auth_set(c, -1, gid_cluster, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP);
313  }
314 
315  crm_client_init();
316 
317  /* TODO: Do our own auth checking, return NULL if unauthorized */
318  client = calloc(1, sizeof(crm_client_t));
319 
320  client->ipcs = c;
321  client->kind = CRM_CLIENT_IPC;
322  client->pid = crm_ipcs_client_pid(c);
323 
324  client->id = crm_generate_uuid();
325 
326  crm_debug("Connecting %p for uid=%d gid=%d pid=%u id=%s", c, uid_client, gid_client, client->pid, client->id);
327 
328 #if ENABLE_ACL
329  client->user = uid2username(uid_client);
330 #endif
331 
332  g_hash_table_insert(client_connections, c, client);
333  return client;
334 }
335 
336 void
338 {
339  if (c == NULL) {
340  return;
341  }
342 
343  if (client_connections) {
344  if (c->ipcs) {
345  crm_trace("Destroying %p/%p (%d remaining)",
346  c, c->ipcs, crm_hash_table_size(client_connections) - 1);
347  g_hash_table_remove(client_connections, c->ipcs);
348 
349  } else {
350  crm_trace("Destroying remote connection %p (%d remaining)",
351  c, crm_hash_table_size(client_connections) - 1);
352  g_hash_table_remove(client_connections, c->id);
353  }
354  }
355 
356  if (c->event_timer) {
357  g_source_remove(c->event_timer);
358  }
359 
360  crm_debug("Destroying %d events", g_list_length(c->event_queue));
361  while (c->event_queue) {
362  struct iovec *event = c->event_queue->data;
363 
364  c->event_queue = g_list_remove(c->event_queue, event);
365  free(event[0].iov_base);
366  free(event[1].iov_base);
367  free(event);
368  }
369 
370  free(c->id);
371  free(c->name);
372  free(c->user);
373  if (c->remote) {
374  if (c->remote->auth_timeout) {
375  g_source_remove(c->remote->auth_timeout);
376  }
377  free(c->remote->buffer);
378  free(c->remote);
379  }
380  free(c);
381 }
382 
383 int
384 crm_ipcs_client_pid(qb_ipcs_connection_t * c)
385 {
386  struct qb_ipcs_connection_stats stats;
387 
388  stats.client_pid = 0;
389  qb_ipcs_connection_stats_get(c, &stats, 0);
390  return stats.client_pid;
391 }
392 
393 xmlNode *
395 {
396  xmlNode *xml = NULL;
397  char *uncompressed = NULL;
398  char *text = ((char *)data) + sizeof(struct crm_ipc_response_header);
399  struct crm_ipc_response_header *header = data;
400 
401  if (id) {
402  *id = ((struct qb_ipc_response_header *)data)->id;
403  }
404  if (flags) {
405  *flags = header->flags;
406  }
407 
408  if (is_set(header->flags, crm_ipc_proxied)) {
409  /* mark this client as being the endpoint of a proxy connection.
410  * Proxy connections responses are sent on the event channel to avoid
411  * blocking the proxy daemon (crmd) */
413  }
414 
415  if(header->version > PCMK_IPC_VERSION) {
416  crm_err("Filtering incompatible v%d IPC message, we only support versions <= %d",
417  header->version, PCMK_IPC_VERSION);
418  return NULL;
419  }
420 
421  if (header->size_compressed) {
422  int rc = 0;
423  unsigned int size_u = 1 + header->size_uncompressed;
424  uncompressed = calloc(1, size_u);
425 
426  crm_trace("Decompressing message data %u bytes into %u bytes",
427  header->size_compressed, size_u);
428 
429  rc = BZ2_bzBuffToBuffDecompress(uncompressed, &size_u, text, header->size_compressed, 1, 0);
430  text = uncompressed;
431 
432  if (rc != BZ_OK) {
433  crm_err("Decompression failed: %s (%d)", bz2_strerror(rc), rc);
434  free(uncompressed);
435  return NULL;
436  }
437  }
438 
439  CRM_ASSERT(text[header->size_uncompressed - 1] == 0);
440 
441  crm_trace("Received %.200s", text);
442  xml = string2xml(text);
443 
444  free(uncompressed);
445  return xml;
446 }
447 
449 
450 static gboolean
451 crm_ipcs_flush_events_cb(gpointer data)
452 {
453  crm_client_t *c = data;
454 
455  c->event_timer = 0;
457  return FALSE;
458 }
459 
460 ssize_t
462 {
463  int sent = 0;
464  ssize_t rc = 0;
465  int queue_len = 0;
466 
467  if (c == NULL) {
468  return pcmk_ok;
469 
470  } else if (c->event_timer) {
471  /* There is already a timer, wait until it goes off */
472  crm_trace("Timer active for %p - %d", c->ipcs, c->event_timer);
473  return pcmk_ok;
474  }
475 
476  queue_len = g_list_length(c->event_queue);
477  while (c->event_queue && sent < 100) {
478  struct crm_ipc_response_header *header = NULL;
479  struct iovec *event = c->event_queue->data;
480 
481  rc = qb_ipcs_event_sendv(c->ipcs, event, 2);
482  if (rc < 0) {
483  break;
484  }
485 
486  sent++;
487  header = event[0].iov_base;
488  if (header->size_compressed) {
489  crm_trace("Event %d to %p[%d] (%d compressed bytes) sent",
490  header->qb.id, c->ipcs, c->pid, rc);
491  } else {
492  crm_trace("Event %d to %p[%d] (%d bytes) sent: %.120s",
493  header->qb.id, c->ipcs, c->pid, rc, event[1].iov_base);
494  }
495 
496  c->event_queue = g_list_remove(c->event_queue, event);
497  free(event[0].iov_base);
498  free(event[1].iov_base);
499  free(event);
500  }
501 
502  queue_len -= sent;
503  if (sent > 0 || c->event_queue) {
504  crm_trace("Sent %d events (%d remaining) for %p[%d]: %s (%d)",
505  sent, queue_len, c->ipcs, c->pid, pcmk_strerror(rc < 0 ? rc : 0), rc);
506  }
507 
508  if (c->event_queue) {
509  if (queue_len % 100 == 0 && queue_len > 99) {
510  crm_warn("Event queue for %p[%d] has grown to %d", c->ipcs, c->pid, queue_len);
511 
512  } else if (queue_len > 500) {
513  crm_err("Evicting slow client %p[%d]: event queue reached %d entries",
514  c->ipcs, c->pid, queue_len);
515  qb_ipcs_disconnect(c->ipcs);
516  return rc;
517  }
518 
519  c->event_timer = g_timeout_add(1000 + 100 * queue_len, crm_ipcs_flush_events_cb, c);
520  }
521 
522  return rc;
523 }
524 
525 ssize_t
526 crm_ipc_prepare(uint32_t request, xmlNode * message, struct iovec ** result, uint32_t max_send_size)
527 {
528  static unsigned int biggest = 0;
529  struct iovec *iov;
530  unsigned int total = 0;
531  char *compressed = NULL;
532  char *buffer = dump_xml_unformatted(message);
533  struct crm_ipc_response_header *header = calloc(1, sizeof(struct crm_ipc_response_header));
534 
535  CRM_ASSERT(result != NULL);
536 
537  crm_ipc_init();
538 
539  if (max_send_size == 0) {
540  max_send_size = ipc_buffer_max;
541  }
542 
543  CRM_LOG_ASSERT(max_send_size != 0);
544 
545  *result = NULL;
546  iov = calloc(2, sizeof(struct iovec));
547 
548 
549  iov[0].iov_len = hdr_offset;
550  iov[0].iov_base = header;
551 
552  header->version = PCMK_IPC_VERSION;
553  header->size_uncompressed = 1 + strlen(buffer);
554  total = iov[0].iov_len + header->size_uncompressed;
555 
556  if (total < max_send_size) {
557  iov[1].iov_base = buffer;
558  iov[1].iov_len = header->size_uncompressed;
559 
560  } else {
561  unsigned int new_size = 0;
562 
564  (buffer, header->size_uncompressed, max_send_size, &compressed, &new_size)) {
565 
566  header->flags |= crm_ipc_compressed;
567  header->size_compressed = new_size;
568 
569  iov[1].iov_len = header->size_compressed;
570  iov[1].iov_base = compressed;
571 
572  free(buffer);
573 
574  biggest = QB_MAX(header->size_compressed, biggest);
575 
576  } else {
577  ssize_t rc = -EMSGSIZE;
578 
579  crm_log_xml_trace(message, "EMSGSIZE");
580  biggest = QB_MAX(header->size_uncompressed, biggest);
581 
582  crm_err
583  ("Could not compress the message (%u bytes) into less than the configured ipc limit (%u bytes). "
584  "Set PCMK_ipc_buffer to a higher value (%u bytes suggested)",
585  header->size_uncompressed, max_send_size, 4 * biggest);
586 
587  free(compressed);
588  free(buffer);
589  free(header);
590  free(iov);
591 
592  return rc;
593  }
594  }
595 
596  header->qb.size = iov[0].iov_len + iov[1].iov_len;
597  header->qb.id = (int32_t)request; /* Replying to a specific request */
598 
599  *result = iov;
600  CRM_ASSERT(header->qb.size > 0);
601  return header->qb.size;
602 }
603 
604 ssize_t
605 crm_ipcs_sendv(crm_client_t * c, struct iovec * iov, enum crm_ipc_flags flags)
606 {
607  ssize_t rc;
608  static uint32_t id = 1;
609  struct crm_ipc_response_header *header = iov[0].iov_base;
610 
612  /* _ALL_ replies to proxied connections need to be sent as events */
613  if (is_not_set(flags, crm_ipc_server_event)) {
614  flags |= crm_ipc_server_event;
615  /* this flag lets us know this was originally meant to be a response.
616  * even though we're sending it over the event channel. */
618  }
619  }
620 
621  header->flags |= flags;
622  if (flags & crm_ipc_server_event) {
623  header->qb.id = id++; /* We don't really use it, but doesn't hurt to set one */
624 
625  if (flags & crm_ipc_server_free) {
626  crm_trace("Sending the original to %p[%d]", c->ipcs, c->pid);
627  c->event_queue = g_list_append(c->event_queue, iov);
628 
629  } else {
630  struct iovec *iov_copy = calloc(2, sizeof(struct iovec));
631 
632  crm_trace("Sending a copy to %p[%d]", c->ipcs, c->pid);
633  iov_copy[0].iov_len = iov[0].iov_len;
634  iov_copy[0].iov_base = malloc(iov[0].iov_len);
635  memcpy(iov_copy[0].iov_base, iov[0].iov_base, iov[0].iov_len);
636 
637  iov_copy[1].iov_len = iov[1].iov_len;
638  iov_copy[1].iov_base = malloc(iov[1].iov_len);
639  memcpy(iov_copy[1].iov_base, iov[1].iov_base, iov[1].iov_len);
640 
641  c->event_queue = g_list_append(c->event_queue, iov_copy);
642  }
643 
644  } else {
645  CRM_LOG_ASSERT(header->qb.id != 0); /* Replying to a specific request */
646 
647  rc = qb_ipcs_response_sendv(c->ipcs, iov, 2);
648  if (rc < header->qb.size) {
649  crm_notice("Response %d to %p[%d] (%u bytes) failed: %s (%d)",
650  header->qb.id, c->ipcs, c->pid, header->qb.size, pcmk_strerror(rc), rc);
651 
652  } else {
653  crm_trace("Response %d sent, %d bytes to %p[%d]", header->qb.id, rc, c->ipcs, c->pid);
654  }
655 
656  if (flags & crm_ipc_server_free) {
657  free(iov[0].iov_base);
658  free(iov[1].iov_base);
659  free(iov);
660  }
661  }
662 
663  if (flags & crm_ipc_server_event) {
664  rc = crm_ipcs_flush_events(c);
665  } else {
667  }
668 
669  if (rc == -EPIPE || rc == -ENOTCONN) {
670  crm_trace("Client %p disconnected", c->ipcs);
671  }
672 
673  return rc;
674 }
675 
676 ssize_t
677 crm_ipcs_send(crm_client_t * c, uint32_t request, xmlNode * message,
678  enum crm_ipc_flags flags)
679 {
680  struct iovec *iov = NULL;
681  ssize_t rc = 0;
682 
683  if(c == NULL) {
684  return -EDESTADDRREQ;
685  }
686  crm_ipc_init();
687 
688  rc = crm_ipc_prepare(request, message, &iov, ipc_buffer_max);
689  if (rc > 0) {
690  rc = crm_ipcs_sendv(c, iov, flags | crm_ipc_server_free);
691 
692  } else {
693  free(iov);
694  crm_notice("Message to %p[%d] failed: %s (%d)",
695  c->ipcs, c->pid, pcmk_strerror(rc), rc);
696  }
697 
698  return rc;
699 }
700 
701 void
702 crm_ipcs_send_ack(crm_client_t * c, uint32_t request, uint32_t flags, const char *tag, const char *function,
703  int line)
704 {
705  if (flags & crm_ipc_client_response) {
706  xmlNode *ack = create_xml_node(NULL, tag);
707 
708  crm_trace("Ack'ing msg from %s (%p)", crm_client_name(c), c);
709  c->request_id = 0;
710  crm_xml_add(ack, "function", function);
711  crm_xml_add_int(ack, "line", line);
712  crm_ipcs_send(c, request, ack, flags);
713  free_xml(ack);
714  }
715 }
716 
717 /* Client... */
718 
719 #define MIN_MSG_SIZE 12336 /* sizeof(struct qb_ipc_connection_response) */
720 #define MAX_MSG_SIZE 128*1024 /* 128k default */
721 
722 struct crm_ipc_s {
723  struct pollfd pfd;
724 
725  /* the max size we can send/receive over ipc */
726  unsigned int max_buf_size;
727  /* Size of the allocated 'buffer' */
728  unsigned int buf_size;
729  int msg_size;
730  int need_reply;
731  char *buffer;
732  char *name;
733  uint32_t buffer_flags;
734 
735  qb_ipcc_connection_t *ipc;
736 
737 };
738 
739 static unsigned int
740 pick_ipc_buffer(unsigned int max)
741 {
742  static unsigned int global_max = 0;
743 
744  if(global_max == 0) {
745  const char *env = getenv("PCMK_ipc_buffer");
746 
747  if (env) {
748  int env_max = crm_parse_int(env, "0");
749 
750  global_max = (env_max > 0)? env_max : MAX_MSG_SIZE;
751 
752  } else {
753  global_max = MAX_MSG_SIZE;
754  }
755  }
756 
757  return QB_MAX(max, global_max);
758 }
759 
760 crm_ipc_t *
761 crm_ipc_new(const char *name, size_t max_size)
762 {
763  crm_ipc_t *client = NULL;
764 
765  client = calloc(1, sizeof(crm_ipc_t));
766 
767  client->name = strdup(name);
768  client->buf_size = pick_ipc_buffer(max_size);
769  client->buffer = malloc(client->buf_size);
770 
771  /* Clients initiating connection pick the max buf size */
772  client->max_buf_size = client->buf_size;
773 
774  client->pfd.fd = -1;
775  client->pfd.events = POLLIN;
776  client->pfd.revents = 0;
777 
778  return client;
779 }
780 
788 bool
790 {
791  client->need_reply = FALSE;
792  client->ipc = qb_ipcc_connect(client->name, client->buf_size);
793 
794  if (client->ipc == NULL) {
795  crm_debug("Could not establish %s connection: %s (%d)", client->name, pcmk_strerror(errno), errno);
796  return FALSE;
797  }
798 
799  client->pfd.fd = crm_ipc_get_fd(client);
800  if (client->pfd.fd < 0) {
801  crm_debug("Could not obtain file descriptor for %s connection: %s (%d)", client->name, pcmk_strerror(errno), errno);
802  return FALSE;
803  }
804 
805  qb_ipcc_context_set(client->ipc, client);
806 
807 #ifdef HAVE_IPCS_GET_BUFFER_SIZE
808  client->max_buf_size = qb_ipcc_get_buffer_size(client->ipc);
809  if (client->max_buf_size > client->buf_size) {
810  free(client->buffer);
811  client->buffer = calloc(1, client->max_buf_size);
812  client->buf_size = client->max_buf_size;
813  }
814 #endif
815 
816  return TRUE;
817 }
818 
819 void
821 {
822  if (client) {
823  crm_trace("Disconnecting %s IPC connection %p (%p.%p)", client->name, client, client->ipc);
824 
825  if (client->ipc) {
826  qb_ipcc_connection_t *ipc = client->ipc;
827 
828  client->ipc = NULL;
829  qb_ipcc_disconnect(ipc);
830  }
831  }
832 }
833 
834 void
836 {
837  if (client) {
838  if (client->ipc && qb_ipcc_is_connected(client->ipc)) {
839  crm_notice("Destroying an active IPC connection to %s", client->name);
840  /* The next line is basically unsafe
841  *
842  * If this connection was attached to mainloop and mainloop is active,
843  * the 'disconnected' callback will end up back here and we'll end
844  * up free'ing the memory twice - something that can still happen
845  * even without this if we destroy a connection and it closes before
846  * we call exit
847  */
848  /* crm_ipc_close(client); */
849  }
850  crm_trace("Destroying IPC connection to %s: %p", client->name, client);
851  free(client->buffer);
852  free(client->name);
853  free(client);
854  }
855 }
856 
857 int
859 {
860  int fd = 0;
861 
862  if (client && client->ipc && (qb_ipcc_fd_get(client->ipc, &fd) == 0)) {
863  return fd;
864  }
865  errno = EINVAL;
866  crm_perror(LOG_ERR, "Could not obtain file IPC descriptor for %s",
867  (client? client->name : "unspecified client"));
868  return -errno;
869 }
870 
871 bool
873 {
874  bool rc = FALSE;
875 
876  if (client == NULL) {
877  crm_trace("No client");
878  return FALSE;
879 
880  } else if (client->ipc == NULL) {
881  crm_trace("No connection");
882  return FALSE;
883 
884  } else if (client->pfd.fd < 0) {
885  crm_trace("Bad descriptor");
886  return FALSE;
887  }
888 
889  rc = qb_ipcc_is_connected(client->ipc);
890  if (rc == FALSE) {
891  client->pfd.fd = -EINVAL;
892  }
893  return rc;
894 }
895 
896 int
898 {
899  CRM_ASSERT(client != NULL);
900 
901  if (crm_ipc_connected(client) == FALSE) {
902  return -ENOTCONN;
903  }
904 
905  client->pfd.revents = 0;
906  return poll(&(client->pfd), 1, 0);
907 }
908 
909 static int
910 crm_ipc_decompress(crm_ipc_t * client)
911 {
912  struct crm_ipc_response_header *header = (struct crm_ipc_response_header *)(void*)client->buffer;
913 
914  if (header->size_compressed) {
915  int rc = 0;
916  unsigned int size_u = 1 + header->size_uncompressed;
917  /* never let buf size fall below our max size required for ipc reads. */
918  unsigned int new_buf_size = QB_MAX((hdr_offset + size_u), client->max_buf_size);
919  char *uncompressed = calloc(1, new_buf_size);
920 
921  crm_trace("Decompressing message data %u bytes into %u bytes",
922  header->size_compressed, size_u);
923 
924  rc = BZ2_bzBuffToBuffDecompress(uncompressed + hdr_offset, &size_u,
925  client->buffer + hdr_offset, header->size_compressed, 1, 0);
926 
927  if (rc != BZ_OK) {
928  crm_err("Decompression failed: %s (%d)", bz2_strerror(rc), rc);
929  free(uncompressed);
930  return -EILSEQ;
931  }
932 
933  /*
934  * This assert no longer holds true. For an identical msg, some clients may
935  * require compression, and others may not. If that same msg (event) is sent
936  * to multiple clients, it could result in some clients receiving a compressed
937  * msg even though compression was not explicitly required for them.
938  *
939  * CRM_ASSERT((header->size_uncompressed + hdr_offset) >= ipc_buffer_max);
940  */
941  CRM_ASSERT(size_u == header->size_uncompressed);
942 
943  memcpy(uncompressed, client->buffer, hdr_offset); /* Preserve the header */
944  header = (struct crm_ipc_response_header *)(void*)uncompressed;
945 
946  free(client->buffer);
947  client->buf_size = new_buf_size;
948  client->buffer = uncompressed;
949  }
950 
951  CRM_ASSERT(client->buffer[hdr_offset + header->size_uncompressed - 1] == 0);
952  return pcmk_ok;
953 }
954 
955 long
957 {
958  struct crm_ipc_response_header *header = NULL;
959 
960  CRM_ASSERT(client != NULL);
961  CRM_ASSERT(client->ipc != NULL);
962  CRM_ASSERT(client->buffer != NULL);
963 
964  crm_ipc_init();
965 
966  client->buffer[0] = 0;
967  client->msg_size = qb_ipcc_event_recv(client->ipc, client->buffer, client->buf_size - 1, 0);
968  if (client->msg_size >= 0) {
969  int rc = crm_ipc_decompress(client);
970 
971  if (rc != pcmk_ok) {
972  return rc;
973  }
974 
975  header = (struct crm_ipc_response_header *)(void*)client->buffer;
976  if(header->version > PCMK_IPC_VERSION) {
977  crm_err("Filtering incompatible v%d IPC message, we only support versions <= %d",
978  header->version, PCMK_IPC_VERSION);
979  return -EBADMSG;
980  }
981 
982  crm_trace("Received %s event %d, size=%u, rc=%d, text: %.100s",
983  client->name, header->qb.id, header->qb.size, client->msg_size,
984  client->buffer + hdr_offset);
985 
986  } else {
987  crm_trace("No message from %s received: %s", client->name, pcmk_strerror(client->msg_size));
988  }
989 
990  if (crm_ipc_connected(client) == FALSE || client->msg_size == -ENOTCONN) {
991  crm_err("Connection to %s failed", client->name);
992  }
993 
994  if (header) {
995  /* Data excluding the header */
996  return header->size_uncompressed;
997  }
998  return -ENOMSG;
999 }
1000 
1001 const char *
1003 {
1004  CRM_ASSERT(client != NULL);
1005  return client->buffer + sizeof(struct crm_ipc_response_header);
1006 }
1007 
1008 uint32_t
1010 {
1011  struct crm_ipc_response_header *header = NULL;
1012 
1013  CRM_ASSERT(client != NULL);
1014  if (client->buffer == NULL) {
1015  return 0;
1016  }
1017 
1018  header = (struct crm_ipc_response_header *)(void*)client->buffer;
1019  return header->flags;
1020 }
1021 
1022 const char *
1024 {
1025  CRM_ASSERT(client != NULL);
1026  return client->name;
1027 }
1028 
1029 static int
1030 internal_ipc_send_recv(crm_ipc_t * client, const void *iov)
1031 {
1032  int rc = 0;
1033 
1034  do {
1035  rc = qb_ipcc_sendv_recv(client->ipc, iov, 2, client->buffer, client->buf_size, -1);
1036  } while (rc == -EAGAIN && crm_ipc_connected(client));
1037 
1038  return rc;
1039 }
1040 
1041 static int
1042 internal_ipc_send_request(crm_ipc_t * client, const void *iov, int ms_timeout)
1043 {
1044  int rc = 0;
1045  time_t timeout = time(NULL) + 1 + (ms_timeout / 1000);
1046 
1047  do {
1048  rc = qb_ipcc_sendv(client->ipc, iov, 2);
1049  } while (rc == -EAGAIN && time(NULL) < timeout && crm_ipc_connected(client));
1050 
1051  return rc;
1052 }
1053 
1054 static int
1055 internal_ipc_get_reply(crm_ipc_t * client, int request_id, int ms_timeout)
1056 {
1057  time_t timeout = time(NULL) + 1 + (ms_timeout / 1000);
1058  int rc = 0;
1059 
1060  crm_ipc_init();
1061 
1062  /* get the reply */
1063  crm_trace("client %s waiting on reply to msg id %d", client->name, request_id);
1064  do {
1065 
1066  rc = qb_ipcc_recv(client->ipc, client->buffer, client->buf_size, 1000);
1067  if (rc > 0) {
1068  struct crm_ipc_response_header *hdr = NULL;
1069 
1070  int rc = crm_ipc_decompress(client);
1071 
1072  if (rc != pcmk_ok) {
1073  return rc;
1074  }
1075 
1076  hdr = (struct crm_ipc_response_header *)(void*)client->buffer;
1077  if (hdr->qb.id == request_id) {
1078  /* Got it */
1079  break;
1080  } else if (hdr->qb.id < request_id) {
1081  xmlNode *bad = string2xml(crm_ipc_buffer(client));
1082 
1083  crm_err("Discarding old reply %d (need %d)", hdr->qb.id, request_id);
1084  crm_log_xml_notice(bad, "OldIpcReply");
1085 
1086  } else {
1087  xmlNode *bad = string2xml(crm_ipc_buffer(client));
1088 
1089  crm_err("Discarding newer reply %d (need %d)", hdr->qb.id, request_id);
1090  crm_log_xml_notice(bad, "ImpossibleReply");
1091  CRM_ASSERT(hdr->qb.id <= request_id);
1092  }
1093  } else if (crm_ipc_connected(client) == FALSE) {
1094  crm_err("Server disconnected client %s while waiting for msg id %d", client->name,
1095  request_id);
1096  break;
1097  }
1098 
1099  } while (time(NULL) < timeout);
1100 
1101  return rc;
1102 }
1103 
1104 int
1105 crm_ipc_send(crm_ipc_t * client, xmlNode * message, enum crm_ipc_flags flags, int32_t ms_timeout,
1106  xmlNode ** reply)
1107 {
1108  long rc = 0;
1109  struct iovec *iov;
1110  static uint32_t id = 0;
1111  static int factor = 8;
1112  struct crm_ipc_response_header *header;
1113 
1114  crm_ipc_init();
1115 
1116  if (client == NULL) {
1117  crm_notice("Invalid connection");
1118  return -ENOTCONN;
1119 
1120  } else if (crm_ipc_connected(client) == FALSE) {
1121  /* Don't even bother */
1122  crm_notice("Connection to %s closed", client->name);
1123  return -ENOTCONN;
1124  }
1125 
1126  if (ms_timeout == 0) {
1127  ms_timeout = 5000;
1128  }
1129 
1130  if (client->need_reply) {
1131  crm_trace("Trying again to obtain pending reply from %s", client->name);
1132  rc = qb_ipcc_recv(client->ipc, client->buffer, client->buf_size, ms_timeout);
1133  if (rc < 0) {
1134  crm_warn("Sending to %s (%p) is disabled until pending reply is received", client->name,
1135  client->ipc);
1136  return -EALREADY;
1137 
1138  } else {
1139  crm_notice("Lost reply from %s (%p) finally arrived, sending re-enabled", client->name,
1140  client->ipc);
1141  client->need_reply = FALSE;
1142  }
1143  }
1144 
1145  id++;
1146  CRM_LOG_ASSERT(id != 0); /* Crude wrap-around detection */
1147  rc = crm_ipc_prepare(id, message, &iov, client->max_buf_size);
1148  if(rc < 0) {
1149  return rc;
1150  }
1151 
1152  header = iov[0].iov_base;
1153  header->flags |= flags;
1154 
1155  if(is_set(flags, crm_ipc_proxied)) {
1156  /* Don't look for a synchronous response */
1158  }
1159 
1160  if(header->size_compressed) {
1161  if(factor < 10 && (client->max_buf_size / 10) < (rc / factor)) {
1162  crm_notice("Compressed message exceeds %d0%% of the configured ipc limit (%u bytes), "
1163  "consider setting PCMK_ipc_buffer to %u or higher",
1164  factor, client->max_buf_size, 2 * client->max_buf_size);
1165  factor++;
1166  }
1167  }
1168 
1169  crm_trace("Sending from client: %s request id: %d bytes: %u timeout:%d msg...",
1170  client->name, header->qb.id, header->qb.size, ms_timeout);
1171 
1172  if (ms_timeout > 0 || is_not_set(flags, crm_ipc_client_response)) {
1173 
1174  rc = internal_ipc_send_request(client, iov, ms_timeout);
1175 
1176  if (rc <= 0) {
1177  crm_trace("Failed to send from client %s request %d with %u bytes...",
1178  client->name, header->qb.id, header->qb.size);
1179  goto send_cleanup;
1180 
1181  } else if (is_not_set(flags, crm_ipc_client_response)) {
1182  crm_trace("Message sent, not waiting for reply to %d from %s to %u bytes...",
1183  header->qb.id, client->name, header->qb.size);
1184 
1185  goto send_cleanup;
1186  }
1187 
1188  rc = internal_ipc_get_reply(client, header->qb.id, ms_timeout);
1189  if (rc < 0) {
1190  /* No reply, for now, disable sending
1191  *
1192  * The alternative is to close the connection since we don't know
1193  * how to detect and discard out-of-sequence replies
1194  *
1195  * TODO - implement the above
1196  */
1197  client->need_reply = TRUE;
1198  }
1199 
1200  } else {
1201  rc = internal_ipc_send_recv(client, iov);
1202  }
1203 
1204  if (rc > 0) {
1205  struct crm_ipc_response_header *hdr = (struct crm_ipc_response_header *)(void*)client->buffer;
1206 
1207  crm_trace("Received response %d, size=%u, rc=%ld, text: %.200s", hdr->qb.id, hdr->qb.size,
1208  rc, crm_ipc_buffer(client));
1209 
1210  if (reply) {
1211  *reply = string2xml(crm_ipc_buffer(client));
1212  }
1213 
1214  } else {
1215  crm_trace("Response not received: rc=%ld, errno=%d", rc, errno);
1216  }
1217 
1218  send_cleanup:
1219  if (crm_ipc_connected(client) == FALSE) {
1220  crm_notice("Connection to %s closed: %s (%ld)", client->name, pcmk_strerror(rc), rc);
1221 
1222  } else if (rc == -ETIMEDOUT) {
1223  crm_warn("Request %d to %s (%p) failed: %s (%ld) after %dms",
1224  header->qb.id, client->name, client->ipc, pcmk_strerror(rc), rc, ms_timeout);
1225  crm_write_blackbox(0, NULL);
1226 
1227  } else if (rc <= 0) {
1228  crm_warn("Request %d to %s (%p) failed: %s (%ld)",
1229  header->qb.id, client->name, client->ipc, pcmk_strerror(rc), rc);
1230  }
1231 
1232  free(header);
1233  free(iov[1].iov_base);
1234  free(iov);
1235  return rc;
1236 }
1237 
1238 /* Utils */
1239 
1240 xmlNode *
1241 create_hello_message(const char *uuid,
1242  const char *client_name, const char *major_version, const char *minor_version)
1243 {
1244  xmlNode *hello_node = NULL;
1245  xmlNode *hello = NULL;
1246 
1247  if (uuid == NULL || strlen(uuid) == 0
1248  || client_name == NULL || strlen(client_name) == 0
1249  || major_version == NULL || strlen(major_version) == 0
1250  || minor_version == NULL || strlen(minor_version) == 0) {
1251  crm_err("Missing fields, Hello message will not be valid.");
1252  return NULL;
1253  }
1254 
1255  hello_node = create_xml_node(NULL, XML_TAG_OPTIONS);
1256  crm_xml_add(hello_node, "major_version", major_version);
1257  crm_xml_add(hello_node, "minor_version", minor_version);
1258  crm_xml_add(hello_node, "client_name", client_name);
1259  crm_xml_add(hello_node, "client_uuid", uuid);
1260 
1261  crm_trace("creating hello message");
1262  hello = create_request(CRM_OP_HELLO, hello_node, NULL, NULL, client_name, uuid);
1263  free_xml(hello_node);
1264 
1265  return hello;
1266 }
#define F_CRM_TASK
Definition: msg_xml.h:56
const char * crm_ipc_buffer(crm_ipc_t *client)
Definition: ipc.c:1002
#define F_CRM_REFERENCE
Definition: msg_xml.h:62
void crm_write_blackbox(int nsig, struct qb_log_callsite *callsite)
Definition: logging.c:407
A dumping ground.
#define F_TYPE
Definition: msg_xml.h:34
void crm_ipc_close(crm_ipc_t *client)
Definition: ipc.c:820
#define crm_notice(fmt, args...)
Definition: logging.h:250
char * crm_generate_uuid(void)
Definition: utils.c:2314
uint32_t crm_ipc_buffer_flags(crm_ipc_t *client)
Definition: ipc.c:1009
int crm_ipc_send(crm_ipc_t *client, xmlNode *message, enum crm_ipc_flags flags, int32_t ms_timeout, xmlNode **reply)
Definition: ipc.c:1105
#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:1113
crm_client_t * crm_client_get(qb_ipcs_connection_t *c)
Definition: ipc.c:204
uint32_t flags
Definition: ipcs.h:79
qb_ipcs_connection_t * ipcs
Definition: ipcs.h:90
#define F_CRM_MSG_TYPE
Definition: msg_xml.h:58
uint32_t size
Definition: internal.h:52
int request_id
Definition: ipcs.h:78
#define CRM_FEATURE_SET
Definition: crm.h:38
#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:789
int crm_parse_int(const char *text, const char *default_text)
Definition: utils.c:643
#define PCMK_IPC_VERSION
Definition: ipc.c:38
struct crm_remote_s * remote
Definition: ipcs.h:92
int crm_user_lookup(const char *name, uid_t *uid, gid_t *gid)
Definition: utils.c:455
#define CRM_LOG_ASSERT(expr)
Definition: logging.h:150
void crm_client_destroy(crm_client_t *c)
Definition: ipc.c:337
int crm_ipc_get_fd(crm_ipc_t *client)
Definition: ipc.c:858
void crm_client_init(void)
Definition: ipc.c:249
#define clear_bit(word, bit)
Definition: crm_internal.h:199
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:526
char * user
Definition: ipcs.h:74
ssize_t crm_ipcs_flush_events(crm_client_t *c)
Definition: ipc.c:461
xmlNode * string2xml(const char *input)
Definition: xml.c:2957
char version[256]
Definition: plugin.c:84
#define MAX_MSG_SIZE
Definition: ipc.c:720
#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:605
#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:288
uint64_t flags
Definition: remote.c:121
#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:1023
GList * event_queue
Definition: ipcs.h:83
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:835
xmlNode * create_xml_node(xmlNode *parent, const char *name)
Definition: xml.c:2793
const char * crm_element_value(xmlNode *data, const char *name)
Definition: xml.c:5839
#define CRM_DAEMON_USER
Definition: config.h:47
gboolean add_message_xml(xmlNode *msg, const char *field, xmlNode *xml)
Definition: xml.c:3332
void free_xml(xmlNode *child)
Definition: xml.c:2848
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:702
xmlNode * crm_ipcs_recv(crm_client_t *c, void *data, size_t size, uint32_t *id, uint32_t *flags)
Definition: ipc.c:394
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:2695
const char * crm_xml_add_int(xmlNode *node, const char *name, int value)
Definition: xml.c:2783
ssize_t crm_ipcs_send(crm_client_t *c, uint32_t request, xmlNode *message, enum crm_ipc_flags flags)
Definition: ipc.c:677
uint pid
Definition: ipcs.h:67
int event_timer
Definition: ipcs.h:82
#define crm_perror(level, fmt, args...)
Log a system error message.
Definition: logging.h:226
bool crm_compress_string(const char *data, int length, int max, char **result, unsigned int *result_len)
Definition: utils.c:2358
xmlNode * create_hello_message(const char *uuid, const char *client_name, const char *major_version, const char *minor_version)
Definition: ipc.c:1241
#define CRM_OP_HELLO
Definition: crm.h:106
#define crm_err(fmt, args...)
Definition: logging.h:248
const char * bz2_strerror(int rc)
Definition: logging.c:1176
#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:3987
int crm_ipc_ready(crm_ipc_t *client)
Definition: ipc.c:897
#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:956
char * id
Definition: ipcs.h:72
#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:421
#define F_CRM_ORIGIN
Definition: msg_xml.h:64
int crm_ipcs_client_pid(qb_ipcs_connection_t *c)
Definition: ipc.c:384
#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:88
const char * crm_client_name(crm_client_t *c)
Definition: ipc.c:235
bool crm_ipc_connected(crm_ipc_t *client)
Definition: ipc.c:872
crm_ipc_t * crm_ipc_new(const char *name, size_t max_size)
Definition: ipc.c:761
char * name
Definition: ipcs.h:73
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
enum crm_ais_msg_types type
Definition: internal.h:51
#define int32_t
Definition: stdint.in.h:157