corosync  3.1.5.15-9134
lib/cfg.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2002-2005 MontaVista Software, Inc.
3  * Copyright (c) 2006-2020 Red Hat, Inc.
4  *
5  * All rights reserved.
6  *
7  * Author: Steven Dake (sdake@redhat.com)
8  *
9  * This software licensed under BSD license, the text of which follows:
10  *
11  * Redistribution and use in source and binary forms, with or without
12  * modification, are permitted provided that the following conditions are met:
13  *
14  * - Redistributions of source code must retain the above copyright notice,
15  * this list of conditions and the following disclaimer.
16  * - Redistributions in binary form must reproduce the above copyright notice,
17  * this list of conditions and the following disclaimer in the documentation
18  * and/or other materials provided with the distribution.
19  * - Neither the name of the MontaVista Software, Inc. nor the names of its
20  * contributors may be used to endorse or promote products derived from this
21  * software without specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
27  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
33  * THE POSSIBILITY OF SUCH DAMAGE.
34  */
35 
36 #include <config.h>
37 
38 #include <stdio.h>
39 #include <string.h>
40 #include <stdlib.h>
41 #include <unistd.h>
42 #include <errno.h>
43 #include <pthread.h>
44 #include <limits.h>
45 #include <sys/types.h>
46 #include <sys/socket.h>
47 #include <sys/select.h>
48 #include <sys/un.h>
49 #include <sys/uio.h>
50 
51 #include <qb/qbipcc.h>
52 
53 #include <corosync/corotypes.h>
54 #include <corosync/corodefs.h>
55 #include <corosync/hdb.h>
56 
57 #include <corosync/cfg.h>
58 #include <corosync/ipc_cfg.h>
59 
60 #include "util.h"
61 
62 /*
63  * Data structure for instance data
64  */
65 struct cfg_inst {
66  qb_ipcc_connection_t *c;
70  int finalize;
71 };
72 
73 /*
74  * All instances in one database
75  */
76 static void cfg_inst_free (void *inst);
77 
78 DECLARE_HDB_DATABASE (cfg_hdb, cfg_inst_free);
79 
80 /*
81  * Implementation
82  */
83 
86  corosync_cfg_handle_t *cfg_handle,
87  const corosync_cfg_callbacks_t *cfg_callbacks)
88 {
89  struct cfg_inst *cfg_inst;
90  cs_error_t error = CS_OK;
91 
92  error = hdb_error_to_cs (hdb_handle_create (&cfg_hdb, sizeof (struct cfg_inst), cfg_handle));
93  if (error != CS_OK) {
94  goto error_no_destroy;
95  }
96 
97  error = hdb_error_to_cs (hdb_handle_get (&cfg_hdb, *cfg_handle, (void *)&cfg_inst));
98  if (error != CS_OK) {
99  goto error_destroy;
100  }
101 
102  cfg_inst->finalize = 0;
103  cfg_inst->c = qb_ipcc_connect ("cfg", IPC_REQUEST_SIZE);
104  if (cfg_inst->c == NULL) {
105  error = qb_to_cs_error(-errno);
106  goto error_put_destroy;
107  }
108 
109  if (cfg_callbacks) {
110  memcpy (&cfg_inst->callbacks, cfg_callbacks, sizeof (corosync_cfg_callbacks_t));
111  }
112 
113  (void)hdb_handle_put (&cfg_hdb, *cfg_handle);
114 
115  return (CS_OK);
116 
117 error_put_destroy:
118  (void)hdb_handle_put (&cfg_hdb, *cfg_handle);
119 error_destroy:
120  (void)hdb_handle_destroy (&cfg_hdb, *cfg_handle);
121 error_no_destroy:
122  return (error);
123 }
124 
127  corosync_cfg_handle_t cfg_handle,
128  int32_t *selection_fd)
129 {
130  struct cfg_inst *cfg_inst;
131  cs_error_t error;
132 
133  error = hdb_error_to_cs (hdb_handle_get (&cfg_hdb, cfg_handle, (void *)&cfg_inst));
134  if (error != CS_OK) {
135  return (error);
136  }
137 
138  error = qb_to_cs_error (qb_ipcc_fd_get (cfg_inst->c, selection_fd));
139 
140  (void)hdb_handle_put (&cfg_hdb, cfg_handle);
141  return (error);
142 }
143 
146  corosync_cfg_handle_t cfg_handle,
147  cs_dispatch_flags_t dispatch_flags)
148 {
149  int timeout = -1;
150  cs_error_t error;
151  int cont = 1; /* always continue do loop except when set to 0 */
152  struct cfg_inst *cfg_inst;
154  corosync_cfg_callbacks_t callbacks;
155  struct qb_ipc_response_header *dispatch_data;
156  char dispatch_buf[IPC_DISPATCH_SIZE];
157 
158  error = hdb_error_to_cs (hdb_handle_get (&cfg_hdb, cfg_handle,
159  (void *)&cfg_inst));
160  if (error != CS_OK) {
161  return (error);
162  }
163 
164  /*
165  * Timeout instantly for CS_DISPATCH_ONE_NONBLOCKING or CS_DISPATCH_ALL and
166  * wait indefinately for CS_DISPATCH_ONE or CS_DISPATCH_BLOCKING
167  */
168  if (dispatch_flags == CS_DISPATCH_ALL || dispatch_flags == CS_DISPATCH_ONE_NONBLOCKING) {
169  timeout = 0;
170  }
171 
172  dispatch_data = (struct qb_ipc_response_header *)dispatch_buf;
173  do {
174  error = qb_to_cs_error (qb_ipcc_event_recv (
175  cfg_inst->c,
176  dispatch_buf,
178  timeout));
179  if (error == CS_ERR_BAD_HANDLE) {
180  error = CS_OK;
181  goto error_put;
182  }
183  if (error == CS_ERR_TRY_AGAIN) {
184  if (dispatch_flags == CS_DISPATCH_ONE_NONBLOCKING) {
185  /*
186  * Don't mask error
187  */
188  goto error_put;
189  }
190  error = CS_OK;
191  if (dispatch_flags == CS_DISPATCH_ALL) {
192  break; /* exit do while cont is 1 loop */
193  } else {
194  continue; /* next poll */
195  }
196  }
197  if (error != CS_OK) {
198  goto error_put;
199  }
200 
201  /*
202  * Make copy of callbacks, message data, unlock instance, and call callback
203  * A risk of this dispatch method is that the callback routines may
204  * operate at the same time that cfgFinalize has been called in another thread.
205  */
206  memcpy (&callbacks, &cfg_inst->callbacks, sizeof (corosync_cfg_callbacks_t));
207 
208  /*
209  * Dispatch incoming response
210  */
211  switch (dispatch_data->id) {
213  if (callbacks.corosync_cfg_shutdown_callback == NULL) {
214  break;
215  }
216 
217  res_lib_cfg_testshutdown = (struct res_lib_cfg_testshutdown *)dispatch_data;
219  break;
220  default:
221  error = CS_ERR_LIBRARY;
222  goto error_nounlock;
223  break;
224  }
225  if (cfg_inst->finalize) {
226  /*
227  * If the finalize has been called then get out of the dispatch.
228  */
229  error = CS_ERR_BAD_HANDLE;
230  goto error_put;
231  }
232 
233  /*
234  * Determine if more messages should be processed
235  */
236  if (dispatch_flags == CS_DISPATCH_ONE || dispatch_flags == CS_DISPATCH_ONE_NONBLOCKING) {
237  cont = 0;
238  }
239  } while (cont);
240 
241 error_put:
242  (void)hdb_handle_put (&cfg_hdb, cfg_handle);
243 error_nounlock:
244  return (error);
245 }
246 
247 static void cfg_inst_free (void *inst)
248 {
249  struct cfg_inst *cfg_inst = (struct cfg_inst *)inst;
250  qb_ipcc_disconnect(cfg_inst->c);
251 }
252 
255  corosync_cfg_handle_t cfg_handle)
256 {
257  struct cfg_inst *cfg_inst;
258  cs_error_t error;
259 
260  error = hdb_error_to_cs(hdb_handle_get (&cfg_hdb, cfg_handle, (void *)&cfg_inst));
261  if (error != CS_OK) {
262  return (error);
263  }
264 
265  /*
266  * Another thread has already started finalizing
267  */
268  if (cfg_inst->finalize) {
269  (void)hdb_handle_put (&cfg_hdb, cfg_handle);
270  return (CS_ERR_BAD_HANDLE);
271  }
272 
273  cfg_inst->finalize = 1;
274 
275  (void)hdb_handle_destroy (&cfg_hdb, cfg_handle);
276 
277  (void)hdb_handle_put (&cfg_hdb, cfg_handle);
278 
279  return (error);
280 }
281 
284  corosync_cfg_handle_t cfg_handle,
285  char ***interface_names,
286  char ***status,
287  unsigned int *interface_count)
288 {
289  struct cfg_inst *cfg_inst;
292  unsigned int i, j;
293  cs_error_t error;
294  struct iovec iov;
295 
296  error = hdb_error_to_cs(hdb_handle_get (&cfg_hdb, cfg_handle, (void *)&cfg_inst));
297  if (error != CS_OK) {
298  return (error);
299  }
300 
301  req_lib_cfg_ringstatusget.header.size = sizeof (struct req_lib_cfg_ringstatusget);
303 
304  iov.iov_base = (void *)&req_lib_cfg_ringstatusget,
305  iov.iov_len = sizeof (struct req_lib_cfg_ringstatusget),
306 
307  error = qb_to_cs_error (qb_ipcc_sendv_recv(cfg_inst->c,
308  &iov,
309  1,
311  sizeof (struct res_lib_cfg_ringstatusget), CS_IPC_TIMEOUT_MS));
312 
313  if (error != CS_OK) {
314  goto exit_handle_put;
315  }
316 
317  *interface_count = res_lib_cfg_ringstatusget.interface_count;
318  *interface_names = malloc (sizeof (char *) * *interface_count);
319  if (*interface_names == NULL) {
320  return (CS_ERR_NO_MEMORY);
321  }
322  memset (*interface_names, 0, sizeof (char *) * *interface_count);
323 
324  *status = malloc (sizeof (char *) * *interface_count);
325  if (*status == NULL) {
326  error = CS_ERR_NO_MEMORY;
327  goto error_free_interface_names_array;
328  }
329  memset (*status, 0, sizeof (char *) * *interface_count);
330 
331  for (i = 0; i < res_lib_cfg_ringstatusget.interface_count; i++) {
332  (*(interface_names))[i] = strdup (res_lib_cfg_ringstatusget.interface_name[i]);
333  if ((*(interface_names))[i] == NULL) {
334  error = CS_ERR_NO_MEMORY;
335  goto error_free_interface_names;
336  }
337  }
338 
339  for (i = 0; i < res_lib_cfg_ringstatusget.interface_count; i++) {
340  (*(status))[i] = strdup (res_lib_cfg_ringstatusget.interface_status[i]);
341  if ((*(status))[i] == NULL) {
342  error = CS_ERR_NO_MEMORY;
343  goto error_free_status;
344  }
345  }
346  goto exit_handle_put;
347 
348 error_free_status:
349  for (j = 0; j < i; j++) {
350  free ((*(status))[j]);
351  }
352  i = *interface_count;
353 
354 error_free_interface_names:
355  for (j = 0; j < i; j++) {
356  free ((*(interface_names))[j]);
357  }
358 
359  free (*status);
360 
361 error_free_interface_names_array:
362  free (*interface_names);
363 
364 exit_handle_put:
365  (void)hdb_handle_put (&cfg_hdb, cfg_handle);
366 
367  return (error);
368 }
369 
372  corosync_cfg_handle_t cfg_handle,
373  unsigned int nodeid,
375  void *node_status)
376 {
377  struct cfg_inst *cfg_inst;
379  cs_error_t error;
380  struct iovec iov;
381  size_t cfg_node_status_size;
382  void *res_lib_cfg_nodestatuget_ptr;
385 
386  if (!node_status) {
387  return (CS_ERR_INVALID_PARAM);
388  }
389 
390  switch (version) {
391  case CFG_NODE_STATUS_V1:
392  cfg_node_status_size = sizeof(struct res_lib_cfg_nodestatusget_v1);
393  res_lib_cfg_nodestatuget_ptr = &res_lib_cfg_nodestatusget_v1;
394 
395  break;
396  default:
397  return (CS_ERR_INVALID_PARAM);
398  break;
399  }
400 
401  error = hdb_error_to_cs(hdb_handle_get (&cfg_hdb, cfg_handle, (void *)&cfg_inst));
402  if (error != CS_OK) {
403  return (error);
404  }
405 
406  req_lib_cfg_nodestatusget.header.size = sizeof (struct req_lib_cfg_nodestatusget);
410 
411  iov.iov_base = (void *)&req_lib_cfg_nodestatusget,
412  iov.iov_len = sizeof (struct req_lib_cfg_nodestatusget),
413 
414  error = qb_to_cs_error (qb_ipcc_sendv_recv(cfg_inst->c,
415  &iov,
416  1,
417  res_lib_cfg_nodestatuget_ptr,
418  cfg_node_status_size, CS_IPC_TIMEOUT_MS));
419  if (error != CS_OK) {
420  goto error_put;
421  }
422 
423  res_lib_cfg_nodestatusget_version = res_lib_cfg_nodestatuget_ptr;
424  error = res_lib_cfg_nodestatusget_version->header.error;
425  if (error != CS_OK) {
426  goto error_put;
427  }
428 
429  if (res_lib_cfg_nodestatusget_version->version != version) {
430  /*
431  * corosync sent us something we don't really understand.
432  */
433  error = CS_ERR_NOT_SUPPORTED;
434  goto error_put;
435  }
436 
437  switch (version) {
438  case CFG_NODE_STATUS_V1:
439  memcpy(node_status, &res_lib_cfg_nodestatusget_v1.node_status,
440  sizeof(struct corosync_cfg_node_status_v1));
441  break;
442  }
443 
444 error_put:
445  (void)hdb_handle_put (&cfg_hdb, cfg_handle);
446 
447  return (error);
448 }
449 
450 
453  corosync_cfg_handle_t cfg_handle,
454  uint8_t track_flags)
455 {
456  struct cfg_inst *cfg_inst;
459  cs_error_t error;
460  struct iovec iov;
461 
465 
466  error = hdb_error_to_cs(hdb_handle_get (&cfg_hdb, cfg_handle,
467  (void *)&cfg_inst));
468  if (error != CS_OK) {
469  return (error);
470  }
471 
472  iov.iov_base = (void *)&req_lib_cfg_trackstart,
473  iov.iov_len = sizeof (struct req_lib_cfg_trackstart),
474 
475  error = qb_to_cs_error (qb_ipcc_sendv_recv (cfg_inst->c,
476  &iov,
477  1,
479  sizeof (struct res_lib_cfg_trackstart), CS_IPC_TIMEOUT_MS));
480 
481  (void)hdb_handle_put (&cfg_hdb, cfg_handle);
482 
483  return (error == CS_OK ? res_lib_cfg_trackstart.header.error : error);
484 }
485 
488  corosync_cfg_handle_t cfg_handle)
489 {
490  struct cfg_inst *cfg_inst;
493  cs_error_t error;
494  struct iovec iov;
495 
496  error = hdb_error_to_cs (hdb_handle_get (&cfg_hdb, cfg_handle,
497  (void *)&cfg_inst));
498  if (error != CS_OK) {
499  return (error);
500  }
501 
502  req_lib_cfg_trackstop.header.size = sizeof (struct req_lib_cfg_trackstop);
504 
505  iov.iov_base = (void *)&req_lib_cfg_trackstop,
506  iov.iov_len = sizeof (struct req_lib_cfg_trackstop),
507 
508  error = qb_to_cs_error (qb_ipcc_sendv_recv (cfg_inst->c,
509  &iov,
510  1,
512  sizeof (struct res_lib_cfg_trackstop), CS_IPC_TIMEOUT_MS));
513 
514  (void)hdb_handle_put (&cfg_hdb, cfg_handle);
515 
516  return (error == CS_OK ? res_lib_cfg_trackstop.header.error : error);
517 }
518 
521  corosync_cfg_handle_t cfg_handle,
522  unsigned int nodeid,
523  const char *reason)
524 {
525  struct cfg_inst *cfg_inst;
528  cs_error_t error;
529  struct iovec iov;
530 
531  if (strlen(reason) >= CS_MAX_NAME_LENGTH)
532  return CS_ERR_NAME_TOO_LONG;
533 
534  error = hdb_error_to_cs (hdb_handle_get (&cfg_hdb, cfg_handle,
535  (void *)&cfg_inst));
536  if (error != CS_OK) {
537  return (error);
538  }
539 
541  req_lib_cfg_killnode.header.size = sizeof (struct req_lib_cfg_killnode);
542  req_lib_cfg_killnode.nodeid = nodeid;
543  strcpy((char *)req_lib_cfg_killnode.reason.value, reason);
544  req_lib_cfg_killnode.reason.length = strlen(reason)+1;
545 
546  iov.iov_base = (void *)&req_lib_cfg_killnode;
547  iov.iov_len = sizeof (struct req_lib_cfg_killnode);
548 
549  error = qb_to_cs_error (qb_ipcc_sendv_recv (cfg_inst->c,
550  &iov,
551  1,
553  sizeof (struct res_lib_cfg_killnode), CS_IPC_TIMEOUT_MS));
554 
555  error = res_lib_cfg_killnode.header.error;
556 
557  (void)hdb_handle_put (&cfg_hdb, cfg_handle);
558 
559  return (error == CS_OK ? res_lib_cfg_killnode.header.error : error);
560 }
561 
564  corosync_cfg_handle_t cfg_handle,
566 {
567  struct cfg_inst *cfg_inst;
570  cs_error_t error;
571  struct iovec iov;
572 
573  error = hdb_error_to_cs(hdb_handle_get (&cfg_hdb, cfg_handle,
574  (void *)&cfg_inst));
575  if (error != CS_OK) {
576  return (error);
577  }
578 
580  req_lib_cfg_tryshutdown.header.size = sizeof (struct req_lib_cfg_tryshutdown);
582 
583  iov.iov_base = (void *)&req_lib_cfg_tryshutdown;
584  iov.iov_len = sizeof (req_lib_cfg_tryshutdown);
585 
586  error = qb_to_cs_error (qb_ipcc_sendv_recv (cfg_inst->c,
587  &iov,
588  1,
590  sizeof (struct res_lib_cfg_tryshutdown), CS_IPC_TIMEOUT_MS));
591 
592  (void)hdb_handle_put (&cfg_hdb, cfg_handle);
593 
594  return (error == CS_OK ? res_lib_cfg_tryshutdown.header.error : error);
595 }
596 
599  corosync_cfg_handle_t cfg_handle,
601 {
602  struct cfg_inst *cfg_inst;
605  struct iovec iov;
606  cs_error_t error;
607 
608  error = hdb_error_to_cs(hdb_handle_get (&cfg_hdb, cfg_handle,
609  (void *)&cfg_inst));
610  if (error != CS_OK) {
611  return (error);
612  }
613 
615  req_lib_cfg_replytoshutdown.header.size = sizeof (struct req_lib_cfg_replytoshutdown);
617 
618  iov.iov_base = (void *)&req_lib_cfg_replytoshutdown;
619  iov.iov_len = sizeof (struct req_lib_cfg_replytoshutdown);
620 
621  error = qb_to_cs_error (qb_ipcc_sendv_recv (cfg_inst->c,
622  &iov,
623  1,
626 
627  return (error);
628 }
629 
631  corosync_cfg_handle_t cfg_handle,
632  unsigned int nodeid,
633  size_t max_addrs,
634  int *num_addrs,
636 {
637  cs_error_t error;
640  struct cfg_inst *cfg_inst;
641  int addrlen = 0;
642  int i;
643  struct iovec iov;
644  const char *addr_buf;
645  char response_buf[IPC_RESPONSE_SIZE];
646  char zeroes[sizeof(struct sockaddr_storage)];
647 
648  error = hdb_error_to_cs(hdb_handle_get (&cfg_hdb, cfg_handle,
649  (void *)&cfg_inst));
650  if (error != CS_OK) {
651  return (error);
652  }
653  memset(zeroes, 0, sizeof(zeroes));
654 
658 
659  iov.iov_base = (char *)&req_lib_cfg_get_node_addrs;
660  iov.iov_len = sizeof (req_lib_cfg_get_node_addrs);
661 
662  error = qb_to_cs_error (qb_ipcc_sendv_recv (
663  cfg_inst->c,
664  &iov, 1,
665  response_buf, IPC_RESPONSE_SIZE, CS_IPC_TIMEOUT_MS));
667 
668  if (error != CS_OK) {
669  goto error_put;
670  }
671 
672  if (res_lib_cfg_get_node_addrs->family == AF_INET)
673  addrlen = sizeof(struct sockaddr_in);
674  if (res_lib_cfg_get_node_addrs->family == AF_INET6)
675  addrlen = sizeof(struct sockaddr_in6);
676 
677  for (i = 0, addr_buf = (char *)res_lib_cfg_get_node_addrs->addrs;
678  i < max_addrs && i<res_lib_cfg_get_node_addrs->num_addrs;
679  i++, addr_buf += TOTEMIP_ADDRLEN) {
680  struct sockaddr_in *in;
681  struct sockaddr_in6 *in6;
682 
683  addrs[i].address_length = addrlen;
684 
685  if (res_lib_cfg_get_node_addrs->family == AF_INET) {
686  in = (struct sockaddr_in *)addrs[i].address;
687  if (memcmp(addr_buf, zeroes, addrlen) == 0) {
688  in->sin_family = 0;
689  } else {
690  in->sin_family = AF_INET;
691  }
692  memcpy(&in->sin_addr, addr_buf, sizeof(struct in_addr));
693  }
694  if (res_lib_cfg_get_node_addrs->family == AF_INET6) {
695  in6 = (struct sockaddr_in6 *)addrs[i].address;
696 
697  if (memcmp(addr_buf, zeroes, addrlen) == 0) {
698  in6->sin6_family = 0;
699  } else {
700  in6->sin6_family = AF_INET6;
701  }
702  memcpy(&in6->sin6_addr, addr_buf, sizeof(struct in6_addr));
703  }
704 
705  /* Mark it as unused */
706 
707  }
709  errno = error = res_lib_cfg_get_node_addrs->header.error;
710 
711 error_put:
712  hdb_handle_put (&cfg_hdb, cfg_handle);
713 
714  return (error);
715 }
716 
718  corosync_cfg_handle_t handle,
719  unsigned int *local_nodeid)
720 {
721  cs_error_t error;
722  struct cfg_inst *cfg_inst;
723  struct iovec iov;
726 
727  error = hdb_error_to_cs(hdb_handle_get (&cfg_hdb, handle, (void *)&cfg_inst));
728  if (error != CS_OK) {
729  return (error);
730  }
731 
732  req_lib_cfg_local_get.header.size = sizeof (struct qb_ipc_request_header);
734 
735  iov.iov_base = (void *)&req_lib_cfg_local_get;
736  iov.iov_len = sizeof (struct req_lib_cfg_local_get);
737 
738  error = qb_to_cs_error (qb_ipcc_sendv_recv (
739  cfg_inst->c,
740  &iov,
741  1,
743  sizeof (struct res_lib_cfg_local_get), CS_IPC_TIMEOUT_MS));
744 
745  if (error != CS_OK) {
746  goto error_exit;
747  }
748 
749  error = res_lib_cfg_local_get.header.error;
750 
751  *local_nodeid = res_lib_cfg_local_get.local_nodeid;
752 
753 error_exit:
754  (void)hdb_handle_put (&cfg_hdb, handle);
755 
756  return (error);
757 }
758 
760  corosync_cfg_handle_t handle)
761 {
762  cs_error_t error;
763  struct cfg_inst *cfg_inst;
764  struct iovec iov;
767 
768  error = hdb_error_to_cs(hdb_handle_get (&cfg_hdb, handle, (void *)&cfg_inst));
769  if (error != CS_OK) {
770  return (error);
771  }
772 
773  req_lib_cfg_reload_config.header.size = sizeof (struct qb_ipc_request_header);
775 
776  iov.iov_base = (void *)&req_lib_cfg_reload_config;
777  iov.iov_len = sizeof (struct req_lib_cfg_reload_config);
778 
779  error = qb_to_cs_error (qb_ipcc_sendv_recv (
780  cfg_inst->c,
781  &iov,
782  1,
784  sizeof (struct res_lib_cfg_reload_config), CS_IPC_TIMEOUT_MS));
785 
786  if (error != CS_OK) {
787  goto error_exit;
788  }
789 
790  error = res_lib_cfg_reload_config.header.error;
791 
792 error_exit:
793  (void)hdb_handle_put (&cfg_hdb, handle);
794 
795  return (error);
796 }
797 
799  corosync_cfg_handle_t handle)
800 {
801  cs_error_t error;
802  struct cfg_inst *cfg_inst;
803  struct iovec iov;
806 
807  error = hdb_error_to_cs(hdb_handle_get (&cfg_hdb, handle, (void *)&cfg_inst));
808  if (error != CS_OK) {
809  return (error);
810  }
811 
812  req_lib_cfg_reopen_log_files.header.size = sizeof (struct qb_ipc_request_header);
814 
815  iov.iov_base = (void *)&req_lib_cfg_reopen_log_files;
816  iov.iov_len = sizeof (struct req_lib_cfg_reopen_log_files);
817 
818  error = qb_to_cs_error (qb_ipcc_sendv_recv (
819  cfg_inst->c,
820  &iov,
821  1,
824 
825  if (error != CS_OK) {
826  goto error_exit;
827  }
828 
829  error = res_lib_cfg_reopen_log_files.header.error;
830 
831 error_exit:
832  (void)hdb_handle_put (&cfg_hdb, handle);
833 
834  return (error);
835 }
corosync_cfg_node_status_version_t
Definition: cfg.h:165
@ CFG_NODE_STATUS_V1
Definition: cfg.h:166
corosync_cfg_shutdown_reply_flags_t
enum corosync_cfg_shutdown_reply_flags_t
Definition: cfg.h:66
uint64_t corosync_cfg_handle_t
Definition: cfg.h:41
corosync_cfg_shutdown_flags_t
Shutdown types.
Definition: cfg.h:46
unsigned int nodeid
Definition: coroapi.h:0
#define TOTEMIP_ADDRLEN
Definition: coroapi.h:86
cs_dispatch_flags_t
The cs_dispatch_flags_t enum.
Definition: corotypes.h:84
@ CS_DISPATCH_ONE
Definition: corotypes.h:85
@ CS_DISPATCH_ONE_NONBLOCKING
Definition: corotypes.h:88
@ CS_DISPATCH_ALL
Definition: corotypes.h:86
cs_error_t qb_to_cs_error(int result)
qb_to_cs_error
#define CS_MAX_NAME_LENGTH
Definition: corotypes.h:55
cs_error_t
The cs_error_t enum.
Definition: corotypes.h:98
@ CS_ERR_NAME_TOO_LONG
Definition: corotypes.h:111
@ CS_ERR_NO_MEMORY
Definition: corotypes.h:106
@ CS_ERR_BAD_HANDLE
Definition: corotypes.h:107
@ CS_ERR_TRY_AGAIN
Definition: corotypes.h:104
@ CS_OK
Definition: corotypes.h:99
@ CS_ERR_INVALID_PARAM
Definition: corotypes.h:105
@ CS_ERR_LIBRARY
Definition: corotypes.h:100
@ CS_ERR_NOT_SUPPORTED
Definition: corotypes.h:117
#define CS_IPC_TIMEOUT_MS
Definition: corotypes.h:131
uint32_t flags
@ MESSAGE_REQ_CFG_RELOAD_CONFIG
Definition: ipc_cfg.h:61
@ MESSAGE_REQ_CFG_RINGSTATUSGET
Definition: ipc_cfg.h:54
@ MESSAGE_REQ_CFG_TRACKSTART
Definition: ipc_cfg.h:64
@ MESSAGE_REQ_CFG_TRACKSTOP
Definition: ipc_cfg.h:65
@ MESSAGE_REQ_CFG_NODESTATUSGET
Definition: ipc_cfg.h:63
@ MESSAGE_REQ_CFG_REOPEN_LOG_FILES
Definition: ipc_cfg.h:62
@ MESSAGE_REQ_CFG_TRYSHUTDOWN
Definition: ipc_cfg.h:57
@ MESSAGE_REQ_CFG_REPLYTOSHUTDOWN
Definition: ipc_cfg.h:58
@ MESSAGE_REQ_CFG_KILLNODE
Definition: ipc_cfg.h:56
@ MESSAGE_REQ_CFG_GET_NODE_ADDRS
Definition: ipc_cfg.h:59
@ MESSAGE_REQ_CFG_LOCAL_GET
Definition: ipc_cfg.h:60
@ MESSAGE_RES_CFG_TESTSHUTDOWN
Definition: ipc_cfg.h:82
cs_error_t corosync_cfg_trackstart(corosync_cfg_handle_t cfg_handle, uint8_t track_flags)
corosync_cfg_trackstart Track CFG for shutdown requests
Definition: lib/cfg.c:452
cs_error_t corosync_cfg_fd_get(corosync_cfg_handle_t cfg_handle, int32_t *selection_fd)
corosync_cfg_fd_get
Definition: lib/cfg.c:126
cs_error_t corosync_cfg_finalize(corosync_cfg_handle_t cfg_handle)
corosync_cfg_finalize
Definition: lib/cfg.c:254
cs_error_t corosync_cfg_ring_status_get(corosync_cfg_handle_t cfg_handle, char ***interface_names, char ***status, unsigned int *interface_count)
corosync_cfg_ring_status_get
Definition: lib/cfg.c:283
cs_error_t corosync_cfg_kill_node(corosync_cfg_handle_t cfg_handle, unsigned int nodeid, const char *reason)
corosync_cfg_kill_node
Definition: lib/cfg.c:520
cs_error_t corosync_cfg_replyto_shutdown(corosync_cfg_handle_t cfg_handle, corosync_cfg_shutdown_reply_flags_t response)
corosync_cfg_replyto_shutdown
Definition: lib/cfg.c:598
cs_error_t corosync_cfg_dispatch(corosync_cfg_handle_t cfg_handle, cs_dispatch_flags_t dispatch_flags)
corosync_cfg_dispatch
Definition: lib/cfg.c:145
cs_error_t corosync_cfg_trackstop(corosync_cfg_handle_t cfg_handle)
corosync_cfg_trackstop Stop tracking CFG for shutdown requests
Definition: lib/cfg.c:487
cs_error_t corosync_cfg_initialize(corosync_cfg_handle_t *cfg_handle, const corosync_cfg_callbacks_t *cfg_callbacks)
corosync_cfg_initialize
Definition: lib/cfg.c:85
cs_error_t corosync_cfg_reload_config(corosync_cfg_handle_t handle)
corosync_cfg_reload_config
Definition: lib/cfg.c:759
cs_error_t corosync_cfg_get_node_addrs(corosync_cfg_handle_t cfg_handle, unsigned int nodeid, size_t max_addrs, int *num_addrs, corosync_cfg_node_address_t *addrs)
corosync_cfg_get_node_addrs
Definition: lib/cfg.c:630
cs_error_t corosync_cfg_reopen_log_files(corosync_cfg_handle_t handle)
Reopen logging files.
Definition: lib/cfg.c:798
cs_error_t corosync_cfg_local_get(corosync_cfg_handle_t handle, unsigned int *local_nodeid)
corosync_cfg_local_get
Definition: lib/cfg.c:717
cs_error_t corosync_cfg_try_shutdown(corosync_cfg_handle_t cfg_handle, corosync_cfg_shutdown_flags_t flags)
corosync_cfg_try_shutdown
Definition: lib/cfg.c:563
cs_error_t corosync_cfg_node_status_get(corosync_cfg_handle_t cfg_handle, unsigned int nodeid, corosync_cfg_node_status_version_t version, void *node_status)
corosync_cfg_node_status_get
Definition: lib/cfg.c:371
DECLARE_HDB_DATABASE(cfg_hdb, cfg_inst_free)
#define IPC_REQUEST_SIZE
Definition: lib/util.h:49
cs_error_t hdb_error_to_cs(int res)
#define IPC_DISPATCH_SIZE
Definition: lib/util.h:51
#define IPC_RESPONSE_SIZE
Definition: lib/util.h:50
qb_ipcc_connection_t * c
Definition: lib/cfg.c:66
int comp_registered
Definition: lib/cfg.c:69
int finalize
Definition: lib/cfg.c:70
corosync_cfg_callbacks_t callbacks
Definition: lib/cfg.c:67
cs_name_t comp_name
Definition: lib/cfg.c:68
struct corosync_cfg_shutdown_callback_t
Definition: cfg.h:81
corosync_cfg_shutdown_callback_t corosync_cfg_shutdown_callback
Definition: cfg.h:82
A node address.
Definition: cfg.h:96
The cs_name_t struct.
Definition: corotypes.h:66
The req_lib_cfg_get_node_addrs struct.
Definition: ipc_cfg.h:201
The req_lib_cfg_killnode struct.
Definition: ipc_cfg.h:147
The req_lib_cfg_local_get struct.
Definition: ipc_cfg.h:220
The req_lib_cfg_nodestatusget struct.
Definition: ipc_cfg.h:111
The req_lib_cfg_reload_config struct.
Definition: ipc_cfg.h:235
The req_lib_cfg_reopen_log_files struct.
Definition: ipc_cfg.h:249
The req_lib_cfg_replytoshutdown struct.
Definition: ipc_cfg.h:178
The req_lib_cfg_ringstatusget struct.
Definition: ipc_cfg.h:94
struct qb_ipc_request_header header
Definition: ipc_cfg.h:261
struct qb_ipc_request_header header
Definition: ipc_cfg.h:270
The req_lib_cfg_tryshutdown struct.
Definition: ipc_cfg.h:163
unsigned int flags
Definition: ipc_cfg.h:165
The res_lib_cfg_get_node_addrs struct.
Definition: ipc_cfg.h:209
unsigned int num_addrs
Definition: ipc_cfg.h:212
The res_lib_cfg_killnode struct.
Definition: ipc_cfg.h:156
The res_lib_cfg_local_get struct.
Definition: ipc_cfg.h:227
The res_lib_cfg_nodestatusget struct.
Definition: ipc_cfg.h:125
The res_lib_cfg_reload_config struct.
Definition: ipc_cfg.h:242
The res_lib_cfg_reopen_log_files struct.
Definition: ipc_cfg.h:256
The res_lib_cfg_replytoshutdown struct.
Definition: ipc_cfg.h:186
The res_lib_cfg_ringstatusget struct.
Definition: ipc_cfg.h:101
The res_lib_cfg_testshutdown struct.
Definition: ipc_cfg.h:193
unsigned int flags
Definition: ipc_cfg.h:195
struct qb_ipc_response_header header
Definition: ipc_cfg.h:266
struct qb_ipc_response_header header
Definition: ipc_cfg.h:274
The res_lib_cfg_tryshutdown struct.
Definition: ipc_cfg.h:171
char version
Definition: totem.h:1