cpg.c 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188
  1. /*
  2. * vi: set autoindent tabstop=4 shiftwidth=4 :
  3. *
  4. * Copyright (c) 2006-2012 Red Hat, Inc.
  5. *
  6. * All rights reserved.
  7. *
  8. * Author: Christine Caulfield (ccaulfi@redhat.com)
  9. * Author: Jan Friesse (jfriesse@redhat.com)
  10. *
  11. * This software licensed under BSD license, the text of which follows:
  12. *
  13. * Redistribution and use in source and binary forms, with or without
  14. * modification, are permitted provided that the following conditions are met:
  15. *
  16. * - Redistributions of source code must retain the above copyright notice,
  17. * this list of conditions and the following disclaimer.
  18. * - Redistributions in binary form must reproduce the above copyright notice,
  19. * this list of conditions and the following disclaimer in the documentation
  20. * and/or other materials provided with the distribution.
  21. * - Neither the name of the MontaVista Software, Inc. nor the names of its
  22. * contributors may be used to endorse or promote products derived from this
  23. * software without specific prior written permission.
  24. *
  25. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  26. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  27. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  28. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  29. * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  30. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  31. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  32. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  33. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  34. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
  35. * THE POSSIBILITY OF SUCH DAMAGE.
  36. */
  37. /*
  38. * Provides a closed process group API using the coroipcc executive
  39. */
  40. #include <config.h>
  41. #include <stdlib.h>
  42. #include <stdio.h>
  43. #include <string.h>
  44. #include <unistd.h>
  45. #include <sys/types.h>
  46. #include <sys/socket.h>
  47. #include <sys/mman.h>
  48. #include <sys/uio.h>
  49. #include <sys/stat.h>
  50. #include <errno.h>
  51. #include <limits.h>
  52. #include <qb/qbdefs.h>
  53. #include <qb/qbipcc.h>
  54. #include <qb/qblog.h>
  55. #include <corosync/hdb.h>
  56. #include <corosync/list.h>
  57. #include <corosync/corotypes.h>
  58. #include <corosync/corodefs.h>
  59. #include <corosync/cpg.h>
  60. #include <corosync/ipc_cpg.h>
  61. #include "util.h"
  62. #ifndef MAP_ANONYMOUS
  63. #define MAP_ANONYMOUS MAP_ANON
  64. #endif
  65. /*
  66. * ZCB files have following umask (umask is same as used in libqb)
  67. */
  68. #define CPG_MEMORY_MAP_UMASK 077
  69. struct cpg_inst {
  70. qb_ipcc_connection_t *c;
  71. int finalize;
  72. void *context;
  73. union {
  74. cpg_model_data_t model_data;
  75. cpg_model_v1_data_t model_v1_data;
  76. };
  77. struct list_head iteration_list_head;
  78. };
  79. static void cpg_inst_free (void *inst);
  80. DECLARE_HDB_DATABASE(cpg_handle_t_db, cpg_inst_free);
  81. struct cpg_iteration_instance_t {
  82. cpg_iteration_handle_t cpg_iteration_handle;
  83. qb_ipcc_connection_t *conn;
  84. hdb_handle_t executive_iteration_handle;
  85. struct list_head list;
  86. };
  87. DECLARE_HDB_DATABASE(cpg_iteration_handle_t_db,NULL);
  88. /*
  89. * Internal (not visible by API) functions
  90. */
  91. static cs_error_t
  92. coroipcc_msg_send_reply_receive (
  93. qb_ipcc_connection_t *c,
  94. const struct iovec *iov,
  95. unsigned int iov_len,
  96. void *res_msg,
  97. size_t res_len)
  98. {
  99. return qb_to_cs_error(qb_ipcc_sendv_recv(c, iov, iov_len, res_msg, res_len,
  100. CS_IPC_TIMEOUT_MS));
  101. }
  102. static void cpg_iteration_instance_finalize (struct cpg_iteration_instance_t *cpg_iteration_instance)
  103. {
  104. list_del (&cpg_iteration_instance->list);
  105. hdb_handle_destroy (&cpg_iteration_handle_t_db, cpg_iteration_instance->cpg_iteration_handle);
  106. }
  107. static void cpg_inst_free (void *inst)
  108. {
  109. struct cpg_inst *cpg_inst = (struct cpg_inst *)inst;
  110. qb_ipcc_disconnect(cpg_inst->c);
  111. }
  112. static void cpg_inst_finalize (struct cpg_inst *cpg_inst, hdb_handle_t handle)
  113. {
  114. struct list_head *iter, *iter_next;
  115. struct cpg_iteration_instance_t *cpg_iteration_instance;
  116. /*
  117. * Traverse thru iteration instances and delete them
  118. */
  119. for (iter = cpg_inst->iteration_list_head.next; iter != &cpg_inst->iteration_list_head;iter = iter_next) {
  120. iter_next = iter->next;
  121. cpg_iteration_instance = list_entry (iter, struct cpg_iteration_instance_t, list);
  122. cpg_iteration_instance_finalize (cpg_iteration_instance);
  123. }
  124. hdb_handle_destroy (&cpg_handle_t_db, handle);
  125. }
  126. /**
  127. * @defgroup cpg_coroipcc The closed process group API
  128. * @ingroup coroipcc
  129. *
  130. * @{
  131. */
  132. cs_error_t cpg_initialize (
  133. cpg_handle_t *handle,
  134. cpg_callbacks_t *callbacks)
  135. {
  136. cpg_model_v1_data_t model_v1_data;
  137. memset (&model_v1_data, 0, sizeof (cpg_model_v1_data_t));
  138. if (callbacks) {
  139. model_v1_data.cpg_deliver_fn = callbacks->cpg_deliver_fn;
  140. model_v1_data.cpg_confchg_fn = callbacks->cpg_confchg_fn;
  141. }
  142. return (cpg_model_initialize (handle, CPG_MODEL_V1, (cpg_model_data_t *)&model_v1_data, NULL));
  143. }
  144. cs_error_t cpg_model_initialize (
  145. cpg_handle_t *handle,
  146. cpg_model_t model,
  147. cpg_model_data_t *model_data,
  148. void *context)
  149. {
  150. cs_error_t error;
  151. struct cpg_inst *cpg_inst;
  152. if (model != CPG_MODEL_V1) {
  153. error = CS_ERR_INVALID_PARAM;
  154. goto error_no_destroy;
  155. }
  156. error = hdb_error_to_cs (hdb_handle_create (&cpg_handle_t_db, sizeof (struct cpg_inst), handle));
  157. if (error != CS_OK) {
  158. goto error_no_destroy;
  159. }
  160. error = hdb_error_to_cs (hdb_handle_get (&cpg_handle_t_db, *handle, (void *)&cpg_inst));
  161. if (error != CS_OK) {
  162. goto error_destroy;
  163. }
  164. cpg_inst->c = qb_ipcc_connect ("cpg", IPC_REQUEST_SIZE);
  165. if (cpg_inst->c == NULL) {
  166. error = qb_to_cs_error(-errno);
  167. goto error_put_destroy;
  168. }
  169. if (model_data != NULL) {
  170. switch (model) {
  171. case CPG_MODEL_V1:
  172. memcpy (&cpg_inst->model_v1_data, model_data, sizeof (cpg_model_v1_data_t));
  173. if ((cpg_inst->model_v1_data.flags & ~(CPG_MODEL_V1_DELIVER_INITIAL_TOTEM_CONF)) != 0) {
  174. error = CS_ERR_INVALID_PARAM;
  175. goto error_destroy;
  176. }
  177. break;
  178. }
  179. }
  180. cpg_inst->model_data.model = model;
  181. cpg_inst->context = context;
  182. list_init(&cpg_inst->iteration_list_head);
  183. hdb_handle_put (&cpg_handle_t_db, *handle);
  184. return (CS_OK);
  185. error_put_destroy:
  186. hdb_handle_put (&cpg_handle_t_db, *handle);
  187. error_destroy:
  188. hdb_handle_destroy (&cpg_handle_t_db, *handle);
  189. error_no_destroy:
  190. return (error);
  191. }
  192. cs_error_t cpg_finalize (
  193. cpg_handle_t handle)
  194. {
  195. struct cpg_inst *cpg_inst;
  196. struct iovec iov;
  197. struct req_lib_cpg_finalize req_lib_cpg_finalize;
  198. struct res_lib_cpg_finalize res_lib_cpg_finalize;
  199. cs_error_t error;
  200. error = hdb_error_to_cs (hdb_handle_get (&cpg_handle_t_db, handle, (void *)&cpg_inst));
  201. if (error != CS_OK) {
  202. return (error);
  203. }
  204. /*
  205. * Another thread has already started finalizing
  206. */
  207. if (cpg_inst->finalize) {
  208. hdb_handle_put (&cpg_handle_t_db, handle);
  209. return (CS_ERR_BAD_HANDLE);
  210. }
  211. cpg_inst->finalize = 1;
  212. /*
  213. * Send service request
  214. */
  215. req_lib_cpg_finalize.header.size = sizeof (struct req_lib_cpg_finalize);
  216. req_lib_cpg_finalize.header.id = MESSAGE_REQ_CPG_FINALIZE;
  217. iov.iov_base = (void *)&req_lib_cpg_finalize;
  218. iov.iov_len = sizeof (struct req_lib_cpg_finalize);
  219. error = coroipcc_msg_send_reply_receive (cpg_inst->c,
  220. &iov,
  221. 1,
  222. &res_lib_cpg_finalize,
  223. sizeof (struct res_lib_cpg_finalize));
  224. cpg_inst_finalize (cpg_inst, handle);
  225. hdb_handle_put (&cpg_handle_t_db, handle);
  226. return (error);
  227. }
  228. cs_error_t cpg_fd_get (
  229. cpg_handle_t handle,
  230. int *fd)
  231. {
  232. cs_error_t error;
  233. struct cpg_inst *cpg_inst;
  234. error = hdb_error_to_cs (hdb_handle_get (&cpg_handle_t_db, handle, (void *)&cpg_inst));
  235. if (error != CS_OK) {
  236. return (error);
  237. }
  238. error = qb_to_cs_error (qb_ipcc_fd_get (cpg_inst->c, fd));
  239. hdb_handle_put (&cpg_handle_t_db, handle);
  240. return (error);
  241. }
  242. cs_error_t cpg_context_get (
  243. cpg_handle_t handle,
  244. void **context)
  245. {
  246. cs_error_t error;
  247. struct cpg_inst *cpg_inst;
  248. error = hdb_error_to_cs (hdb_handle_get (&cpg_handle_t_db, handle, (void *)&cpg_inst));
  249. if (error != CS_OK) {
  250. return (error);
  251. }
  252. *context = cpg_inst->context;
  253. hdb_handle_put (&cpg_handle_t_db, handle);
  254. return (CS_OK);
  255. }
  256. cs_error_t cpg_context_set (
  257. cpg_handle_t handle,
  258. void *context)
  259. {
  260. cs_error_t error;
  261. struct cpg_inst *cpg_inst;
  262. error = hdb_error_to_cs (hdb_handle_get (&cpg_handle_t_db, handle, (void *)&cpg_inst));
  263. if (error != CS_OK) {
  264. return (error);
  265. }
  266. cpg_inst->context = context;
  267. hdb_handle_put (&cpg_handle_t_db, handle);
  268. return (CS_OK);
  269. }
  270. cs_error_t cpg_dispatch (
  271. cpg_handle_t handle,
  272. cs_dispatch_flags_t dispatch_types)
  273. {
  274. int timeout = -1;
  275. cs_error_t error;
  276. int cont = 1; /* always continue do loop except when set to 0 */
  277. struct cpg_inst *cpg_inst;
  278. struct res_lib_cpg_confchg_callback *res_cpg_confchg_callback;
  279. struct res_lib_cpg_deliver_callback *res_cpg_deliver_callback;
  280. struct res_lib_cpg_totem_confchg_callback *res_cpg_totem_confchg_callback;
  281. struct cpg_inst cpg_inst_copy;
  282. struct qb_ipc_response_header *dispatch_data;
  283. struct cpg_address member_list[CPG_MEMBERS_MAX];
  284. struct cpg_address left_list[CPG_MEMBERS_MAX];
  285. struct cpg_address joined_list[CPG_MEMBERS_MAX];
  286. struct cpg_name group_name;
  287. mar_cpg_address_t *left_list_start;
  288. mar_cpg_address_t *joined_list_start;
  289. unsigned int i;
  290. struct cpg_ring_id ring_id;
  291. uint32_t totem_member_list[CPG_MEMBERS_MAX];
  292. int32_t errno_res;
  293. char dispatch_buf[IPC_DISPATCH_SIZE];
  294. error = hdb_error_to_cs (hdb_handle_get (&cpg_handle_t_db, handle, (void *)&cpg_inst));
  295. if (error != CS_OK) {
  296. return (error);
  297. }
  298. /*
  299. * Timeout instantly for CS_DISPATCH_ONE_NONBLOCKING or CS_DISPATCH_ALL and
  300. * wait indefinately for CS_DISPATCH_ONE or CS_DISPATCH_BLOCKING
  301. */
  302. if (dispatch_types == CS_DISPATCH_ALL || dispatch_types == CS_DISPATCH_ONE_NONBLOCKING) {
  303. timeout = 0;
  304. }
  305. dispatch_data = (struct qb_ipc_response_header *)dispatch_buf;
  306. do {
  307. errno_res = qb_ipcc_event_recv (
  308. cpg_inst->c,
  309. dispatch_buf,
  310. IPC_DISPATCH_SIZE,
  311. timeout);
  312. error = qb_to_cs_error (errno_res);
  313. if (error == CS_ERR_BAD_HANDLE) {
  314. error = CS_OK;
  315. goto error_put;
  316. }
  317. if (error == CS_ERR_TRY_AGAIN) {
  318. if (dispatch_types == CS_DISPATCH_ONE_NONBLOCKING) {
  319. /*
  320. * Don't mask error
  321. */
  322. goto error_put;
  323. }
  324. error = CS_OK;
  325. if (dispatch_types == CS_DISPATCH_ALL) {
  326. break; /* exit do while cont is 1 loop */
  327. } else {
  328. continue; /* next poll */
  329. }
  330. }
  331. if (error != CS_OK) {
  332. goto error_put;
  333. }
  334. /*
  335. * Make copy of callbacks, message data, unlock instance, and call callback
  336. * A risk of this dispatch method is that the callback routines may
  337. * operate at the same time that cpgFinalize has been called.
  338. */
  339. memcpy (&cpg_inst_copy, cpg_inst, sizeof (struct cpg_inst));
  340. switch (cpg_inst_copy.model_data.model) {
  341. case CPG_MODEL_V1:
  342. /*
  343. * Dispatch incoming message
  344. */
  345. switch (dispatch_data->id) {
  346. case MESSAGE_RES_CPG_DELIVER_CALLBACK:
  347. if (cpg_inst_copy.model_v1_data.cpg_deliver_fn == NULL) {
  348. break;
  349. }
  350. res_cpg_deliver_callback = (struct res_lib_cpg_deliver_callback *)dispatch_data;
  351. marshall_from_mar_cpg_name_t (
  352. &group_name,
  353. &res_cpg_deliver_callback->group_name);
  354. cpg_inst_copy.model_v1_data.cpg_deliver_fn (handle,
  355. &group_name,
  356. res_cpg_deliver_callback->nodeid,
  357. res_cpg_deliver_callback->pid,
  358. &res_cpg_deliver_callback->message,
  359. res_cpg_deliver_callback->msglen);
  360. break;
  361. case MESSAGE_RES_CPG_CONFCHG_CALLBACK:
  362. if (cpg_inst_copy.model_v1_data.cpg_confchg_fn == NULL) {
  363. break;
  364. }
  365. res_cpg_confchg_callback = (struct res_lib_cpg_confchg_callback *)dispatch_data;
  366. for (i = 0; i < res_cpg_confchg_callback->member_list_entries; i++) {
  367. marshall_from_mar_cpg_address_t (&member_list[i],
  368. &res_cpg_confchg_callback->member_list[i]);
  369. }
  370. left_list_start = res_cpg_confchg_callback->member_list +
  371. res_cpg_confchg_callback->member_list_entries;
  372. for (i = 0; i < res_cpg_confchg_callback->left_list_entries; i++) {
  373. marshall_from_mar_cpg_address_t (&left_list[i],
  374. &left_list_start[i]);
  375. }
  376. joined_list_start = res_cpg_confchg_callback->member_list +
  377. res_cpg_confchg_callback->member_list_entries +
  378. res_cpg_confchg_callback->left_list_entries;
  379. for (i = 0; i < res_cpg_confchg_callback->joined_list_entries; i++) {
  380. marshall_from_mar_cpg_address_t (&joined_list[i],
  381. &joined_list_start[i]);
  382. }
  383. marshall_from_mar_cpg_name_t (
  384. &group_name,
  385. &res_cpg_confchg_callback->group_name);
  386. cpg_inst_copy.model_v1_data.cpg_confchg_fn (handle,
  387. &group_name,
  388. member_list,
  389. res_cpg_confchg_callback->member_list_entries,
  390. left_list,
  391. res_cpg_confchg_callback->left_list_entries,
  392. joined_list,
  393. res_cpg_confchg_callback->joined_list_entries);
  394. break;
  395. case MESSAGE_RES_CPG_TOTEM_CONFCHG_CALLBACK:
  396. if (cpg_inst_copy.model_v1_data.cpg_totem_confchg_fn == NULL) {
  397. break;
  398. }
  399. res_cpg_totem_confchg_callback = (struct res_lib_cpg_totem_confchg_callback *)dispatch_data;
  400. marshall_from_mar_cpg_ring_id_t (&ring_id, &res_cpg_totem_confchg_callback->ring_id);
  401. for (i = 0; i < res_cpg_totem_confchg_callback->member_list_entries; i++) {
  402. totem_member_list[i] = res_cpg_totem_confchg_callback->member_list[i];
  403. }
  404. cpg_inst_copy.model_v1_data.cpg_totem_confchg_fn (handle,
  405. ring_id,
  406. res_cpg_totem_confchg_callback->member_list_entries,
  407. totem_member_list);
  408. break;
  409. default:
  410. error = CS_ERR_LIBRARY;
  411. goto error_put;
  412. break;
  413. } /* - switch (dispatch_data->id) */
  414. break; /* case CPG_MODEL_V1 */
  415. } /* - switch (cpg_inst_copy.model_data.model) */
  416. if (cpg_inst_copy.finalize || cpg_inst->finalize) {
  417. /*
  418. * If the finalize has been called then get out of the dispatch.
  419. */
  420. cpg_inst->finalize = 1;
  421. error = CS_ERR_BAD_HANDLE;
  422. goto error_put;
  423. }
  424. /*
  425. * Determine if more messages should be processed
  426. */
  427. if (dispatch_types == CS_DISPATCH_ONE || dispatch_types == CS_DISPATCH_ONE_NONBLOCKING) {
  428. cont = 0;
  429. }
  430. } while (cont);
  431. error_put:
  432. hdb_handle_put (&cpg_handle_t_db, handle);
  433. return (error);
  434. }
  435. cs_error_t cpg_join (
  436. cpg_handle_t handle,
  437. const struct cpg_name *group)
  438. {
  439. cs_error_t error;
  440. struct cpg_inst *cpg_inst;
  441. struct iovec iov[2];
  442. struct req_lib_cpg_join req_lib_cpg_join;
  443. struct res_lib_cpg_join response;
  444. if (group->length > CPG_MAX_NAME_LENGTH) {
  445. return (CS_ERR_NAME_TOO_LONG);
  446. }
  447. error = hdb_error_to_cs (hdb_handle_get (&cpg_handle_t_db, handle, (void *)&cpg_inst));
  448. if (error != CS_OK) {
  449. return (error);
  450. }
  451. /* Now join */
  452. req_lib_cpg_join.header.size = sizeof (struct req_lib_cpg_join);
  453. req_lib_cpg_join.header.id = MESSAGE_REQ_CPG_JOIN;
  454. req_lib_cpg_join.pid = getpid();
  455. req_lib_cpg_join.flags = 0;
  456. switch (cpg_inst->model_data.model) {
  457. case CPG_MODEL_V1:
  458. req_lib_cpg_join.flags = cpg_inst->model_v1_data.flags;
  459. break;
  460. }
  461. marshall_to_mar_cpg_name_t (&req_lib_cpg_join.group_name,
  462. group);
  463. iov[0].iov_base = (void *)&req_lib_cpg_join;
  464. iov[0].iov_len = sizeof (struct req_lib_cpg_join);
  465. do {
  466. error = coroipcc_msg_send_reply_receive (cpg_inst->c, iov, 1,
  467. &response, sizeof (struct res_lib_cpg_join));
  468. if (error != CS_OK) {
  469. goto error_exit;
  470. }
  471. } while (response.header.error == CS_ERR_BUSY);
  472. error = response.header.error;
  473. error_exit:
  474. hdb_handle_put (&cpg_handle_t_db, handle);
  475. return (error);
  476. }
  477. cs_error_t cpg_leave (
  478. cpg_handle_t handle,
  479. const struct cpg_name *group)
  480. {
  481. cs_error_t error;
  482. struct cpg_inst *cpg_inst;
  483. struct iovec iov[2];
  484. struct req_lib_cpg_leave req_lib_cpg_leave;
  485. struct res_lib_cpg_leave res_lib_cpg_leave;
  486. if (group->length > CPG_MAX_NAME_LENGTH) {
  487. return (CS_ERR_NAME_TOO_LONG);
  488. }
  489. error = hdb_error_to_cs (hdb_handle_get (&cpg_handle_t_db, handle, (void *)&cpg_inst));
  490. if (error != CS_OK) {
  491. return (error);
  492. }
  493. req_lib_cpg_leave.header.size = sizeof (struct req_lib_cpg_leave);
  494. req_lib_cpg_leave.header.id = MESSAGE_REQ_CPG_LEAVE;
  495. req_lib_cpg_leave.pid = getpid();
  496. marshall_to_mar_cpg_name_t (&req_lib_cpg_leave.group_name,
  497. group);
  498. iov[0].iov_base = (void *)&req_lib_cpg_leave;
  499. iov[0].iov_len = sizeof (struct req_lib_cpg_leave);
  500. do {
  501. error = coroipcc_msg_send_reply_receive (cpg_inst->c, iov, 1,
  502. &res_lib_cpg_leave, sizeof (struct res_lib_cpg_leave));
  503. if (error != CS_OK) {
  504. goto error_exit;
  505. }
  506. } while (res_lib_cpg_leave.header.error == CS_ERR_BUSY);
  507. error = res_lib_cpg_leave.header.error;
  508. error_exit:
  509. hdb_handle_put (&cpg_handle_t_db, handle);
  510. return (error);
  511. }
  512. cs_error_t cpg_membership_get (
  513. cpg_handle_t handle,
  514. struct cpg_name *group_name,
  515. struct cpg_address *member_list,
  516. int *member_list_entries)
  517. {
  518. cs_error_t error;
  519. struct cpg_inst *cpg_inst;
  520. struct iovec iov;
  521. struct req_lib_cpg_membership_get req_lib_cpg_membership_get;
  522. struct res_lib_cpg_membership_get res_lib_cpg_membership_get;
  523. unsigned int i;
  524. if (group_name->length > CPG_MAX_NAME_LENGTH) {
  525. return (CS_ERR_NAME_TOO_LONG);
  526. }
  527. if (member_list == NULL) {
  528. return (CS_ERR_INVALID_PARAM);
  529. }
  530. if (member_list_entries == NULL) {
  531. return (CS_ERR_INVALID_PARAM);
  532. }
  533. error = hdb_error_to_cs (hdb_handle_get (&cpg_handle_t_db, handle, (void *)&cpg_inst));
  534. if (error != CS_OK) {
  535. return (error);
  536. }
  537. req_lib_cpg_membership_get.header.size = sizeof (struct req_lib_cpg_membership_get);
  538. req_lib_cpg_membership_get.header.id = MESSAGE_REQ_CPG_MEMBERSHIP;
  539. marshall_to_mar_cpg_name_t (&req_lib_cpg_membership_get.group_name,
  540. group_name);
  541. iov.iov_base = (void *)&req_lib_cpg_membership_get;
  542. iov.iov_len = sizeof (struct req_lib_cpg_membership_get);
  543. error = coroipcc_msg_send_reply_receive (cpg_inst->c, &iov, 1,
  544. &res_lib_cpg_membership_get, sizeof (res_lib_cpg_membership_get));
  545. if (error != CS_OK) {
  546. goto error_exit;
  547. }
  548. error = res_lib_cpg_membership_get.header.error;
  549. /*
  550. * Copy results to caller
  551. */
  552. *member_list_entries = res_lib_cpg_membership_get.member_count;
  553. if (member_list) {
  554. for (i = 0; i < res_lib_cpg_membership_get.member_count; i++) {
  555. marshall_from_mar_cpg_address_t (&member_list[i],
  556. &res_lib_cpg_membership_get.member_list[i]);
  557. }
  558. }
  559. error_exit:
  560. hdb_handle_put (&cpg_handle_t_db, handle);
  561. return (error);
  562. }
  563. cs_error_t cpg_local_get (
  564. cpg_handle_t handle,
  565. unsigned int *local_nodeid)
  566. {
  567. cs_error_t error;
  568. struct cpg_inst *cpg_inst;
  569. struct iovec iov;
  570. struct req_lib_cpg_local_get req_lib_cpg_local_get;
  571. struct res_lib_cpg_local_get res_lib_cpg_local_get;
  572. error = hdb_error_to_cs (hdb_handle_get (&cpg_handle_t_db, handle, (void *)&cpg_inst));
  573. if (error != CS_OK) {
  574. return (error);
  575. }
  576. req_lib_cpg_local_get.header.size = sizeof (struct qb_ipc_request_header);
  577. req_lib_cpg_local_get.header.id = MESSAGE_REQ_CPG_LOCAL_GET;
  578. iov.iov_base = (void *)&req_lib_cpg_local_get;
  579. iov.iov_len = sizeof (struct req_lib_cpg_local_get);
  580. error = coroipcc_msg_send_reply_receive (cpg_inst->c, &iov, 1,
  581. &res_lib_cpg_local_get, sizeof (res_lib_cpg_local_get));
  582. if (error != CS_OK) {
  583. goto error_exit;
  584. }
  585. error = res_lib_cpg_local_get.header.error;
  586. *local_nodeid = res_lib_cpg_local_get.local_nodeid;
  587. error_exit:
  588. hdb_handle_put (&cpg_handle_t_db, handle);
  589. return (error);
  590. }
  591. cs_error_t cpg_flow_control_state_get (
  592. cpg_handle_t handle,
  593. cpg_flow_control_state_t *flow_control_state)
  594. {
  595. cs_error_t error;
  596. struct cpg_inst *cpg_inst;
  597. error = hdb_error_to_cs (hdb_handle_get (&cpg_handle_t_db, handle, (void *)&cpg_inst));
  598. if (error != CS_OK) {
  599. return (error);
  600. }
  601. *flow_control_state = CPG_FLOW_CONTROL_DISABLED;
  602. error = CS_OK;
  603. hdb_handle_put (&cpg_handle_t_db, handle);
  604. return (error);
  605. }
  606. static int
  607. memory_map (char *path, const char *file, void **buf, size_t bytes)
  608. {
  609. int32_t fd;
  610. void *addr;
  611. int32_t res;
  612. char *buffer;
  613. int32_t i;
  614. size_t written;
  615. size_t page_size;
  616. long int sysconf_page_size;
  617. mode_t old_umask;
  618. snprintf (path, PATH_MAX, "/dev/shm/%s", file);
  619. old_umask = umask(CPG_MEMORY_MAP_UMASK);
  620. fd = mkstemp (path);
  621. (void)umask(old_umask);
  622. if (fd == -1) {
  623. snprintf (path, PATH_MAX, LOCALSTATEDIR "/run/%s", file);
  624. old_umask = umask(CPG_MEMORY_MAP_UMASK);
  625. fd = mkstemp (path);
  626. (void)umask(old_umask);
  627. if (fd == -1) {
  628. return (-1);
  629. }
  630. }
  631. res = ftruncate (fd, bytes);
  632. if (res == -1) {
  633. goto error_close_unlink;
  634. }
  635. sysconf_page_size = sysconf(_SC_PAGESIZE);
  636. if (sysconf_page_size <= 0) {
  637. goto error_close_unlink;
  638. }
  639. page_size = sysconf_page_size;
  640. buffer = malloc (page_size);
  641. if (buffer == NULL) {
  642. goto error_close_unlink;
  643. }
  644. memset (buffer, 0, page_size);
  645. for (i = 0; i < (bytes / page_size); i++) {
  646. retry_write:
  647. written = write (fd, buffer, page_size);
  648. if (written == -1 && errno == EINTR) {
  649. goto retry_write;
  650. }
  651. if (written != page_size) {
  652. free (buffer);
  653. goto error_close_unlink;
  654. }
  655. }
  656. free (buffer);
  657. addr = mmap (NULL, bytes, PROT_READ | PROT_WRITE,
  658. MAP_SHARED, fd, 0);
  659. if (addr == MAP_FAILED) {
  660. goto error_close_unlink;
  661. }
  662. #ifdef MADV_NOSYNC
  663. madvise(addr, bytes, MADV_NOSYNC);
  664. #endif
  665. res = close (fd);
  666. if (res) {
  667. return (-1);
  668. }
  669. *buf = addr;
  670. return 0;
  671. error_close_unlink:
  672. close (fd);
  673. unlink(path);
  674. return -1;
  675. }
  676. cs_error_t cpg_zcb_alloc (
  677. cpg_handle_t handle,
  678. size_t size,
  679. void **buffer)
  680. {
  681. void *buf = NULL;
  682. char path[PATH_MAX];
  683. mar_req_coroipcc_zc_alloc_t req_coroipcc_zc_alloc;
  684. struct qb_ipc_response_header res_coroipcs_zc_alloc;
  685. size_t map_size;
  686. struct iovec iovec;
  687. struct coroipcs_zc_header *hdr;
  688. cs_error_t error;
  689. struct cpg_inst *cpg_inst;
  690. error = hdb_error_to_cs (hdb_handle_get (&cpg_handle_t_db, handle, (void *)&cpg_inst));
  691. if (error != CS_OK) {
  692. return (error);
  693. }
  694. map_size = size + sizeof (struct req_lib_cpg_mcast) + sizeof (struct coroipcs_zc_header);
  695. assert(memory_map (path, "corosync_zerocopy-XXXXXX", &buf, map_size) != -1);
  696. if (strlen(path) >= CPG_ZC_PATH_LEN) {
  697. unlink(path);
  698. munmap (buf, map_size);
  699. return (CS_ERR_NAME_TOO_LONG);
  700. }
  701. req_coroipcc_zc_alloc.header.size = sizeof (mar_req_coroipcc_zc_alloc_t);
  702. req_coroipcc_zc_alloc.header.id = MESSAGE_REQ_CPG_ZC_ALLOC;
  703. req_coroipcc_zc_alloc.map_size = map_size;
  704. strcpy (req_coroipcc_zc_alloc.path_to_file, path);
  705. iovec.iov_base = (void *)&req_coroipcc_zc_alloc;
  706. iovec.iov_len = sizeof (mar_req_coroipcc_zc_alloc_t);
  707. error = coroipcc_msg_send_reply_receive (
  708. cpg_inst->c,
  709. &iovec,
  710. 1,
  711. &res_coroipcs_zc_alloc,
  712. sizeof (struct qb_ipc_response_header));
  713. hdr = (struct coroipcs_zc_header *)buf;
  714. hdr->map_size = map_size;
  715. *buffer = ((char *)buf) + sizeof (struct coroipcs_zc_header);
  716. hdb_handle_put (&cpg_handle_t_db, handle);
  717. *buffer = ((char *)*buffer) + sizeof (struct req_lib_cpg_mcast);
  718. return (error);
  719. }
  720. cs_error_t cpg_zcb_free (
  721. cpg_handle_t handle,
  722. void *buffer)
  723. {
  724. cs_error_t error;
  725. struct cpg_inst *cpg_inst;
  726. mar_req_coroipcc_zc_free_t req_coroipcc_zc_free;
  727. struct qb_ipc_response_header res_coroipcs_zc_free;
  728. struct iovec iovec;
  729. struct coroipcs_zc_header *header = (struct coroipcs_zc_header *)((char *)buffer - sizeof (struct coroipcs_zc_header));
  730. error = hdb_error_to_cs (hdb_handle_get (&cpg_handle_t_db, handle, (void *)&cpg_inst));
  731. if (error != CS_OK) {
  732. return (error);
  733. }
  734. req_coroipcc_zc_free.header.size = sizeof (mar_req_coroipcc_zc_free_t);
  735. req_coroipcc_zc_free.header.id = MESSAGE_REQ_CPG_ZC_FREE;
  736. req_coroipcc_zc_free.map_size = header->map_size;
  737. req_coroipcc_zc_free.server_address = header->server_address;
  738. iovec.iov_base = (void *)&req_coroipcc_zc_free;
  739. iovec.iov_len = sizeof (mar_req_coroipcc_zc_free_t);
  740. error = coroipcc_msg_send_reply_receive (
  741. cpg_inst->c,
  742. &iovec,
  743. 1,
  744. &res_coroipcs_zc_free,
  745. sizeof (struct qb_ipc_response_header));
  746. munmap ((void *)header, header->map_size);
  747. hdb_handle_put (&cpg_handle_t_db, handle);
  748. return (error);
  749. }
  750. cs_error_t cpg_zcb_mcast_joined (
  751. cpg_handle_t handle,
  752. cpg_guarantee_t guarantee,
  753. void *msg,
  754. size_t msg_len)
  755. {
  756. cs_error_t error;
  757. struct cpg_inst *cpg_inst;
  758. struct req_lib_cpg_mcast *req_lib_cpg_mcast;
  759. struct res_lib_cpg_mcast res_lib_cpg_mcast;
  760. mar_req_coroipcc_zc_execute_t req_coroipcc_zc_execute;
  761. struct coroipcs_zc_header *hdr;
  762. struct iovec iovec;
  763. error = hdb_error_to_cs (hdb_handle_get (&cpg_handle_t_db, handle, (void *)&cpg_inst));
  764. if (error != CS_OK) {
  765. return (error);
  766. }
  767. req_lib_cpg_mcast = (struct req_lib_cpg_mcast *)(((char *)msg) - sizeof (struct req_lib_cpg_mcast));
  768. req_lib_cpg_mcast->header.size = sizeof (struct req_lib_cpg_mcast) +
  769. msg_len;
  770. req_lib_cpg_mcast->header.id = MESSAGE_REQ_CPG_MCAST;
  771. req_lib_cpg_mcast->guarantee = guarantee;
  772. req_lib_cpg_mcast->msglen = msg_len;
  773. hdr = (struct coroipcs_zc_header *)(((char *)req_lib_cpg_mcast) - sizeof (struct coroipcs_zc_header));
  774. req_coroipcc_zc_execute.header.size = sizeof (mar_req_coroipcc_zc_execute_t);
  775. req_coroipcc_zc_execute.header.id = MESSAGE_REQ_CPG_ZC_EXECUTE;
  776. req_coroipcc_zc_execute.server_address = hdr->server_address;
  777. iovec.iov_base = (void *)&req_coroipcc_zc_execute;
  778. iovec.iov_len = sizeof (mar_req_coroipcc_zc_execute_t);
  779. error = coroipcc_msg_send_reply_receive (
  780. cpg_inst->c,
  781. &iovec,
  782. 1,
  783. &res_lib_cpg_mcast,
  784. sizeof(res_lib_cpg_mcast));
  785. if (error != CS_OK) {
  786. goto error_exit;
  787. }
  788. error = res_lib_cpg_mcast.header.error;
  789. error_exit:
  790. hdb_handle_put (&cpg_handle_t_db, handle);
  791. return (error);
  792. }
  793. cs_error_t cpg_mcast_joined (
  794. cpg_handle_t handle,
  795. cpg_guarantee_t guarantee,
  796. const struct iovec *iovec,
  797. unsigned int iov_len)
  798. {
  799. int i;
  800. cs_error_t error;
  801. struct cpg_inst *cpg_inst;
  802. struct iovec iov[64];
  803. struct req_lib_cpg_mcast req_lib_cpg_mcast;
  804. size_t msg_len = 0;
  805. error = hdb_error_to_cs (hdb_handle_get (&cpg_handle_t_db, handle, (void *)&cpg_inst));
  806. if (error != CS_OK) {
  807. return (error);
  808. }
  809. for (i = 0; i < iov_len; i++ ) {
  810. msg_len += iovec[i].iov_len;
  811. }
  812. req_lib_cpg_mcast.header.size = sizeof (struct req_lib_cpg_mcast) +
  813. msg_len;
  814. req_lib_cpg_mcast.header.id = MESSAGE_REQ_CPG_MCAST;
  815. req_lib_cpg_mcast.guarantee = guarantee;
  816. req_lib_cpg_mcast.msglen = msg_len;
  817. iov[0].iov_base = (void *)&req_lib_cpg_mcast;
  818. iov[0].iov_len = sizeof (struct req_lib_cpg_mcast);
  819. memcpy (&iov[1], iovec, iov_len * sizeof (struct iovec));
  820. qb_ipcc_fc_enable_max_set(cpg_inst->c, 2);
  821. error = qb_to_cs_error(qb_ipcc_sendv(cpg_inst->c, iov, iov_len + 1));
  822. qb_ipcc_fc_enable_max_set(cpg_inst->c, 1);
  823. hdb_handle_put (&cpg_handle_t_db, handle);
  824. return (error);
  825. }
  826. cs_error_t cpg_iteration_initialize(
  827. cpg_handle_t handle,
  828. cpg_iteration_type_t iteration_type,
  829. const struct cpg_name *group,
  830. cpg_iteration_handle_t *cpg_iteration_handle)
  831. {
  832. cs_error_t error;
  833. struct iovec iov;
  834. struct cpg_inst *cpg_inst;
  835. struct cpg_iteration_instance_t *cpg_iteration_instance;
  836. struct req_lib_cpg_iterationinitialize req_lib_cpg_iterationinitialize;
  837. struct res_lib_cpg_iterationinitialize res_lib_cpg_iterationinitialize;
  838. if (group && group->length > CPG_MAX_NAME_LENGTH) {
  839. return (CS_ERR_NAME_TOO_LONG);
  840. }
  841. if (cpg_iteration_handle == NULL) {
  842. return (CS_ERR_INVALID_PARAM);
  843. }
  844. if ((iteration_type == CPG_ITERATION_ONE_GROUP && group == NULL) ||
  845. (iteration_type != CPG_ITERATION_ONE_GROUP && group != NULL)) {
  846. return (CS_ERR_INVALID_PARAM);
  847. }
  848. if (iteration_type != CPG_ITERATION_NAME_ONLY && iteration_type != CPG_ITERATION_ONE_GROUP &&
  849. iteration_type != CPG_ITERATION_ALL) {
  850. return (CS_ERR_INVALID_PARAM);
  851. }
  852. error = hdb_error_to_cs (hdb_handle_get (&cpg_handle_t_db, handle, (void *)&cpg_inst));
  853. if (error != CS_OK) {
  854. return (error);
  855. }
  856. error = hdb_error_to_cs (hdb_handle_create (&cpg_iteration_handle_t_db,
  857. sizeof (struct cpg_iteration_instance_t), cpg_iteration_handle));
  858. if (error != CS_OK) {
  859. goto error_put_cpg_db;
  860. }
  861. error = hdb_error_to_cs (hdb_handle_get (&cpg_iteration_handle_t_db, *cpg_iteration_handle,
  862. (void *)&cpg_iteration_instance));
  863. if (error != CS_OK) {
  864. goto error_destroy;
  865. }
  866. cpg_iteration_instance->conn = cpg_inst->c;
  867. list_init (&cpg_iteration_instance->list);
  868. req_lib_cpg_iterationinitialize.header.size = sizeof (struct req_lib_cpg_iterationinitialize);
  869. req_lib_cpg_iterationinitialize.header.id = MESSAGE_REQ_CPG_ITERATIONINITIALIZE;
  870. req_lib_cpg_iterationinitialize.iteration_type = iteration_type;
  871. if (group) {
  872. marshall_to_mar_cpg_name_t (&req_lib_cpg_iterationinitialize.group_name, group);
  873. }
  874. iov.iov_base = (void *)&req_lib_cpg_iterationinitialize;
  875. iov.iov_len = sizeof (struct req_lib_cpg_iterationinitialize);
  876. error = coroipcc_msg_send_reply_receive (cpg_inst->c,
  877. &iov,
  878. 1,
  879. &res_lib_cpg_iterationinitialize,
  880. sizeof (struct res_lib_cpg_iterationinitialize));
  881. if (error != CS_OK) {
  882. goto error_put_destroy;
  883. }
  884. cpg_iteration_instance->executive_iteration_handle =
  885. res_lib_cpg_iterationinitialize.iteration_handle;
  886. cpg_iteration_instance->cpg_iteration_handle = *cpg_iteration_handle;
  887. list_add (&cpg_iteration_instance->list, &cpg_inst->iteration_list_head);
  888. hdb_handle_put (&cpg_iteration_handle_t_db, *cpg_iteration_handle);
  889. hdb_handle_put (&cpg_handle_t_db, handle);
  890. return (res_lib_cpg_iterationinitialize.header.error);
  891. error_put_destroy:
  892. hdb_handle_put (&cpg_iteration_handle_t_db, *cpg_iteration_handle);
  893. error_destroy:
  894. hdb_handle_destroy (&cpg_iteration_handle_t_db, *cpg_iteration_handle);
  895. error_put_cpg_db:
  896. hdb_handle_put (&cpg_handle_t_db, handle);
  897. return (error);
  898. }
  899. cs_error_t cpg_iteration_next(
  900. cpg_iteration_handle_t handle,
  901. struct cpg_iteration_description_t *description)
  902. {
  903. cs_error_t error;
  904. struct cpg_iteration_instance_t *cpg_iteration_instance;
  905. struct req_lib_cpg_iterationnext req_lib_cpg_iterationnext;
  906. struct res_lib_cpg_iterationnext res_lib_cpg_iterationnext;
  907. if (description == NULL) {
  908. return CS_ERR_INVALID_PARAM;
  909. }
  910. error = hdb_error_to_cs (hdb_handle_get (&cpg_iteration_handle_t_db, handle,
  911. (void *)&cpg_iteration_instance));
  912. if (error != CS_OK) {
  913. goto error_exit;
  914. }
  915. req_lib_cpg_iterationnext.header.size = sizeof (struct req_lib_cpg_iterationnext);
  916. req_lib_cpg_iterationnext.header.id = MESSAGE_REQ_CPG_ITERATIONNEXT;
  917. req_lib_cpg_iterationnext.iteration_handle = cpg_iteration_instance->executive_iteration_handle;
  918. error = qb_to_cs_error (qb_ipcc_send (cpg_iteration_instance->conn,
  919. &req_lib_cpg_iterationnext,
  920. req_lib_cpg_iterationnext.header.size));
  921. if (error != CS_OK) {
  922. goto error_put;
  923. }
  924. error = qb_to_cs_error (qb_ipcc_recv (cpg_iteration_instance->conn,
  925. &res_lib_cpg_iterationnext,
  926. sizeof(struct res_lib_cpg_iterationnext), -1));
  927. if (error != CS_OK) {
  928. goto error_put;
  929. }
  930. marshall_from_mar_cpg_iteration_description_t(
  931. description,
  932. &res_lib_cpg_iterationnext.description);
  933. error = res_lib_cpg_iterationnext.header.error;
  934. error_put:
  935. hdb_handle_put (&cpg_iteration_handle_t_db, handle);
  936. error_exit:
  937. return (error);
  938. }
  939. cs_error_t cpg_iteration_finalize (
  940. cpg_iteration_handle_t handle)
  941. {
  942. cs_error_t error;
  943. struct iovec iov;
  944. struct cpg_iteration_instance_t *cpg_iteration_instance;
  945. struct req_lib_cpg_iterationfinalize req_lib_cpg_iterationfinalize;
  946. struct res_lib_cpg_iterationfinalize res_lib_cpg_iterationfinalize;
  947. error = hdb_error_to_cs (hdb_handle_get (&cpg_iteration_handle_t_db, handle,
  948. (void *)&cpg_iteration_instance));
  949. if (error != CS_OK) {
  950. goto error_exit;
  951. }
  952. req_lib_cpg_iterationfinalize.header.size = sizeof (struct req_lib_cpg_iterationfinalize);
  953. req_lib_cpg_iterationfinalize.header.id = MESSAGE_REQ_CPG_ITERATIONFINALIZE;
  954. req_lib_cpg_iterationfinalize.iteration_handle = cpg_iteration_instance->executive_iteration_handle;
  955. iov.iov_base = (void *)&req_lib_cpg_iterationfinalize;
  956. iov.iov_len = sizeof (struct req_lib_cpg_iterationfinalize);
  957. error = coroipcc_msg_send_reply_receive (cpg_iteration_instance->conn,
  958. &iov,
  959. 1,
  960. &res_lib_cpg_iterationfinalize,
  961. sizeof (struct req_lib_cpg_iterationfinalize));
  962. if (error != CS_OK) {
  963. goto error_put;
  964. }
  965. cpg_iteration_instance_finalize (cpg_iteration_instance);
  966. hdb_handle_put (&cpg_iteration_handle_t_db, cpg_iteration_instance->cpg_iteration_handle);
  967. return (res_lib_cpg_iterationfinalize.header.error);
  968. error_put:
  969. hdb_handle_put (&cpg_iteration_handle_t_db, handle);
  970. error_exit:
  971. return (error);
  972. }
  973. /** @} */