1CPG_INITIALIZE(3) Corosync Cluster Engine Programmer's ManualCPG_INITIALIZE(3)
2
3
4

NAME

6       cpg_initialize - Create a new connection to the CPG service
7

SYNOPSIS

9       #include <corosync/cpg.h>
10
11       int cpg_initialize(cpg_handle_t *handle, cpg_callbacks_t *callbacks);
12

DESCRIPTION

14       The  cpg_initialize  function is used to initialize a connection to the
15       closed  process  groups  API.   This   function   is   deprecated   and
16       cpg_model_initialize should be used in newly written code.
17
18       Each  application  may  have  several connections to the CPG API.  Each
19       application uses the handle argument to uniquely identify  the  connec‐
20       tion.   The  handle  argument  is  then used in other function calls to
21       identify the connection to be used for communication with the CPG  ser‐
22       vice.
23
24       Every  time  an  CPG  event  occurs within the joined group, one of the
25       callbacks specified by the argument callbacks is called.  The  callback
26       functions are described by the following type definitions:
27
28              typedef void (*cpg_deliver_fn_t) (
29                      cpg_handle_t handle,
30                      const struct cpg_name *group_name,
31                      uint32_t nodeid,
32                      uint32_t pid,
33                      const void *msg,
34                      size_t msg_len);
35
36
37              typedef void (*cpg_confchg_fn_t) (
38                      cpg_handle_t handle,
39                      const struct cpg_name *group_name,
40                      const struct cpg_address *member_list, size_t member_list_entries,
41                      const struct cpg_address *left_list, size_t left_list_entries,
42                      const struct cpg_address *joined_list, size_t joined_list_entries);
43
44
45       The callbacks argument is of the type:
46
47              typedef struct {
48                      cpg_deliver_fn_t cpg_deliver_fn;
49                      cpg_confchg_fn_t cpg_confchg_fn;
50              } cpg_callbacks_t;
51
52       When  a configuration change occurs or a message is to be delivered one
53       of the callbacks is called from the cpg_dispatch() function.  If a con‐
54       figuration change occurs, cpg_confchg_fn is called.  If a delivery of a
55       message occurs, cpg_deliver_fn is called.
56
57       The cpg_address structure is defined
58
59              struct cpg_address {
60                      unsigned int nodeid;
61                      unsigned int pid;
62                      unsigned int reason;
63              };
64
65       where nodeid is a 32 bit unique node identifier, pid is the process  ID
66       of  the process that has joined/left the group or sent the message, and
67       reason is an integer code indicating why the node joined/left the group
68       (this value is not set for the member_list items).
69
70              CPG_REASON_JOIN      - the process joined a group using cpg_join().
71              CPG_REASON_LEAVE     - the process left a group using cpg_leave()
72              CPG_REASON_NODEDOWN  - the process left a group because the node left the cluster.
73              CPG_REASON_NODEUP    - the process joined a group because it was already a member of a group on a node that has just joined the cluster
74              CPG_REASON_PROCDOWN  - the process left a group without calling cpg_leave()
75              CPG_REASON_UNDEFINED - a special value used for the member_list items
76

RETURN VALUE

78       This  call returns the CS_OK value if successful, otherwise an error is
79       returned.
80

ERRORS

82       The errors are undocumented.
83

SEE ALSO

85       cpg_overview(3),  cpg_initialize(3),  cpg_finalize(3),   cpg_fd_get(3),
86       cpg_dispatch(3),    cpg_join(3),   cpg_leave(3),   cpg_mcast_joined(3),
87       cpg_membership_get(3)         cpg_zcb_alloc(3)          cpg_zcb_free(3)
88       cpg_zcb_mcast_joined(3)      cpg_context_get(3)      cpg_context_set(3)
89       cpg_local_get(3) cpg_model_initialize(3)
90
91
92       CS_ERR_TRY_AGAIN Resource temporarily unavailable
93
94       CS_ERR_INVALID_PARAM Invalid argument
95
96       CS_ERR_ACCESS Permission denied
97
98       CS_ERR_LIBRARY The connection failed
99
100       CS_ERR_INTERRUPT System call interrupted by a signal
101
102       CS_ERR_NOT_SUPPORTED The requested protocol/functionality not supported
103
104       CS_ERR_MESSAGE_ERROR Incorrect auth message received
105
106       CS_ERR_NO_MEMORY Not enough memory to complete the requested task
107
108
109
110corosync Man Page                 2019-04-16                 CPG_INITIALIZE(3)
Impressum