43 #include <sys/types.h> 44 #include <sys/socket.h> 48 #include <qb/qbipcc.h> 59 qb_ipcc_connection_t *
c;
65 static void quorum_inst_free (
void *inst);
72 uint32_t *quorum_type)
77 struct qb_ipc_request_header req;
80 error =
hdb_error_to_cs(hdb_handle_create (&quorum_handle_t_db,
sizeof (
struct quorum_inst), handle));
82 goto error_no_destroy;
85 error =
hdb_error_to_cs(hdb_handle_get (&quorum_handle_t_db, *handle, (
void *)&quorum_inst));
91 quorum_inst->finalize = 0;
93 if (quorum_inst->c == NULL) {
95 goto error_put_destroy;
98 req.size =
sizeof (req);
101 iov.iov_base = (
char *)&req;
102 iov.iov_len =
sizeof (req);
108 &res_lib_quorum_gettype,
109 sizeof (
struct res_lib_quorum_gettype), -1));
111 if (error !=
CS_OK) {
112 goto error_put_destroy;
115 error = res_lib_quorum_gettype.header.error;
120 memcpy(&quorum_inst->callbacks, callbacks, sizeof (*callbacks));
122 memset(&quorum_inst->callbacks, 0, sizeof (*callbacks));
124 (void)hdb_handle_put (&quorum_handle_t_db, *handle);
129 (void)hdb_handle_put (&quorum_handle_t_db, *handle);
131 (void)hdb_handle_destroy (&quorum_handle_t_db, *handle);
136 static void quorum_inst_free (
void *inst)
139 qb_ipcc_disconnect(quorum_inst->
c);
148 error =
hdb_error_to_cs(hdb_handle_get (&quorum_handle_t_db, handle, (
void *)&quorum_inst));
149 if (error !=
CS_OK) {
156 if (quorum_inst->finalize) {
157 (void)hdb_handle_put (&quorum_handle_t_db, handle);
161 quorum_inst->finalize = 1;
163 (void)hdb_handle_destroy (&quorum_handle_t_db, handle);
165 (void)hdb_handle_put (&quorum_handle_t_db, handle);
177 struct qb_ipc_request_header req;
180 error =
hdb_error_to_cs(hdb_handle_get (&quorum_handle_t_db, handle, (
void *)&quorum_inst));
181 if (error !=
CS_OK) {
185 req.size =
sizeof (req);
188 iov.iov_base = (
char *)&req;
189 iov.iov_len =
sizeof (req);
195 &res_lib_quorum_getquorate,
198 if (error !=
CS_OK) {
202 error = res_lib_quorum_getquorate.header.error;
204 *quorate = res_lib_quorum_getquorate.
quorate;
207 (void)hdb_handle_put (&quorum_handle_t_db, handle);
219 error =
hdb_error_to_cs(hdb_handle_get (&quorum_handle_t_db, handle, (
void *)&quorum_inst));
220 if (error !=
CS_OK) {
226 (void)hdb_handle_put (&quorum_handle_t_db, handle);
239 error =
hdb_error_to_cs(hdb_handle_get (&quorum_handle_t_db, handle, (
void *)&quorum_inst));
240 if (error !=
CS_OK) {
244 *context = quorum_inst->context;
246 (void)hdb_handle_put (&quorum_handle_t_db, handle);
258 error =
hdb_error_to_cs(hdb_handle_get (&quorum_handle_t_db, handle, (
void *)&quorum_inst));
259 if (error !=
CS_OK) {
263 quorum_inst->context =
context;
265 (void)hdb_handle_put (&quorum_handle_t_db, handle);
279 struct qb_ipc_response_header res;
281 error =
hdb_error_to_cs(hdb_handle_get (&quorum_handle_t_db, handle, (
void *)&quorum_inst));
282 if (error !=
CS_OK) {
286 req_lib_quorum_trackstart.header.size =
sizeof (
struct req_lib_quorum_trackstart);
290 iov.iov_base = (
char *)&req_lib_quorum_trackstart;
291 iov.iov_len =
sizeof (
struct req_lib_quorum_trackstart);
300 if (error !=
CS_OK) {
307 (void)hdb_handle_put (&quorum_handle_t_db, handle);
318 struct qb_ipc_request_header req;
319 struct qb_ipc_response_header res;
321 error =
hdb_error_to_cs(hdb_handle_get (&quorum_handle_t_db, handle, (
void *)&quorum_inst));
322 if (error !=
CS_OK) {
326 req.size =
sizeof (req);
329 iov.iov_base = (
char *)&req;
330 iov.iov_len =
sizeof (req);
339 if (error !=
CS_OK) {
346 (void)hdb_handle_put (&quorum_handle_t_db, handle);
360 struct qb_ipc_response_header *dispatch_data;
373 (
void *)&quorum_inst));
374 if (error !=
CS_OK) {
386 dispatch_data = (
struct qb_ipc_response_header *)dispatch_buf;
411 if (error !=
CS_OK) {
424 switch (dispatch_data->id) {
430 res_lib_quorum_notification = (
struct res_lib_quorum_notification *)dispatch_data;
433 res_lib_quorum_notification->quorate,
434 res_lib_quorum_notification->ring_seq,
435 res_lib_quorum_notification->view_list_entries,
444 if (quorum_inst->finalize) {
461 (void)hdb_handle_put (&quorum_handle_t_db, handle);
The res_lib_quorum_getquorate struct.
quorum_callbacks_t callbacks
cs_error_t hdb_error_to_cs(int res)
cs_error_t quorum_dispatch(quorum_handle_t handle, cs_dispatch_flags_t dispatch_types)
Dispatch messages and configuration changes.
The req_lib_quorum_trackstart struct.
The quorum_callbacks_t struct.
The res_lib_quorum_notification struct.
cs_error_t quorum_trackstop(quorum_handle_t handle)
quorum_trackstop
cs_error_t quorum_getquorate(quorum_handle_t handle, int *quorate)
Get quorum information.
cs_error_t quorum_context_get(quorum_handle_t handle, const void **context)
quorum_context_get
#define IPC_DISPATCH_SIZE
cs_error_t quorum_context_set(quorum_handle_t handle, const void *context)
quorum_context_set
cs_error_t
The cs_error_t enum.
cs_dispatch_flags_t
The cs_dispatch_flags_t enum.
uint64_t quorum_handle_t
quorum_handle_t
The res_lib_quorum_gettype struct.
cs_error_t quorum_fd_get(quorum_handle_t handle, int *fd)
Get a file descriptor on which to poll.
DECLARE_HDB_DATABASE(quorum_handle_t_db, quorum_inst_free)
quorum_notification_fn_t quorum_notify_fn
cs_error_t quorum_trackstart(quorum_handle_t handle, unsigned int flags)
Track node and quorum changes.
#define CS_IPC_TIMEOUT_MS
cs_error_t qb_to_cs_error(int result)
qb_to_cs_error
cs_error_t quorum_finalize(quorum_handle_t handle)
Close the quorum handle.
cs_error_t quorum_initialize(quorum_handle_t *handle, quorum_callbacks_t *callbacks, uint32_t *quorum_type)
Create a new quorum connection.