| 88 | } |
| 89 | |
| 90 | cs_error_t quorum_model_initialize ( |
| 91 | quorum_handle_t *handle, |
| 92 | quorum_model_t model, |
| 93 | quorum_model_data_t *model_data, |
| 94 | uint32_t *quorum_type, |
| 95 | void *context) |
| 96 | { |
| 97 | cs_error_t error; |
| 98 | struct quorum_inst *quorum_inst; |
| 99 | struct iovec iov; |
| 100 | struct qb_ipc_request_header quorum_gettype_req; |
| 101 | struct req_lib_quorum_model_gettype quorum_model_gettype_req; |
| 102 | struct res_lib_quorum_gettype res_lib_quorum_gettype; |
| 103 | struct res_lib_quorum_model_gettype res_lib_quorum_model_gettype; |
| 104 | uint32_t local_quorum_type; |
| 105 | |
| 106 | if (model != QUORUM_MODEL_V0 && model != QUORUM_MODEL_V1) { |
| 107 | error = CS_ERR_INVALID_PARAM; |
| 108 | goto error_no_destroy; |
| 109 | } |
| 110 | |
| 111 | error = hdb_error_to_cs(hdb_handle_create (&quorum_handle_t_db, sizeof (struct quorum_inst), handle)); |
| 112 | if (error != CS_OK) { |
| 113 | goto error_no_destroy; |
| 114 | } |
| 115 | |
| 116 | error = hdb_error_to_cs(hdb_handle_get (&quorum_handle_t_db, *handle, (void *)&quorum_inst)); |
| 117 | if (error != CS_OK) { |
| 118 | goto error_destroy; |
| 119 | } |
| 120 | |
| 121 | error = CS_OK; |
| 122 | quorum_inst->finalize = 0; |
| 123 | quorum_inst->c = qb_ipcc_connect ("quorum", IPC_REQUEST_SIZE); |
| 124 | if (quorum_inst->c == NULL) { |
| 125 | error = qb_to_cs_error(-errno); |
| 126 | goto error_put_destroy; |
| 127 | } |
| 128 | |
| 129 | switch (model) { |
| 130 | case QUORUM_MODEL_V0: |
| 131 | quorum_gettype_req.size = sizeof (quorum_gettype_req); |
| 132 | quorum_gettype_req.id = MESSAGE_REQ_QUORUM_GETTYPE; |
| 133 | |
| 134 | iov.iov_base = (char *)&quorum_gettype_req; |
| 135 | iov.iov_len = sizeof (quorum_gettype_req); |
| 136 | |
| 137 | error = qb_to_cs_error(qb_ipcc_sendv_recv ( |
| 138 | quorum_inst->c, |
| 139 | &iov, |
| 140 | 1, |
| 141 | &res_lib_quorum_gettype, |
| 142 | sizeof(res_lib_quorum_gettype), -1)); |
| 143 | |
| 144 | if (error != CS_OK) { |
| 145 | goto error_put_destroy; |
| 146 | } |
| 147 | error = res_lib_quorum_gettype.header.error; |