コード例 #1
0
ファイル: cfg.c プロジェクト: credativ/corosync
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);
}
コード例 #2
0
ファイル: cfg.c プロジェクト: credativ/corosync
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);
}
コード例 #3
0
ファイル: cfg.c プロジェクト: credativ/corosync
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);
}
コード例 #4
0
ファイル: cmap.c プロジェクト: credativ/corosync
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);
}
コード例 #5
0
ファイル: cmap.c プロジェクト: credativ/corosync
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);
}
コード例 #6
0
ファイル: ipc.c プロジェクト: bcavanagh/pacemaker
static int
internal_ipc_send_recv(crm_ipc_t *client, const void *iov)
{
    int rc = 0;
    do {
        rc = qb_ipcc_sendv_recv(client->ipc, iov, 2, client->buffer, client->buf_size, -1);
    } while(rc == -EAGAIN && crm_ipc_connected(client));

    return rc;
}
コード例 #7
0
ファイル: cmap.c プロジェクト: credativ/corosync
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);
}
コード例 #8
0
ファイル: votequorum.c プロジェクト: KevenChang/corosync
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);
}
コード例 #9
0
ファイル: cmap.c プロジェクト: credativ/corosync
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);
}
コード例 #10
0
ファイル: votequorum.c プロジェクト: KevenChang/corosync
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);
}
コード例 #11
0
ファイル: votequorum.c プロジェクト: KevenChang/corosync
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);
}
コード例 #12
0
ファイル: votequorum.c プロジェクト: KevenChang/corosync
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);
}
コード例 #13
0
int
crm_ipc_send(crm_ipc_t *client, xmlNode *message, xmlNode **reply, int32_t ms_timeout)
{
    long rc = 0;
    struct iovec iov[2];
    static uint32_t id = 0;
    struct qb_ipc_request_header header;
    char *buffer = dump_xml_unformatted(message);

    iov[0].iov_len = sizeof(struct qb_ipc_request_header);
    iov[0].iov_base = &header;
    iov[1].iov_len = 1 + strlen(buffer);
    iov[1].iov_base = buffer;

    header.id = id++; /* We don't really use it, but doesn't hurt to set one */
    header.size = iov[0].iov_len + iov[1].iov_len;

    if(ms_timeout == 0) {
        ms_timeout = 5000;
    }
    
    crm_trace("Waiting for reply to %u bytes: %.200s...", header.size, buffer);
    rc = qb_ipcc_sendv_recv(client->ipc, iov, 2, client->buffer, client->buf_size, ms_timeout);

    if(rc > 0) {
        struct qb_ipc_response_header *hdr = (struct qb_ipc_response_header *)client->buffer;
        crm_trace("Recieved response %d, size=%d, rc=%d, text: %.200s", hdr->id, hdr->size, rc, crm_ipc_buffer(client));

        if(reply) {
            *reply = string2xml(crm_ipc_buffer(client));
        }

    } else {
        crm_trace("Response not recieved: rc=%d, errno=%d", rc, errno);
    }

    if(crm_ipc_connected(client) == FALSE) {
        crm_notice("Connection to %s closed: %d", client->name, rc);

    } else if(rc <= 0) {
        crm_perror(LOG_ERR, "Request to %s failed: %ld", client->name, rc);
        crm_info("Request was %.120s", buffer);
    }

    free(buffer);
    return rc;
}
コード例 #14
0
ファイル: cmap.c プロジェクト: credativ/corosync
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);
}
コード例 #15
0
ファイル: pload.c プロジェクト: danfrincu/corosync
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);
}
コード例 #16
0
ファイル: votequorum.c プロジェクト: KevenChang/corosync
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);
}
コード例 #17
0
ファイル: votequorum.c プロジェクト: KevenChang/corosync
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);
}
コード例 #18
0
ファイル: cmap.c プロジェクト: ip1981/corosync
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);
}
コード例 #19
0
ファイル: cfg.c プロジェクト: credativ/corosync
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);
}
コード例 #20
0
ファイル: quorum.c プロジェクト: ip1981/corosync
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);
}
コード例 #21
0
ファイル: cfg.c プロジェクト: credativ/corosync
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);
}
コード例 #22
0
ファイル: quorum.c プロジェクト: ip1981/corosync
cs_error_t quorum_trackstart (
	quorum_handle_t handle,
	unsigned int flags )
{
	cs_error_t error;
	struct quorum_inst *quorum_inst;
	struct iovec iov;
	struct req_lib_quorum_trackstart req_lib_quorum_trackstart;
	struct qb_ipc_response_header res;

	error = hdb_error_to_cs(hdb_handle_get (&quorum_handle_t_db, handle, (void *)&quorum_inst));
	if (error != CS_OK) {
		return (error);
	}

	req_lib_quorum_trackstart.header.size = sizeof (struct req_lib_quorum_trackstart);
	req_lib_quorum_trackstart.header.id = MESSAGE_REQ_QUORUM_TRACKSTART;
	req_lib_quorum_trackstart.track_flags = flags;

	iov.iov_base = (char *)&req_lib_quorum_trackstart;
	iov.iov_len = sizeof (struct req_lib_quorum_trackstart);

       error = qb_to_cs_error(qb_ipcc_sendv_recv (
		quorum_inst->c,
                &iov,
                1,
                &res,
                sizeof (res), CS_IPC_TIMEOUT_MS));

	if (error != CS_OK) {
		goto error_exit;
	}

	error = res.error;

error_exit:
	(void)hdb_handle_put (&quorum_handle_t_db, handle);

	return (error);
}
コード例 #23
0
ファイル: cmap.c プロジェクト: credativ/corosync
cs_error_t cmap_iter_finalize(
		cmap_handle_t handle,
		cmap_iter_handle_t iter_handle)
{
	cs_error_t error;
	struct iovec iov;
	struct cmap_inst *cmap_inst;
	struct req_lib_cmap_iter_finalize req_lib_cmap_iter_finalize;
	struct res_lib_cmap_iter_finalize res_lib_cmap_iter_finalize;

	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_finalize, 0, sizeof(req_lib_cmap_iter_finalize));
	req_lib_cmap_iter_finalize.header.size = sizeof(req_lib_cmap_iter_finalize);
	req_lib_cmap_iter_finalize.header.id = MESSAGE_REQ_CMAP_ITER_FINALIZE;
	req_lib_cmap_iter_finalize.iter_handle = iter_handle;

	iov.iov_base = (char *)&req_lib_cmap_iter_finalize;
	iov.iov_len = sizeof(req_lib_cmap_iter_finalize);

	error = qb_to_cs_error(qb_ipcc_sendv_recv(
		cmap_inst->c,
		&iov,
		1,
		&res_lib_cmap_iter_finalize,
		sizeof (struct res_lib_cmap_iter_finalize), CS_IPC_TIMEOUT_MS));

	if (error == CS_OK) {
		error = res_lib_cmap_iter_finalize.header.error;
	}

	(void)hdb_handle_put (&cmap_handle_t_db, handle);

	return (error);
}
コード例 #24
0
ファイル: cfg.c プロジェクト: HideoYamauchi/corosync
cs_error_t corosync_cfg_reopen_log_files (
	corosync_cfg_handle_t handle)
{
	cs_error_t error;
	struct cfg_inst *cfg_inst;
	struct iovec iov;
	struct req_lib_cfg_reopen_log_files req_lib_cfg_reopen_log_files;
	struct res_lib_cfg_reopen_log_files res_lib_cfg_reopen_log_files;

	error = hdb_error_to_cs(hdb_handle_get (&cfg_hdb, handle, (void *)&cfg_inst));
	if (error != CS_OK) {
		return (error);
	}

	req_lib_cfg_reopen_log_files.header.size = sizeof (struct qb_ipc_request_header);
	req_lib_cfg_reopen_log_files.header.id = MESSAGE_REQ_CFG_REOPEN_LOG_FILES;

	iov.iov_base = (void *)&req_lib_cfg_reopen_log_files;
	iov.iov_len = sizeof (struct req_lib_cfg_reopen_log_files);

	error = qb_to_cs_error (qb_ipcc_sendv_recv (
		cfg_inst->c,
		&iov,
		1,
		&res_lib_cfg_reopen_log_files,
		sizeof (struct res_lib_cfg_reopen_log_files), CS_IPC_TIMEOUT_MS));

	if (error != CS_OK) {
		goto error_exit;
	}

	error = res_lib_cfg_reopen_log_files.header.error;

error_exit:
	(void)hdb_handle_put (&cfg_hdb, handle);

	return (error);
}
コード例 #25
0
ファイル: quorum.c プロジェクト: ip1981/corosync
cs_error_t quorum_trackstop (
	quorum_handle_t handle)
{
	cs_error_t error;
	struct quorum_inst *quorum_inst;
	struct iovec iov;
	struct qb_ipc_request_header req;
	struct qb_ipc_response_header res;

	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_TRACKSTOP;

	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,
                sizeof (res), CS_IPC_TIMEOUT_MS));

	if (error != CS_OK) {
		goto error_exit;
	}

	error = res.error;

