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); }
/* * 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 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); }
/** * 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); }
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 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); }
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); }
cs_error_t icmap_init(void) { int32_t err; icmap_map = qb_trie_create(); if (icmap_map == NULL) return (CS_ERR_INIT); err = qb_map_notify_add(icmap_map, NULL, icmap_map_free_cb, QB_MAP_NOTIFY_FREE, NULL); return (qb_to_cs_error(err)); }
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 icmap_track_delete(icmap_track_t icmap_track) { int32_t err; if ((err = qb_map_notify_del_2(icmap_map, icmap_track->key_name, icmap_notify_fn, icmap_tt_to_qbtt(icmap_track->track_type), icmap_track)) != 0) { return (qb_to_cs_error(err)); } free(icmap_track->key_name); free(icmap_track); return (CS_OK); }
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 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 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); }
cs_error_t votequorum_fd_get ( votequorum_handle_t handle, int *fd) { cs_error_t error; struct votequorum_inst *votequorum_inst; error = hdb_error_to_cs(hdb_handle_get (&votequorum_handle_t_db, handle, (void *)&votequorum_inst)); if (error != CS_OK) { return (error); } error = qb_to_cs_error(qb_ipcc_fd_get (votequorum_inst->c, fd)); (void)hdb_handle_put (&votequorum_handle_t_db, handle); return (error); }
cs_error_t corosync_cfg_fd_get ( corosync_cfg_handle_t cfg_handle, int32_t *selection_fd) { 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); } error = qb_to_cs_error (qb_ipcc_fd_get (cfg_inst->c, selection_fd)); (void)hdb_handle_put (&cfg_hdb, cfg_handle); return (error); }
cs_error_t icmap_track_add( const char *key_name, int32_t track_type, icmap_notify_fn_t notify_fn, void *user_data, icmap_track_t *icmap_track) { int32_t err; if (notify_fn == NULL || icmap_track == NULL) { return (CS_ERR_INVALID_PARAM); } if ((track_type & ~(ICMAP_TRACK_ADD | ICMAP_TRACK_DELETE | ICMAP_TRACK_MODIFY | ICMAP_TRACK_PREFIX)) != 0) { return (CS_ERR_INVALID_PARAM); } *icmap_track = malloc(sizeof(**icmap_track)); if (*icmap_track == NULL) { return (CS_ERR_NO_MEMORY); } memset(*icmap_track, 0, sizeof(**icmap_track)); if (key_name != NULL) { (*icmap_track)->key_name = strdup(key_name); }; (*icmap_track)->track_type = track_type; (*icmap_track)->notify_fn = notify_fn; (*icmap_track)->user_data = user_data; if ((err = qb_map_notify_add(icmap_map, (*icmap_track)->key_name, icmap_notify_fn, icmap_tt_to_qbtt(track_type), *icmap_track)) != 0) { free((*icmap_track)->key_name); free(*icmap_track); return (qb_to_cs_error(err)); } list_init(&(*icmap_track)->list); list_add (&(*icmap_track)->list, &icmap_track_list_head); return (CS_OK); }
cs_error_t logsys_reopen_log_files(void) { cs_error_t res; #ifdef HAVE_QB_LOG_FILE_REOPEN int i, j; int num_using_current; int32_t rc; res = CS_OK; pthread_mutex_lock (&logsys_config_mutex); for (i = 0; i <= LOGSYS_MAX_SUBSYS_COUNT; i++) { if (logsys_loggers[i].target_id <= 0 || logsys_loggers[i].logfile == NULL) { continue ; } num_using_current = 0; for (j = 0; j <= i; j++) { if (logsys_loggers[i].target_id == logsys_loggers[j].target_id) { num_using_current++; } } if (num_using_current == 1) { /* * First instance of target file. Reopen it. */ rc = qb_log_file_reopen(logsys_loggers[i].target_id, NULL); if (rc != 0) { LOGSYS_PERROR (-rc, LOGSYS_LEVEL_WARNING, "Unable to reopen log file %s", logsys_loggers[i].logfile); res = qb_to_cs_error(rc); } } } pthread_mutex_unlock (&logsys_config_mutex); #else res = CS_ERR_NOT_SUPPORTED; #endif return (res); }
unsigned int pload_start ( pload_handle_t handle, unsigned int code, unsigned int msg_count, unsigned int msg_size) { unsigned int error; struct pload_inst *pload_inst; struct iovec iov; struct req_lib_pload_start req_lib_pload_start; struct res_lib_pload_start res_lib_pload_start; error = hdb_error_to_cs(hdb_handle_get (&pload_handle_t_db, handle, (void *)&pload_inst)); if (error != CS_OK) { return (error); } req_lib_pload_start.header.size = sizeof (struct req_lib_pload_start); req_lib_pload_start.header.id = MESSAGE_REQ_PLOAD_START; req_lib_pload_start.msg_code = code; req_lib_pload_start.msg_count = msg_count; req_lib_pload_start.msg_size = msg_size; iov.iov_base = (char *)&req_lib_pload_start; iov.iov_len = sizeof (struct req_lib_pload_start); error = qb_to_cs_error(qb_ipcc_sendv_recv(pload_inst->c, &iov, 1, &res_lib_pload_start, sizeof (struct res_lib_pload_start), -1)); if (error != CS_OK) { goto error_exit; } error = res_lib_pload_start.header.error; error_exit: (void)hdb_handle_put (&pload_handle_t_db, handle); return (error); }
cs_error_t cmap_delete(cmap_handle_t handle, const char *key_name) { cs_error_t error; struct iovec iov; struct cmap_inst *cmap_inst; struct req_lib_cmap_delete req_lib_cmap_delete; struct res_lib_cmap_delete res_lib_cmap_delete; 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_delete, 0, sizeof(req_lib_cmap_delete)); req_lib_cmap_delete.header.size = sizeof(req_lib_cmap_delete); req_lib_cmap_delete.header.id = MESSAGE_REQ_CMAP_DELETE; memcpy(req_lib_cmap_delete.key_name.value, key_name, strlen(key_name)); req_lib_cmap_delete.key_name.length = strlen(key_name); iov.iov_base = (char *)&req_lib_cmap_delete; iov.iov_len = sizeof(req_lib_cmap_delete); error = qb_to_cs_error(qb_ipcc_sendv_recv( cmap_inst->c, &iov, 1, &res_lib_cmap_delete, sizeof (struct res_lib_cmap_delete), CS_IPC_TIMEOUT_MS)); if (error == CS_OK) { error = res_lib_cmap_delete.header.error; } (void)hdb_handle_put (&cmap_handle_t_db, handle); return (error); }
cs_error_t votequorum_setvotes ( votequorum_handle_t handle, unsigned int nodeid, unsigned int votes) { cs_error_t error; struct votequorum_inst *votequorum_inst; struct iovec iov; struct req_lib_votequorum_setvotes req_lib_votequorum_setvotes; struct res_lib_votequorum_status res_lib_votequorum_status; 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_setvotes.header.size = sizeof (struct req_lib_votequorum_setvotes); req_lib_votequorum_setvotes.header.id = MESSAGE_REQ_VOTEQUORUM_SETVOTES; req_lib_votequorum_setvotes.nodeid = nodeid; req_lib_votequorum_setvotes.votes = votes; iov.iov_base = (char *)&req_lib_votequorum_setvotes; iov.iov_len = sizeof (struct req_lib_votequorum_setvotes); 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_trackstart ( votequorum_handle_t handle, uint64_t context, unsigned int flags) { cs_error_t error; struct votequorum_inst *votequorum_inst; struct iovec iov; struct req_lib_votequorum_trackstart req_lib_votequorum_trackstart; struct res_lib_votequorum_status res_lib_votequorum_status; 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_trackstart.header.size = sizeof (struct req_lib_votequorum_trackstart); req_lib_votequorum_trackstart.header.id = MESSAGE_REQ_VOTEQUORUM_TRACKSTART; req_lib_votequorum_trackstart.track_flags = flags; req_lib_votequorum_trackstart.context = context; iov.iov_base = (char *)&req_lib_votequorum_trackstart; iov.iov_len = sizeof (struct req_lib_votequorum_trackstart); 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 corosync_cfg_kill_node ( corosync_cfg_handle_t cfg_handle, unsigned int nodeid, const char *reason) { struct cfg_inst *cfg_inst; struct req_lib_cfg_killnode req_lib_cfg_killnode; struct res_lib_cfg_killnode res_lib_cfg_killnode; cs_error_t error; struct iovec iov; if (strlen(reason) >= CS_MAX_NAME_LENGTH) return CS_ERR_NAME_TOO_LONG; error = hdb_error_to_cs (hdb_handle_get (&cfg_hdb, cfg_handle, (void *)&cfg_inst)); if (error != CS_OK) { return (error); } req_lib_cfg_killnode.header.id = MESSAGE_REQ_CFG_KILLNODE; req_lib_cfg_killnode.header.size = sizeof (struct req_lib_cfg_killnode); req_lib_cfg_killnode.nodeid = nodeid; strcpy((char *)req_lib_cfg_killnode.reason.value, reason); req_lib_cfg_killnode.reason.length = strlen(reason)+1; iov.iov_base = (void *)&req_lib_cfg_killnode; iov.iov_len = sizeof (struct req_lib_cfg_killnode); error = qb_to_cs_error (qb_ipcc_sendv_recv (cfg_inst->c, &iov, 1, &res_lib_cfg_killnode, sizeof (struct res_lib_cfg_killnode), CS_IPC_TIMEOUT_MS)); error = res_lib_cfg_killnode.header.error; (void)hdb_handle_put (&cfg_hdb, cfg_handle); return (error == CS_OK ? res_lib_cfg_killnode.header.error : error); }
cs_error_t quorum_getquorate ( quorum_handle_t handle, int *quorate) { cs_error_t error; struct quorum_inst *quorum_inst; struct iovec iov; struct qb_ipc_request_header req; struct res_lib_quorum_getquorate res_lib_quorum_getquorate; error = hdb_error_to_cs(hdb_handle_get (&quorum_handle_t_db, handle, (void *)&quorum_inst)); if (error != CS_OK) { return (error); } req.size = sizeof (req); req.id = MESSAGE_REQ_QUORUM_GETQUORATE; iov.iov_base = (char *)&req; iov.iov_len = sizeof (req); error = qb_to_cs_error(qb_ipcc_sendv_recv ( quorum_inst->c, &iov, 1, &res_lib_quorum_getquorate, sizeof (struct res_lib_quorum_getquorate), CS_IPC_TIMEOUT_MS)); if (error != CS_OK) { goto error_exit; } error = res_lib_quorum_getquorate.header.error; *quorate = res_lib_quorum_getquorate.quorate; error_exit: (void)hdb_handle_put (&quorum_handle_t_db, handle); return (error); }
cs_error_t corosync_cfg_local_get ( corosync_cfg_handle_t handle, unsigned int *local_nodeid) { cs_error_t error; struct cfg_inst *cfg_inst; struct iovec iov; struct req_lib_cfg_local_get req_lib_cfg_local_get; struct res_lib_cfg_local_get res_lib_cfg_local_get; error = hdb_error_to_cs(hdb_handle_get (&cfg_hdb, handle, (void *)&cfg_inst)); if (error != CS_OK) { return (error); } req_lib_cfg_local_get.header.size = sizeof (struct qb_ipc_request_header); req_lib_cfg_local_get.header.id = MESSAGE_REQ_CFG_LOCAL_GET; iov.iov_base = (void *)&req_lib_cfg_local_get; iov.iov_len = sizeof (struct req_lib_cfg_local_get); error = qb_to_cs_error (qb_ipcc_sendv_recv ( cfg_inst->c, &iov, 1, &res_lib_cfg_local_get, sizeof (struct res_lib_cfg_local_get), CS_IPC_TIMEOUT_MS)); if (error != CS_OK) { goto error_exit; } error = res_lib_cfg_local_get.header.error; *local_nodeid = res_lib_cfg_local_get.local_nodeid; error_exit: (void)hdb_handle_put (&cfg_hdb, 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); }