| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714 |
- /*
- * Copyright (c) 2009-2012 Red Hat, Inc.
- *
- * All rights reserved.
- *
- * Author: Christine Caulfield (ccaulfie@redhat.com)
- *
- * This software licensed under BSD license, the text of which follows:
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * - Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * - Neither the name of the MontaVista Software, Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
- /*
- * Provides a quorum API using the corosync executive
- */
- #include <config.h>
- #include <stdlib.h>
- #include <string.h>
- #include <unistd.h>
- #include <sys/types.h>
- #include <sys/socket.h>
- #include <errno.h>
- #include <qb/qbdefs.h>
- #include <qb/qbipcc.h>
- #include <corosync/corotypes.h>
- #include <corosync/corodefs.h>
- #include <corosync/hdb.h>
- #include <corosync/votequorum.h>
- #include <corosync/ipc_votequorum.h>
- #include "util.h"
- struct votequorum_inst {
- qb_ipcc_connection_t *c;
- int finalize;
- void *context;
- votequorum_callbacks_t callbacks;
- };
- DECLARE_HDB_DATABASE(votequorum_handle_t_db,NULL);
- 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->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 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;
- qb_ipcc_disconnect (votequorum_inst->c);
- hdb_handle_destroy (&votequorum_handle_t_db, handle);
- hdb_handle_put (&votequorum_handle_t_db, handle);
- return (CS_OK);
- }
- 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_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;
- error_exit:
- hdb_handle_put (&votequorum_handle_t_db, handle);
- return (error);
- }
- cs_error_t votequorum_setexpected (
- votequorum_handle_t handle,
- unsigned int expected_votes)
- {
- cs_error_t error;
- struct votequorum_inst *votequorum_inst;
- struct iovec iov;
- struct req_lib_votequorum_setexpected req_lib_votequorum_setexpected;
- 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_setexpected.header.size = sizeof (struct req_lib_votequorum_setexpected);
- req_lib_votequorum_setexpected.header.id = MESSAGE_REQ_VOTEQUORUM_SETEXPECTED;
- req_lib_votequorum_setexpected.expected_votes = expected_votes;
- iov.iov_base = (char *)&req_lib_votequorum_setexpected;
- iov.iov_len = sizeof (struct req_lib_votequorum_setexpected);
- 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_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 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);
- }
- cs_error_t votequorum_context_get (
- votequorum_handle_t handle,
- void **context)
- {
- 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);
- }
- *context = votequorum_inst->context;
- hdb_handle_put (&votequorum_handle_t_db, handle);
- return (CS_OK);
- }
- cs_error_t votequorum_context_set (
- votequorum_handle_t handle,
- void *context)
- {
- 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);
- }
- votequorum_inst->context = context;
- hdb_handle_put (&votequorum_handle_t_db, handle);
- return (CS_OK);
- }
- 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 votequorum_dispatch (
- votequorum_handle_t handle,
- cs_dispatch_flags_t dispatch_types)
- {
- int timeout = -1;
- cs_error_t error;
- int cont = 1; /* always continue do loop except when set to 0 */
- struct votequorum_inst *votequorum_inst;
- votequorum_callbacks_t callbacks;
- struct qb_ipc_response_header *dispatch_data;
- struct res_lib_votequorum_notification *res_lib_votequorum_notification;
- struct res_lib_votequorum_expectedvotes_notification *res_lib_votequorum_expectedvotes_notification;
- char dispatch_buf[IPC_DISPATCH_SIZE];
- if (dispatch_types != CS_DISPATCH_ONE &&
- dispatch_types != CS_DISPATCH_ALL &&
- dispatch_types != CS_DISPATCH_BLOCKING &&
- dispatch_types != CS_DISPATCH_ONE_NONBLOCKING) {
- 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);
- }
- /*
- * Timeout instantly for CS_DISPATCH_ONE_NONBLOCKING or CS_DISPATCH_ALL and
- * wait indefinately for CS_DISPATCH_ONE or CS_DISPATCH_BLOCKING
- */
- if (dispatch_types == CS_DISPATCH_ALL || dispatch_types == CS_DISPATCH_ONE_NONBLOCKING) {
- timeout = 0;
- }
- dispatch_data = (struct qb_ipc_response_header *)dispatch_buf;
- do {
- error = qb_to_cs_error (qb_ipcc_event_recv (
- votequorum_inst->c,
- dispatch_buf,
- IPC_DISPATCH_SIZE,
- timeout));
- if (error == CS_ERR_BAD_HANDLE) {
- error = CS_OK;
- goto error_put;
- }
- if (error == CS_ERR_TRY_AGAIN) {
- if (dispatch_types == CS_DISPATCH_ONE_NONBLOCKING) {
- /*
- * Don't mask error
- */
- goto error_put;
- }
- error = CS_OK;
- if (dispatch_types == CS_DISPATCH_ALL) {
- break; /* exit do while cont is 1 loop */
- } else {
- continue; /* next poll */
- }
- }
- if (error != CS_OK) {
- goto error_put;
- }
- /*
- * Make copy of callbacks, message data, unlock instance, and call callback
- * A risk of this dispatch method is that the callback routines may
- * operate at the same time that votequorum_finalize has been called in another thread.
- */
- memcpy (&callbacks, &votequorum_inst->callbacks, sizeof (votequorum_callbacks_t));
- /*
- * Dispatch incoming message
- */
- switch (dispatch_data->id) {
- case MESSAGE_RES_VOTEQUORUM_NOTIFICATION:
- if (callbacks.votequorum_notify_fn == NULL) {
- break;
- }
- res_lib_votequorum_notification = (struct res_lib_votequorum_notification *)dispatch_data;
- callbacks.votequorum_notify_fn ( handle,
- res_lib_votequorum_notification->context,
- res_lib_votequorum_notification->quorate,
- res_lib_votequorum_notification->node_list_entries,
- (votequorum_node_t *)res_lib_votequorum_notification->node_list );
- ;
- break;
- case MESSAGE_RES_VOTEQUORUM_EXPECTEDVOTES_NOTIFICATION:
- if (callbacks.votequorum_expectedvotes_notify_fn == NULL) {
- break;
- }
- res_lib_votequorum_expectedvotes_notification = (struct res_lib_votequorum_expectedvotes_notification *)dispatch_data;
- callbacks.votequorum_expectedvotes_notify_fn ( handle,
- res_lib_votequorum_expectedvotes_notification->context,
- res_lib_votequorum_expectedvotes_notification->expected_votes);
- break;
- default:
- error = CS_ERR_LIBRARY;
- goto error_put;
- break;
- }
- /*
- * Determine if more messages should be processed
- */
- if (dispatch_types == CS_DISPATCH_ONE || dispatch_types == CS_DISPATCH_ONE_NONBLOCKING) {
- cont = 0;
- }
- } while (cont);
- goto error_put;
- error_put:
- hdb_handle_put (&votequorum_handle_t_db, handle);
- return (error);
- }
- #ifdef EXPERIMENTAL_QUORUM_DEVICE_API
- cs_error_t votequorum_qdevice_register (
- votequorum_handle_t handle,
- const char *name,
- unsigned int votes)
- {
- cs_error_t error;
- struct votequorum_inst *votequorum_inst;
- struct iovec iov;
- struct req_lib_votequorum_qdevice_register req_lib_votequorum_qdevice_register;
- struct res_lib_votequorum_status res_lib_votequorum_status;
- if (strlen(name) >= VOTEQUORUM_MAX_QDEVICE_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_register.header.size = sizeof (struct req_lib_votequorum_qdevice_register);
- req_lib_votequorum_qdevice_register.header.id = MESSAGE_REQ_VOTEQUORUM_QDEVICE_REGISTER;
- strcpy(req_lib_votequorum_qdevice_register.name, name);
- req_lib_votequorum_qdevice_register.votes = votes;
- iov.iov_base = (char *)&req_lib_votequorum_qdevice_register;
- iov.iov_len = sizeof (struct req_lib_votequorum_qdevice_register);
- 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_poll (
- votequorum_handle_t handle,
- unsigned int state)
- {
- 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;
- 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;
- req_lib_votequorum_qdevice_poll.state = state;
- 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_unregister (
- 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_QDEVICE_UNREGISTER;
- 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);
- }
- cs_error_t votequorum_qdevice_getinfo (
- votequorum_handle_t handle,
- struct votequorum_qdevice_info *qinfo)
- {
- 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_qdevice_getinfo res_lib_votequorum_qdevice_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_general.header.size = sizeof (struct req_lib_votequorum_general);
- req_lib_votequorum_general.header.id = MESSAGE_REQ_VOTEQUORUM_QDEVICE_GETINFO;
- 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_qdevice_getinfo,
- sizeof (struct res_lib_votequorum_qdevice_getinfo), CS_IPC_TIMEOUT_MS));
- if (error != CS_OK) {
- goto error_exit;
- }
- error = res_lib_votequorum_qdevice_getinfo.header.error;
- qinfo->votes = res_lib_votequorum_qdevice_getinfo.votes;
- qinfo->state = res_lib_votequorum_qdevice_getinfo.state;
- strcpy(qinfo->name, res_lib_votequorum_qdevice_getinfo.name);
- error_exit:
- hdb_handle_put (&votequorum_handle_t_db, handle);
- return (error);
- }
- #endif
|