error_exit:
	(void)hdb_handle_put (&quorum_handle_t_db, handle);

	return (error);
}
コード例 #26
0
ファイル: votequorum.c プロジェクト: KevenChang/corosync
cs_error_t votequorum_trackstop (
	votequorum_handle_t handle)
{
	cs_error_t error;
	struct votequorum_inst *votequorum_inst;
	struct iovec iov;
	struct req_lib_votequorum_general req_lib_votequorum_general;
	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_general.header.size = sizeof (struct req_lib_votequorum_general);
	req_lib_votequorum_general.header.id = MESSAGE_REQ_VOTEQUORUM_TRACKSTOP;

	iov.iov_base = (char *)&req_lib_votequorum_general;
	iov.iov_len = sizeof (struct req_lib_votequorum_general);

        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);
}
コード例 #27
0
ファイル: cfg.c プロジェクト: credativ/corosync
cs_error_t corosync_cfg_reload_config (
	corosync_cfg_handle_t handle)
{
	cs_error_t error;
	struct cfg_inst *cfg_inst;
	struct iovec iov;
	struct req_lib_cfg_reload_config req_lib_cfg_reload_config;
	struct res_lib_cfg_reload_config res_lib_cfg_reload_config;

	error = hdb_error_to_cs(hdb_handle_get (&cfg_hdb, handle, (void *)&cfg_inst));
	if (error != CS_OK) {
		return (error);
	}

	req_lib_cfg_reload_config.header.size = sizeof (struct qb_ipc_request_header);
	req_lib_cfg_reload_config.header.id = MESSAGE_REQ_CFG_RELOAD_CONFIG;

	iov.iov_base = (void *)&req_lib_cfg_reload_config;
	iov.iov_len = sizeof (struct req_lib_cfg_reload_config);

	error = qb_to_cs_error (qb_ipcc_sendv_recv (
		cfg_inst->c,
		&iov,
		1,
		&res_lib_cfg_reload_config,
		sizeof (struct res_lib_cfg_reload_config), CS_IPC_TIMEOUT_MS));

	if (error != CS_OK) {
		goto error_exit;
	}

	error = res_lib_cfg_reload_config.header.error;

error_exit:
	(void)hdb_handle_put (&cfg_hdb, handle);

	return (error);
}
コード例 #28
0
ファイル: cmap.c プロジェクト: credativ/corosync
cs_error_t cmap_track_add(
	cmap_handle_t handle,
	const char *key_name,
	int32_t track_type,
	cmap_notify_fn_t notify_fn,
	void *user_data,
	cmap_track_handle_t *cmap_track_handle)
{
	cs_error_t error;
	struct iovec iov;
	struct cmap_inst *cmap_inst;
	struct req_lib_cmap_track_add req_lib_cmap_track_add;
	struct res_lib_cmap_track_add res_lib_cmap_track_add;
	struct cmap_track_inst *cmap_track_inst;
	cmap_track_handle_t cmap_track_inst_handle;

	if (cmap_track_handle == NULL || notify_fn == 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);
	}

	error = hdb_error_to_cs(hdb_handle_create(&cmap_track_handle_t_db,
				sizeof(*cmap_track_inst), &cmap_track_inst_handle));
	if (error != CS_OK) {
		goto error_put;
	}

	error = hdb_error_to_cs(hdb_handle_get(&cmap_track_handle_t_db,
				cmap_track_inst_handle, (void *)&cmap_track_inst));
	if (error != CS_OK) {
		goto error_put_destroy;
	}

	cmap_track_inst->user_data = user_data;
	cmap_track_inst->notify_fn = notify_fn;
	cmap_track_inst->c = cmap_inst->c;

	memset(&req_lib_cmap_track_add, 0, sizeof(req_lib_cmap_track_add));
	req_lib_cmap_track_add.header.size = sizeof(req_lib_cmap_track_add);
	req_lib_cmap_track_add.header.id = MESSAGE_REQ_CMAP_TRACK_ADD;

	if (key_name) {
		if (strlen(key_name) >= CS_MAX_NAME_LENGTH) {
			return (CS_ERR_NAME_TOO_LONG);
		}
		memcpy(req_lib_cmap_track_add.key_name.value, key_name, strlen(key_name));
		req_lib_cmap_track_add.key_name.length = strlen(key_name);
	}

	req_lib_cmap_track_add.track_type = track_type;
	req_lib_cmap_track_add.track_inst_handle = cmap_track_inst_handle;

	iov.iov_base = (char *)&req_lib_cmap_track_add;
	iov.iov_len = sizeof(req_lib_cmap_track_add);

	error = qb_to_cs_error(qb_ipcc_sendv_recv(
		cmap_inst->c,
		&iov,
		1,
		&res_lib_cmap_track_add,
		sizeof (struct res_lib_cmap_track_add), CS_IPC_TIMEOUT_MS));

	if (error == CS_OK) {
		error = res_lib_cmap_track_add.header.error;
	}

	if (error == CS_OK) {
		*cmap_track_handle = res_lib_cmap_track_add.track_handle;
		cmap_track_inst->track_handle = *cmap_track_handle;
	}

	(void)hdb_handle_put (&cmap_track_handle_t_db, cmap_track_inst_handle);

	(void)hdb_handle_put (&cmap_handle_t_db, handle);

	return (error);

