/** * test * @param handle The handle of pload initialize * @param callbacks The callbacks for pload_initialize * @returns PLOAD_OK */ unsigned int pload_initialize ( pload_handle_t *handle, pload_callbacks_t *callbacks) { cs_error_t error; struct pload_inst *pload_inst; error = hdb_error_to_cs(hdb_handle_create (&pload_handle_t_db, sizeof (struct pload_inst), handle)); if (error != CS_OK) { goto error_no_destroy; } error = hdb_error_to_cs(hdb_handle_get (&pload_handle_t_db, *handle, (void *)&pload_inst)); if (error != CS_OK) { goto error_destroy; } pload_inst->c = qb_ipcc_connect ("pload", IPC_REQUEST_SIZE); if (pload_inst->c == NULL) { error = qb_to_cs_error(-errno); goto error_put_destroy; } (void)hdb_handle_put (&pload_handle_t_db, *handle); return (CS_OK); error_put_destroy: (void)hdb_handle_put (&pload_handle_t_db, *handle); error_destroy: (void)hdb_handle_destroy (&pload_handle_t_db, *handle); error_no_destroy: return (error); }
/* * Function implementations */ cs_error_t cmap_initialize (cmap_handle_t *handle) { cs_error_t error; struct cmap_inst *cmap_inst; error = hdb_error_to_cs(hdb_handle_create(&cmap_handle_t_db, sizeof(*cmap_inst), handle)); if (error != CS_OK) { goto error_no_destroy; } error = hdb_error_to_cs(hdb_handle_get(&cmap_handle_t_db, *handle, (void *)&cmap_inst)); if (error != CS_OK) { goto error_destroy; } error = CS_OK; cmap_inst->finalize = 0; cmap_inst->c = qb_ipcc_connect("cmap", IPC_REQUEST_SIZE); if (cmap_inst->c == NULL) { error = qb_to_cs_error(-errno); goto error_put_destroy; } (void)hdb_handle_put(&cmap_handle_t_db, *handle); return (CS_OK); error_put_destroy: (void)hdb_handle_put(&cmap_handle_t_db, *handle); error_destroy: (void)hdb_handle_destroy(&cmap_handle_t_db, *handle); error_no_destroy: return (error); }
cs_error_t cmap_track_delete( cmap_handle_t handle, cmap_track_handle_t track_handle) { cs_error_t error; struct iovec iov; struct cmap_inst *cmap_inst; struct cmap_track_inst *cmap_track_inst; struct req_lib_cmap_track_delete req_lib_cmap_track_delete; struct res_lib_cmap_track_delete res_lib_cmap_track_delete; error = hdb_error_to_cs(hdb_handle_get (&cmap_handle_t_db, handle, (void *)&cmap_inst)); if (error != CS_OK) { return (error); } memset(&req_lib_cmap_track_delete, 0, sizeof(req_lib_cmap_track_delete)); req_lib_cmap_track_delete.header.size = sizeof(req_lib_cmap_track_delete); req_lib_cmap_track_delete.header.id = MESSAGE_REQ_CMAP_TRACK_DELETE; req_lib_cmap_track_delete.track_handle = track_handle; iov.iov_base = (char *)&req_lib_cmap_track_delete; iov.iov_len = sizeof(req_lib_cmap_track_delete); error = qb_to_cs_error(qb_ipcc_sendv_recv( cmap_inst->c, &iov, 1, &res_lib_cmap_track_delete, sizeof (struct res_lib_cmap_track_delete), CS_IPC_TIMEOUT_MS)); if (error == CS_OK) { error = res_lib_cmap_track_delete.header.error; } if (error == CS_OK) { error = hdb_error_to_cs(hdb_handle_get(&cmap_track_handle_t_db, res_lib_cmap_track_delete.track_inst_handle, (void *)&cmap_track_inst)); if (error != CS_OK) { goto error_put; } (void)hdb_handle_put(&cmap_track_handle_t_db, res_lib_cmap_track_delete.track_inst_handle); (void)hdb_handle_destroy(&cmap_track_handle_t_db, res_lib_cmap_track_delete.track_inst_handle); } error_put: (void)hdb_handle_put (&cmap_handle_t_db, handle); return (error); }
cs_error_t quorum_finalize ( quorum_handle_t handle) { struct quorum_inst *quorum_inst; cs_error_t error; error = hdb_error_to_cs(hdb_handle_get (&quorum_handle_t_db, handle, (void *)&quorum_inst)); if (error != CS_OK) { return (error); } /* * Another thread has already started finalizing */ if (quorum_inst->finalize) { (void)hdb_handle_put (&quorum_handle_t_db, handle); return (CS_ERR_BAD_HANDLE); } quorum_inst->finalize = 1; qb_ipcc_disconnect (quorum_inst->c); (void)hdb_handle_destroy (&quorum_handle_t_db, handle); (void)hdb_handle_put (&quorum_handle_t_db, handle); return (CS_OK); }
cs_error_t coroipcc_msg_send_reply_receive ( hdb_handle_t handle, const struct iovec *iov, unsigned int iov_len, void *res_msg, size_t res_len) { cs_error_t res; struct ipc_instance *ipc_instance; res = hdb_error_to_cs (hdb_handle_get (&ipc_hdb, handle, (void **)&ipc_instance)); if (res != CS_OK) { return (res); } pthread_mutex_lock (&ipc_instance->mutex); res = msg_send (ipc_instance, iov, iov_len); if (res != CS_OK) { goto error_exit; } res = reply_receive (ipc_instance, res_msg, res_len); error_exit: pthread_mutex_unlock (&ipc_instance->mutex); hdb_handle_put (&ipc_hdb, handle); return (res); }
cs_error_t cmap_finalize(cmap_handle_t handle) { struct cmap_inst *cmap_inst; cs_error_t error; hdb_handle_t track_inst_handle = 0; struct cmap_track_inst *cmap_track_inst; error = hdb_error_to_cs(hdb_handle_get(&cmap_handle_t_db, handle, (void *)&cmap_inst)); if (error != CS_OK) { return (error); } qb_ipcc_disconnect(cmap_inst->c); /* * Destroy all track instances for given connection */ hdb_iterator_reset(&cmap_track_handle_t_db); while (hdb_iterator_next(&cmap_track_handle_t_db, (void*)&cmap_track_inst, &track_inst_handle) == 0) { if (cmap_track_inst->c == cmap_inst->c) { (void)hdb_handle_destroy(&cmap_track_handle_t_db, track_inst_handle); } (void)hdb_handle_put (&cmap_track_handle_t_db, track_inst_handle); } (void)hdb_handle_destroy(&cmap_handle_t_db, handle); (void)hdb_handle_put(&cmap_handle_t_db, handle); return (CS_OK); }
evs_error_t evs_finalize ( evs_handle_t handle) { struct evs_inst *evs_inst; cs_error_t error; error = hdb_error_to_cs(hdb_handle_get (&evs_handle_t_db, handle, (void *)&evs_inst)); if (error != CS_OK) { return (error); } /* * Another thread has already started finalizing */ if (evs_inst->finalize) { hdb_handle_put (&evs_handle_t_db, handle); return (EVS_ERR_BAD_HANDLE); } evs_inst->finalize = 1; coroipcc_service_disconnect (evs_inst->handle); hdb_handle_destroy (&evs_handle_t_db, handle); hdb_handle_put (&evs_handle_t_db, handle); return (EVS_OK); }
unsigned int pload_finalize ( pload_handle_t handle) { struct pload_inst *pload_inst; cs_error_t error; error = hdb_error_to_cs (hdb_handle_get (&pload_handle_t_db, handle, (void *)&pload_inst)); if (error != CS_OK) { return (error); } /* * Another thread has already started finalizing */ if (pload_inst->finalize) { (void)hdb_handle_put (&pload_handle_t_db, handle); return (PLOAD_ERR_BAD_HANDLE); } pload_inst->finalize = 1; qb_ipcc_disconnect(pload_inst->c); (void)hdb_handle_destroy (&pload_handle_t_db, handle); (void)hdb_handle_put (&pload_handle_t_db, handle); return (PLOAD_OK); }
cs_error_t corosync_cfg_replyto_shutdown ( corosync_cfg_handle_t cfg_handle, corosync_cfg_shutdown_reply_flags_t response) { struct cfg_inst *cfg_inst; struct req_lib_cfg_replytoshutdown req_lib_cfg_replytoshutdown; struct res_lib_cfg_replytoshutdown res_lib_cfg_replytoshutdown; struct iovec iov; cs_error_t error; error = hdb_error_to_cs(hdb_handle_get (&cfg_hdb, cfg_handle, (void *)&cfg_inst)); if (error != CS_OK) { return (error); } req_lib_cfg_replytoshutdown.header.id = MESSAGE_REQ_CFG_REPLYTOSHUTDOWN; req_lib_cfg_replytoshutdown.header.size = sizeof (struct req_lib_cfg_replytoshutdown); req_lib_cfg_replytoshutdown.response = response; iov.iov_base = (void *)&req_lib_cfg_replytoshutdown; iov.iov_len = sizeof (struct req_lib_cfg_replytoshutdown); error = qb_to_cs_error (qb_ipcc_sendv_recv (cfg_inst->c, &iov, 1, &res_lib_cfg_replytoshutdown, sizeof (struct res_lib_cfg_replytoshutdown), CS_IPC_TIMEOUT_MS)); return (error); }
cs_error_t votequorum_finalize ( votequorum_handle_t handle) { struct votequorum_inst *votequorum_inst; cs_error_t error; error = hdb_error_to_cs(hdb_handle_get (&votequorum_handle_t_db, handle, (void *)&votequorum_inst)); if (error != CS_OK) { return (error); } /* * Another thread has already started finalizing */ if (votequorum_inst->finalize) { hdb_handle_put (&votequorum_handle_t_db, handle); return (CS_ERR_BAD_HANDLE); } votequorum_inst->finalize = 1; hdb_handle_destroy (&votequorum_handle_t_db, handle); hdb_handle_put (&votequorum_handle_t_db, handle); return (CS_OK); }
cs_error_t corosync_cfg_try_shutdown ( corosync_cfg_handle_t cfg_handle, corosync_cfg_shutdown_flags_t flags) { struct cfg_inst *cfg_inst; struct req_lib_cfg_tryshutdown req_lib_cfg_tryshutdown; struct res_lib_cfg_tryshutdown res_lib_cfg_tryshutdown; cs_error_t error; struct iovec iov; error = hdb_error_to_cs(hdb_handle_get (&cfg_hdb, cfg_handle, (void *)&cfg_inst)); if (error != CS_OK) { return (error); } req_lib_cfg_tryshutdown.header.id = MESSAGE_REQ_CFG_TRYSHUTDOWN; req_lib_cfg_tryshutdown.header.size = sizeof (struct req_lib_cfg_tryshutdown); req_lib_cfg_tryshutdown.flags = flags; iov.iov_base = (void *)&req_lib_cfg_tryshutdown; iov.iov_len = sizeof (req_lib_cfg_tryshutdown); error = qb_to_cs_error (qb_ipcc_sendv_recv (cfg_inst->c, &iov, 1, &res_lib_cfg_tryshutdown, sizeof (struct res_lib_cfg_tryshutdown), CS_IPC_TIMEOUT_MS)); (void)hdb_handle_put (&cfg_hdb, cfg_handle); return (error == CS_OK ? res_lib_cfg_tryshutdown.header.error : error); }
cs_error_t corosync_cfg_finalize ( corosync_cfg_handle_t cfg_handle) { struct cfg_inst *cfg_inst; cs_error_t error; error = hdb_error_to_cs(hdb_handle_get (&cfg_hdb, cfg_handle, (void *)&cfg_inst)); if (error != CS_OK) { return (error); } /* * Another thread has already started finalizing */ if (cfg_inst->finalize) { (void)hdb_handle_put (&cfg_hdb, cfg_handle); return (CS_ERR_BAD_HANDLE); } cfg_inst->finalize = 1; (void)hdb_handle_destroy (&cfg_hdb, cfg_handle); (void)hdb_handle_put (&cfg_hdb, cfg_handle); return (error); }
cs_error_t corosync_cfg_ring_reenable ( corosync_cfg_handle_t cfg_handle) { struct cfg_inst *cfg_inst; struct req_lib_cfg_ringreenable req_lib_cfg_ringreenable; struct res_lib_cfg_ringreenable res_lib_cfg_ringreenable; cs_error_t error; struct iovec iov; error = hdb_error_to_cs(hdb_handle_get (&cfg_hdb, cfg_handle, (void *)&cfg_inst)); if (error != CS_OK) { return (error); } req_lib_cfg_ringreenable.header.size = sizeof (struct req_lib_cfg_ringreenable); req_lib_cfg_ringreenable.header.id = MESSAGE_REQ_CFG_RINGREENABLE; iov.iov_base = (void *)&req_lib_cfg_ringreenable, iov.iov_len = sizeof (struct req_lib_cfg_ringreenable); error = qb_to_cs_error (qb_ipcc_sendv_recv (cfg_inst->c, &iov, 1, &res_lib_cfg_ringreenable, sizeof (struct res_lib_cfg_ringreenable), CS_IPC_TIMEOUT_MS)); (void)hdb_handle_put (&cfg_hdb, cfg_handle); return (error); }
cs_error_t cmap_iter_next( cmap_handle_t handle, cmap_iter_handle_t iter_handle, char key_name[], size_t *value_len, cmap_value_types_t *type) { cs_error_t error; struct iovec iov; struct cmap_inst *cmap_inst; struct req_lib_cmap_iter_next req_lib_cmap_iter_next; struct res_lib_cmap_iter_next res_lib_cmap_iter_next; if (key_name == NULL) { return (CS_ERR_INVALID_PARAM); } error = hdb_error_to_cs(hdb_handle_get (&cmap_handle_t_db, handle, (void *)&cmap_inst)); if (error != CS_OK) { return (error); } memset(&req_lib_cmap_iter_next, 0, sizeof(req_lib_cmap_iter_next)); req_lib_cmap_iter_next.header.size = sizeof(req_lib_cmap_iter_next); req_lib_cmap_iter_next.header.id = MESSAGE_REQ_CMAP_ITER_NEXT; req_lib_cmap_iter_next.iter_handle = iter_handle; iov.iov_base = (char *)&req_lib_cmap_iter_next; iov.iov_len = sizeof(req_lib_cmap_iter_next); error = qb_to_cs_error(qb_ipcc_sendv_recv( cmap_inst->c, &iov, 1, &res_lib_cmap_iter_next, sizeof (struct res_lib_cmap_iter_next), CS_IPC_TIMEOUT_MS)); if (error == CS_OK) { error = res_lib_cmap_iter_next.header.error; } if (error == CS_OK) { strncpy(key_name, (const char *)res_lib_cmap_iter_next.key_name.value, CMAP_KEYNAME_MAXLEN); if (value_len != NULL) { *value_len = res_lib_cmap_iter_next.value_len; } if (type != NULL) { *type = res_lib_cmap_iter_next.type; } } (void)hdb_handle_put (&cmap_handle_t_db, handle); return (error); }
cs_error_t cmap_set ( cmap_handle_t handle, const char *key_name, const void *value, size_t value_len, cmap_value_types_t type) { cs_error_t error; struct iovec iov[2]; struct cmap_inst *cmap_inst; struct req_lib_cmap_set req_lib_cmap_set; struct res_lib_cmap_set res_lib_cmap_set; if (key_name == NULL || value == NULL) { return (CS_ERR_INVALID_PARAM); } if (strlen(key_name) >= CS_MAX_NAME_LENGTH) { return (CS_ERR_NAME_TOO_LONG); } error = hdb_error_to_cs(hdb_handle_get (&cmap_handle_t_db, handle, (void *)&cmap_inst)); if (error != CS_OK) { return (error); } memset(&req_lib_cmap_set, 0, sizeof(req_lib_cmap_set)); req_lib_cmap_set.header.size = sizeof(req_lib_cmap_set) + value_len; req_lib_cmap_set.header.id = MESSAGE_REQ_CMAP_SET; memcpy(req_lib_cmap_set.key_name.value, key_name, strlen(key_name)); req_lib_cmap_set.key_name.length = strlen(key_name); req_lib_cmap_set.value_len = value_len; req_lib_cmap_set.type = type; iov[0].iov_base = (char *)&req_lib_cmap_set; iov[0].iov_len = sizeof(req_lib_cmap_set); iov[1].iov_base = (void *)value; iov[1].iov_len = value_len; error = qb_to_cs_error(qb_ipcc_sendv_recv( cmap_inst->c, iov, 2, &res_lib_cmap_set, sizeof (struct res_lib_cmap_set), CS_IPC_TIMEOUT_MS)); if (error == CS_OK) { error = res_lib_cmap_set.header.error; } (void)hdb_handle_put (&cmap_handle_t_db, handle); return (error); }
/** * test * @param handle The handle of evs initialize * @param callbacks The callbacks for evs_initialize * @returns EVS_OK */ evs_error_t evs_initialize ( evs_handle_t *handle, evs_callbacks_t *callbacks) { cs_error_t error; struct evs_inst *evs_inst; error = hdb_error_to_cs(hdb_handle_create (&evs_handle_t_db, sizeof (struct evs_inst), handle)); if (error != CS_OK) { goto error_no_destroy; } error = hdb_error_to_cs(hdb_handle_get (&evs_handle_t_db, *handle, (void *)&evs_inst)); if (error != CS_OK) { goto error_destroy; } error = coroipcc_service_connect ( COROSYNC_SOCKET_NAME, EVS_SERVICE, IPC_REQUEST_SIZE, IPC_RESPONSE_SIZE, IPC_DISPATCH_SIZE, &evs_inst->handle); if (error != EVS_OK) { goto error_put_destroy; } if (callbacks) { memcpy (&evs_inst->callbacks, callbacks, sizeof (evs_callbacks_t)); } hdb_handle_put (&evs_handle_t_db, *handle); return (CS_OK); error_put_destroy: hdb_handle_put (&evs_handle_t_db, *handle); error_destroy: hdb_handle_destroy (&evs_handle_t_db, *handle); error_no_destroy: return (error); }
cs_error_t cmap_iter_init( cmap_handle_t handle, const char *prefix, cmap_iter_handle_t *cmap_iter_handle) { cs_error_t error; struct iovec iov; struct cmap_inst *cmap_inst; struct req_lib_cmap_iter_init req_lib_cmap_iter_init; struct res_lib_cmap_iter_init res_lib_cmap_iter_init; if (cmap_iter_handle == NULL) { return (CS_ERR_INVALID_PARAM); } error = hdb_error_to_cs(hdb_handle_get (&cmap_handle_t_db, handle, (void *)&cmap_inst)); if (error != CS_OK) { return (error); } memset(&req_lib_cmap_iter_init, 0, sizeof(req_lib_cmap_iter_init)); req_lib_cmap_iter_init.header.size = sizeof(req_lib_cmap_iter_init); req_lib_cmap_iter_init.header.id = MESSAGE_REQ_CMAP_ITER_INIT; if (prefix) { if (strlen(prefix) >= CS_MAX_NAME_LENGTH) { return (CS_ERR_NAME_TOO_LONG); } memcpy(req_lib_cmap_iter_init.prefix.value, prefix, strlen(prefix)); req_lib_cmap_iter_init.prefix.length = strlen(prefix); } iov.iov_base = (char *)&req_lib_cmap_iter_init; iov.iov_len = sizeof(req_lib_cmap_iter_init); error = qb_to_cs_error(qb_ipcc_sendv_recv( cmap_inst->c, &iov, 1, &res_lib_cmap_iter_init, sizeof (struct res_lib_cmap_iter_init), CS_IPC_TIMEOUT_MS)); if (error == CS_OK) { error = res_lib_cmap_iter_init.header.error; } if (error == CS_OK) { *cmap_iter_handle = res_lib_cmap_iter_init.iter_handle; } (void)hdb_handle_put (&cmap_handle_t_db, handle); return (error); }
cs_error_t votequorum_getinfo ( votequorum_handle_t handle, unsigned int nodeid, struct votequorum_info *info) { cs_error_t error; struct votequorum_inst *votequorum_inst; struct iovec iov; struct req_lib_votequorum_getinfo req_lib_votequorum_getinfo; struct res_lib_votequorum_getinfo res_lib_votequorum_getinfo; error = hdb_error_to_cs(hdb_handle_get (&votequorum_handle_t_db, handle, (void *)&votequorum_inst)); if (error != CS_OK) { return (error); } req_lib_votequorum_getinfo.header.size = sizeof (struct req_lib_votequorum_getinfo); req_lib_votequorum_getinfo.header.id = MESSAGE_REQ_VOTEQUORUM_GETINFO; req_lib_votequorum_getinfo.nodeid = nodeid; iov.iov_base = (char *)&req_lib_votequorum_getinfo; iov.iov_len = sizeof (struct req_lib_votequorum_getinfo); error = qb_to_cs_error(qb_ipcc_sendv_recv ( votequorum_inst->c, &iov, 1, &res_lib_votequorum_getinfo, sizeof (struct res_lib_votequorum_getinfo), CS_IPC_TIMEOUT_MS)); if (error != CS_OK) { goto error_exit; } error = res_lib_votequorum_getinfo.header.error; info->node_id = res_lib_votequorum_getinfo.nodeid; info->node_state = res_lib_votequorum_getinfo.state; info->node_votes = res_lib_votequorum_getinfo.votes; info->node_expected_votes = res_lib_votequorum_getinfo.expected_votes; info->highest_expected = res_lib_votequorum_getinfo.highest_expected; info->total_votes = res_lib_votequorum_getinfo.total_votes; info->quorum = res_lib_votequorum_getinfo.quorum; info->flags = res_lib_votequorum_getinfo.flags; info->qdevice_votes = res_lib_votequorum_getinfo.qdevice_votes; memset(info->qdevice_name, 0, VOTEQUORUM_QDEVICE_MAX_NAME_LEN); strcpy(info->qdevice_name, res_lib_votequorum_getinfo.qdevice_name); error_exit: hdb_handle_put (&votequorum_handle_t_db, handle); return (error); }
evs_error_t evs_membership_get ( evs_handle_t handle, unsigned int *local_nodeid, unsigned int *member_list, size_t *member_list_entries) { evs_error_t error; struct evs_inst *evs_inst; struct iovec iov; struct req_lib_evs_membership_get req_lib_evs_membership_get; struct res_lib_evs_membership_get res_lib_evs_membership_get; error = hdb_error_to_cs(hdb_handle_get (&evs_handle_t_db, handle, (void *)&evs_inst)); if (error != CS_OK) { return (error); } req_lib_evs_membership_get.header.size = sizeof (struct req_lib_evs_membership_get); req_lib_evs_membership_get.header.id = MESSAGE_REQ_EVS_MEMBERSHIP_GET; iov.iov_base = (void *)&req_lib_evs_membership_get; iov.iov_len = sizeof (struct req_lib_evs_membership_get); error = coroipcc_msg_send_reply_receive (evs_inst->handle, &iov, 1, &res_lib_evs_membership_get, sizeof (struct res_lib_evs_membership_get)); if (error != CS_OK) { goto error_exit; } error = res_lib_evs_membership_get.header.error; /* * Copy results to caller */ if (local_nodeid) { *local_nodeid = res_lib_evs_membership_get.local_nodeid; } *member_list_entries = MIN (*member_list_entries, res_lib_evs_membership_get.member_list_entries); if (member_list) { memcpy (member_list, &res_lib_evs_membership_get.member_list, *member_list_entries * sizeof (struct in_addr)); } error_exit: hdb_handle_put (&evs_handle_t_db, handle); return (error); }
cs_error_t votequorum_initialize ( votequorum_handle_t *handle, votequorum_callbacks_t *callbacks) { cs_error_t error; struct votequorum_inst *votequorum_inst; error = hdb_error_to_cs(hdb_handle_create (&votequorum_handle_t_db, sizeof (struct votequorum_inst), handle)); if (error != CS_OK) { goto error_no_destroy; } error = hdb_error_to_cs(hdb_handle_get (&votequorum_handle_t_db, *handle, (void *)&votequorum_inst)); if (error != CS_OK) { goto error_destroy; } votequorum_inst->finalize = 0; votequorum_inst->c = qb_ipcc_connect ("votequorum", IPC_REQUEST_SIZE); if (votequorum_inst->c == NULL) { error = qb_to_cs_error(-errno); goto error_put_destroy; } if (callbacks) memcpy(&votequorum_inst->callbacks, callbacks, sizeof (*callbacks)); else memset(&votequorum_inst->callbacks, 0, sizeof (*callbacks)); hdb_handle_put (&votequorum_handle_t_db, *handle); return (CS_OK); error_put_destroy: hdb_handle_put (&votequorum_handle_t_db, *handle); error_destroy: hdb_handle_destroy (&votequorum_handle_t_db, *handle); error_no_destroy: return (error); }
cs_error_t corosync_cfg_initialize ( corosync_cfg_handle_t *cfg_handle, const corosync_cfg_callbacks_t *cfg_callbacks) { struct cfg_inst *cfg_inst; cs_error_t error = CS_OK; error = hdb_error_to_cs (hdb_handle_create (&cfg_hdb, sizeof (struct cfg_inst), cfg_handle)); if (error != CS_OK) { goto error_no_destroy; } error = hdb_error_to_cs (hdb_handle_get (&cfg_hdb, *cfg_handle, (void *)&cfg_inst)); if (error != CS_OK) { goto error_destroy; } cfg_inst->finalize = 0; cfg_inst->c = qb_ipcc_connect ("cfg", IPC_REQUEST_SIZE); if (cfg_inst->c == NULL) { error = qb_to_cs_error(-errno); goto error_put_destroy; } if (cfg_callbacks) { memcpy (&cfg_inst->callbacks, cfg_callbacks, sizeof (corosync_cfg_callbacks_t)); } (void)hdb_handle_put (&cfg_hdb, *cfg_handle); return (CS_OK); error_put_destroy: (void)hdb_handle_put (&cfg_hdb, *cfg_handle); error_destroy: (void)hdb_handle_destroy (&cfg_hdb, *cfg_handle); error_no_destroy: return (error); }
evs_error_t evs_mcast_groups ( evs_handle_t handle, evs_guarantee_t guarantee, const struct evs_group *groups, size_t group_entries, const struct iovec *iovec, unsigned int iov_len) { int i; evs_error_t error; struct evs_inst *evs_inst; struct iovec iov[64]; /* FIXME: what if iov_len > 62 ? use malloc */ struct req_lib_evs_mcast_groups req_lib_evs_mcast_groups; struct res_lib_evs_mcast_groups res_lib_evs_mcast_groups; size_t msg_len = 0; error = hdb_error_to_cs(hdb_handle_get (&evs_handle_t_db, handle, (void *)&evs_inst)); if (error != CS_OK) { return (error); } for (i = 0; i < iov_len; i++) { msg_len += iovec[i].iov_len; } req_lib_evs_mcast_groups.header.size = sizeof (struct req_lib_evs_mcast_groups) + (group_entries * sizeof (struct evs_group)) + msg_len; req_lib_evs_mcast_groups.header.id = MESSAGE_REQ_EVS_MCAST_GROUPS; req_lib_evs_mcast_groups.guarantee = guarantee; req_lib_evs_mcast_groups.msg_len = msg_len; req_lib_evs_mcast_groups.group_entries = group_entries; iov[0].iov_base = (void *)&req_lib_evs_mcast_groups; iov[0].iov_len = sizeof (struct req_lib_evs_mcast_groups); iov[1].iov_base = (void *) groups; /* cast away const */ iov[1].iov_len = (group_entries * sizeof (struct evs_group)); memcpy (&iov[2], iovec, iov_len * sizeof (struct iovec)); error = coroipcc_msg_send_reply_receive (evs_inst->handle, iov, iov_len + 2, &res_lib_evs_mcast_groups, sizeof (struct res_lib_evs_mcast_groups)); if (error != CS_OK) { goto error_exit; } error = res_lib_evs_mcast_groups.header.error; error_exit: hdb_handle_put (&evs_handle_t_db, handle); return (error); }
evs_error_t evs_mcast_joined ( evs_handle_t handle, evs_guarantee_t guarantee, const struct iovec *iovec, unsigned int iov_len) { int i; evs_error_t error; struct evs_inst *evs_inst; struct iovec iov[64]; struct req_lib_evs_mcast_joined req_lib_evs_mcast_joined; struct res_lib_evs_mcast_joined res_lib_evs_mcast_joined; size_t msg_len = 0; error = hdb_error_to_cs(hdb_handle_get (&evs_handle_t_db, handle, (void *)&evs_inst)); if (error != CS_OK) { return (error); } for (i = 0; i < iov_len; i++ ) { msg_len += iovec[i].iov_len; } req_lib_evs_mcast_joined.header.size = sizeof (struct req_lib_evs_mcast_joined) + msg_len; req_lib_evs_mcast_joined.header.id = MESSAGE_REQ_EVS_MCAST_JOINED; req_lib_evs_mcast_joined.guarantee = guarantee; req_lib_evs_mcast_joined.msg_len = msg_len; iov[0].iov_base = (void *)&req_lib_evs_mcast_joined; iov[0].iov_len = sizeof (struct req_lib_evs_mcast_joined); memcpy (&iov[1], iovec, iov_len * sizeof (struct iovec)); error = coroipcc_msg_send_reply_receive (evs_inst->handle, iov, iov_len + 1, &res_lib_evs_mcast_joined, sizeof (struct res_lib_evs_mcast_joined)); if (error != CS_OK) { goto error_exit; } error = res_lib_evs_mcast_joined.header.error; error_exit: hdb_handle_put (&evs_handle_t_db, handle); return (error); }
cs_error_t votequorum_qdevice_poll ( votequorum_handle_t handle, const char *name, unsigned int cast_vote, votequorum_ring_id_t ring_id) { cs_error_t error; struct votequorum_inst *votequorum_inst; struct iovec iov; struct req_lib_votequorum_qdevice_poll req_lib_votequorum_qdevice_poll; struct res_lib_votequorum_status res_lib_votequorum_status; if ((strlen(name) == 0) || (strlen(name) >= VOTEQUORUM_QDEVICE_MAX_NAME_LEN)) { return CS_ERR_INVALID_PARAM; } error = hdb_error_to_cs(hdb_handle_get (&votequorum_handle_t_db, handle, (void *)&votequorum_inst)); if (error != CS_OK) { return (error); } req_lib_votequorum_qdevice_poll.header.size = sizeof (struct req_lib_votequorum_qdevice_poll); req_lib_votequorum_qdevice_poll.header.id = MESSAGE_REQ_VOTEQUORUM_QDEVICE_POLL; strcpy(req_lib_votequorum_qdevice_poll.name, name); req_lib_votequorum_qdevice_poll.cast_vote = cast_vote; marshall_to_mar_votequorum_ring_id(&req_lib_votequorum_qdevice_poll.ring_id, &ring_id); iov.iov_base = (char *)&req_lib_votequorum_qdevice_poll; iov.iov_len = sizeof (struct req_lib_votequorum_qdevice_poll); error = qb_to_cs_error(qb_ipcc_sendv_recv ( votequorum_inst->c, &iov, 1, &res_lib_votequorum_status, sizeof (struct res_lib_votequorum_status), CS_IPC_TIMEOUT_MS)); if (error != CS_OK) { goto error_exit; } error = res_lib_votequorum_status.header.error; error_exit: hdb_handle_put (&votequorum_handle_t_db, handle); return (error); }
cs_error_t votequorum_qdevice_update ( votequorum_handle_t handle, const char *oldname, const char *newname) { cs_error_t error; struct votequorum_inst *votequorum_inst; struct iovec iov; struct req_lib_votequorum_qdevice_update req_lib_votequorum_qdevice_update; struct res_lib_votequorum_status res_lib_votequorum_status; if ((strlen(oldname) == 0) || (strlen(oldname) >= VOTEQUORUM_QDEVICE_MAX_NAME_LEN) || (strlen(newname) == 0) || (strlen(newname) >= VOTEQUORUM_QDEVICE_MAX_NAME_LEN)) { return CS_ERR_INVALID_PARAM; } error = hdb_error_to_cs(hdb_handle_get (&votequorum_handle_t_db, handle, (void *)&votequorum_inst)); if (error != CS_OK) { return (error); } req_lib_votequorum_qdevice_update.header.size = sizeof (struct req_lib_votequorum_qdevice_update); req_lib_votequorum_qdevice_update.header.id = MESSAGE_REQ_VOTEQUORUM_QDEVICE_UPDATE; strcpy(req_lib_votequorum_qdevice_update.oldname, oldname); strcpy(req_lib_votequorum_qdevice_update.newname, newname); iov.iov_base = (char *)&req_lib_votequorum_qdevice_update; iov.iov_len = sizeof (struct req_lib_votequorum_qdevice_update); error = qb_to_cs_error(qb_ipcc_sendv_recv ( votequorum_inst->c, &iov, 1, &res_lib_votequorum_status, sizeof (struct res_lib_votequorum_status), CS_IPC_TIMEOUT_MS)); if (error != CS_OK) { goto error_exit; } error = res_lib_votequorum_status.header.error; error_exit: hdb_handle_put (&votequorum_handle_t_db, handle); return (error); }
cs_error_t coroipcc_zcb_alloc ( hdb_handle_t handle, void **buffer, size_t size, size_t header_size) { struct ipc_instance *ipc_instance; void *buf = NULL; char path[PATH_MAX]; unsigned int res; mar_req_coroipcc_zc_alloc_t req_coroipcc_zc_alloc; coroipc_response_header_t res_coroipcs_zc_alloc; size_t map_size; struct iovec iovec; struct coroipcs_zc_header *hdr; res = hdb_error_to_cs (hdb_handle_get (&ipc_hdb, handle, (void **)&ipc_instance)); if (res != CS_OK) { return (res); } map_size = size + header_size + sizeof (struct coroipcs_zc_header); res = memory_map (path, "corosync_zerocopy-XXXXXX", &buf, map_size); assert (res != -1); req_coroipcc_zc_alloc.header.size = sizeof (mar_req_coroipcc_zc_alloc_t); req_coroipcc_zc_alloc.header.id = ZC_ALLOC_HEADER; req_coroipcc_zc_alloc.map_size = map_size; strcpy (req_coroipcc_zc_alloc.path_to_file, path); iovec.iov_base = (void *)&req_coroipcc_zc_alloc; iovec.iov_len = sizeof (mar_req_coroipcc_zc_alloc_t); res = coroipcc_msg_send_reply_receive ( handle, &iovec, 1, &res_coroipcs_zc_alloc, sizeof (coroipc_response_header_t)); hdr = (struct coroipcs_zc_header *)buf; hdr->map_size = map_size; *buffer = ((char *)buf) + sizeof (struct coroipcs_zc_header); hdb_handle_put (&ipc_hdb, handle); return (res); }
cs_error_t cmap_fd_get(cmap_handle_t handle, int *fd) { cs_error_t error; struct cmap_inst *cmap_inst; error = hdb_error_to_cs(hdb_handle_get (&cmap_handle_t_db, handle, (void *)&cmap_inst)); if (error != CS_OK) { return (error); } error = qb_to_cs_error (qb_ipcc_fd_get (cmap_inst->c, fd)); (void)hdb_handle_put (&cmap_handle_t_db, handle); return (error); }
cs_error_t coroipcc_msg_send_reply_receive_in_buf_put ( hdb_handle_t handle) { unsigned int res; struct ipc_instance *ipc_instance; res = hdb_error_to_cs (hdb_handle_get (&ipc_hdb, handle, (void **)&ipc_instance)); if (res != CS_OK) { return (res); } hdb_handle_put (&ipc_hdb, handle); hdb_handle_put (&ipc_hdb, handle); return (res); }
cs_error_t votequorum_qdevice_master_wins ( votequorum_handle_t handle, const char *name, unsigned int allow) { cs_error_t error; struct votequorum_inst *votequorum_inst; struct iovec iov; struct req_lib_votequorum_qdevice_master_wins req_lib_votequorum_qdevice_master_wins; struct res_lib_votequorum_status res_lib_votequorum_status; if ((strlen(name) == 0) || (strlen(name) >= VOTEQUORUM_QDEVICE_MAX_NAME_LEN)) { return CS_ERR_INVALID_PARAM; } error = hdb_error_to_cs(hdb_handle_get (&votequorum_handle_t_db, handle, (void *)&votequorum_inst)); if (error != CS_OK) { return (error); } req_lib_votequorum_qdevice_master_wins.header.size = sizeof (struct req_lib_votequorum_qdevice_master_wins); req_lib_votequorum_qdevice_master_wins.header.id = MESSAGE_REQ_VOTEQUORUM_QDEVICE_MASTER_WINS; strcpy(req_lib_votequorum_qdevice_master_wins.name, name); req_lib_votequorum_qdevice_master_wins.allow = allow; iov.iov_base = (char *)&req_lib_votequorum_qdevice_master_wins; iov.iov_len = sizeof (struct req_lib_votequorum_qdevice_master_wins); error = qb_to_cs_error(qb_ipcc_sendv_recv ( votequorum_inst->c, &iov, 1, &res_lib_votequorum_status, sizeof (struct res_lib_votequorum_status), CS_IPC_TIMEOUT_MS)); if (error != CS_OK) { goto error_exit; } error = res_lib_votequorum_status.header.error; error_exit: hdb_handle_put (&votequorum_handle_t_db, handle); return (error); }
static cs_error_t cmap_adjust_int(cmap_handle_t handle, const char *key_name, int32_t step) { cs_error_t error; struct iovec iov; struct cmap_inst *cmap_inst; struct req_lib_cmap_adjust_int req_lib_cmap_adjust_int; struct res_lib_cmap_adjust_int res_lib_cmap_adjust_int; if (key_name == NULL) { return (CS_ERR_INVALID_PARAM); } if (strlen(key_name) >= CS_MAX_NAME_LENGTH) { return (CS_ERR_NAME_TOO_LONG); } error = hdb_error_to_cs(hdb_handle_get (&cmap_handle_t_db, handle, (void *)&cmap_inst)); if (error != CS_OK) { return (error); } memset(&req_lib_cmap_adjust_int, 0, sizeof(req_lib_cmap_adjust_int)); req_lib_cmap_adjust_int.header.size = sizeof(req_lib_cmap_adjust_int); req_lib_cmap_adjust_int.header.id = MESSAGE_REQ_CMAP_ADJUST_INT; memcpy(req_lib_cmap_adjust_int.key_name.value, key_name, strlen(key_name)); req_lib_cmap_adjust_int.key_name.length = strlen(key_name); req_lib_cmap_adjust_int.step = step; iov.iov_base = (char *)&req_lib_cmap_adjust_int; iov.iov_len = sizeof(req_lib_cmap_adjust_int); error = qb_to_cs_error(qb_ipcc_sendv_recv( cmap_inst->c, &iov, 1, &res_lib_cmap_adjust_int, sizeof (struct res_lib_cmap_adjust_int), CS_IPC_TIMEOUT_MS)); if (error == CS_OK) { error = res_lib_cmap_adjust_int.header.error; } (void)hdb_handle_put (&cmap_handle_t_db, handle); return (error); }