error_put_destroy:
	(void)hdb_handle_put (&cmap_track_handle_t_db, cmap_track_inst_handle);
	(void)hdb_handle_destroy (&cmap_track_handle_t_db, cmap_track_inst_handle);

error_put:
	(void)hdb_handle_put (&cmap_handle_t_db, handle);

	return (error);
}
コード例 #29
0
ファイル: cmap.c プロジェクト: credativ/corosync
cs_error_t cmap_get(
		cmap_handle_t handle,
		const char *key_name,
		void *value,
		size_t *value_len,
		cmap_value_types_t *type)
{
	cs_error_t error;
	struct cmap_inst *cmap_inst;
	struct iovec iov;
	struct req_lib_cmap_get req_lib_cmap_get;
	struct res_lib_cmap_get *res_lib_cmap_get;
	size_t res_size;

	if (key_name == NULL) {
		return (CS_ERR_INVALID_PARAM);
	}
	if (strlen(key_name) >= CS_MAX_NAME_LENGTH) {
		return (CS_ERR_NAME_TOO_LONG);
	}

	if (value != NULL && value_len == 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_get, 0, sizeof(req_lib_cmap_get));
	req_lib_cmap_get.header.size = sizeof(req_lib_cmap_get);
	req_lib_cmap_get.header.id = MESSAGE_REQ_CMAP_GET;

	memcpy(req_lib_cmap_get.key_name.value, key_name, strlen(key_name));
	req_lib_cmap_get.key_name.length = strlen(key_name);

	if (value != NULL && value_len != NULL) {
		req_lib_cmap_get.value_len = *value_len;
	} else {
		req_lib_cmap_get.value_len = 0;
	}

	iov.iov_base = (char *)&req_lib_cmap_get;
	iov.iov_len = sizeof(req_lib_cmap_get);

	res_size = sizeof(struct res_lib_cmap_get) + req_lib_cmap_get.value_len;

	res_lib_cmap_get = malloc(res_size);
	if (res_lib_cmap_get == NULL) {
		return (CS_ERR_NO_MEMORY);
	}

	error = qb_to_cs_error(qb_ipcc_sendv_recv(
		cmap_inst->c,
		&iov,
		1,
		res_lib_cmap_get,
		res_size, CS_IPC_TIMEOUT_MS));

	if (error == CS_OK) {
		error = res_lib_cmap_get->header.error;
	}

	if (error == CS_OK) {
		if (type != NULL) {
			*type = res_lib_cmap_get->type;
		}

		if (value_len != NULL) {
			*value_len = res_lib_cmap_get->value_len;
		}

		if (value != NULL && value_len != NULL) {
			memcpy(value, res_lib_cmap_get->value, res_lib_cmap_get->value_len);
		}
	}

	free(res_lib_cmap_get);

	(void)hdb_handle_put (&cmap_handle_t_db, handle);

	return (error);
}
コード例 #30
0
ファイル: cfg.c プロジェクト: credativ/corosync
cs_error_t corosync_cfg_get_node_addrs (
	corosync_cfg_handle_t cfg_handle,
	int nodeid,
	size_t max_addrs,
	int *num_addrs,
	corosync_cfg_node_address_t *addrs)
{
	cs_error_t error;
	struct req_lib_cfg_get_node_addrs req_lib_cfg_get_node_addrs;
	struct res_lib_cfg_get_node_addrs *res_lib_cfg_get_node_addrs;
	struct cfg_inst *cfg_inst;
	int addrlen = 0;
	int i;
	struct iovec iov;
	const char *addr_buf;
	char response_buf[IPC_RESPONSE_SIZE];

	error = hdb_error_to_cs(hdb_handle_get (&cfg_hdb, cfg_handle,
		(void *)&cfg_inst));
	if (error != CS_OK) {
		return (error);
	}

	req_lib_cfg_get_node_addrs.header.size = sizeof (req_lib_cfg_get_node_addrs);
	req_lib_cfg_get_node_addrs.header.id = MESSAGE_REQ_CFG_GET_NODE_ADDRS;
	req_lib_cfg_get_node_addrs.nodeid = nodeid;

	iov.iov_base = (char *)&req_lib_cfg_get_node_addrs;
	iov.iov_len = sizeof (req_lib_cfg_get_node_addrs);

	error = qb_to_cs_error (qb_ipcc_sendv_recv (
		cfg_inst->c,
		&iov, 1,
		response_buf, IPC_RESPONSE_SIZE, CS_IPC_TIMEOUT_MS));
	res_lib_cfg_get_node_addrs = (struct res_lib_cfg_get_node_addrs *)response_buf;

	if (error != CS_OK) {
		goto error_put;
	}

	if (res_lib_cfg_get_node_addrs->family == AF_INET)
		addrlen = sizeof(struct sockaddr_in);
	if (res_lib_cfg_get_node_addrs->family == AF_INET6)
		addrlen = sizeof(struct sockaddr_in6);

	for (i = 0, addr_buf = (char *)res_lib_cfg_get_node_addrs->addrs;
	    i < max_addrs && i<res_lib_cfg_get_node_addrs->num_addrs;
	    i++, addr_buf += TOTEMIP_ADDRLEN) {
		struct sockaddr_in *in;
		struct sockaddr_in6 *in6;

		addrs[i].address_length = addrlen;

		if (res_lib_cfg_get_node_addrs->family == AF_INET) {
			in = (struct sockaddr_in *)addrs[i].address;
			in->sin_family = AF_INET;
			memcpy(&in->sin_addr, addr_buf, sizeof(struct in_addr));
		}
		if (res_lib_cfg_get_node_addrs->family == AF_INET6) {
			in6 = (struct sockaddr_in6 *)addrs[i].address;
			in6->sin6_family = AF_INET6;
			memcpy(&in6->sin6_addr, addr_buf, sizeof(struct in6_addr));
		}
	}
	*num_addrs = res_lib_cfg_get_node_addrs->num_addrs;
	errno = error = res_lib_cfg_get_node_addrs->header.error;

error_put:
	hdb_handle_put (&cfg_hdb, cfg_handle);

	return (error);
}