cpg.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647
  1. /*
  2. * vi: set autoindent tabstop=4 shiftwidth=4 :
  3. *
  4. * Copyright (c) 2006-2009 Red Hat, Inc.
  5. *
  6. * All rights reserved.
  7. *
  8. * Author: Patrick Caulfield (pcaulfie@redhat.com)
  9. *
  10. * This software licensed under BSD license, the text of which follows:
  11. *
  12. * Redistribution and use in source and binary forms, with or without
  13. * modification, are permitted provided that the following conditions are met:
  14. *
  15. * - Redistributions of source code must retain the above copyright notice,
  16. * this list of conditions and the following disclaimer.
  17. * - Redistributions in binary form must reproduce the above copyright notice,
  18. * this list of conditions and the following disclaimer in the documentation
  19. * and/or other materials provided with the distribution.
  20. * - Neither the name of the MontaVista Software, Inc. nor the names of its
  21. * contributors may be used to endorse or promote products derived from this
  22. * software without specific prior written permission.
  23. *
  24. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  25. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  26. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  27. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  28. * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  29. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  30. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  31. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  32. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  33. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
  34. * THE POSSIBILITY OF SUCH DAMAGE.
  35. */
  36. /*
  37. * Provides a closed process group API using the coroipcc executive
  38. */
  39. #include <config.h>
  40. #include <stdlib.h>
  41. #include <string.h>
  42. #include <unistd.h>
  43. #include <pthread.h>
  44. #include <sys/types.h>
  45. #include <sys/socket.h>
  46. #include <errno.h>
  47. #include <corosync/corotypes.h>
  48. #include <corosync/cpg.h>
  49. #include <corosync/ipc_cpg.h>
  50. #include <corosync/mar_cpg.h>
  51. #include <corosync/coroipcc.h>
  52. struct cpg_inst {
  53. void *ipc_ctx;
  54. int finalize;
  55. cpg_callbacks_t callbacks;
  56. void *context;
  57. pthread_mutex_t response_mutex;
  58. pthread_mutex_t dispatch_mutex;
  59. };
  60. static void cpg_instance_destructor (void *instance);
  61. DECLARE_SAHDB_DATABASE(cpg_handle_t_db,cpg_instance_destructor);
  62. /*
  63. * Clean up function for a cpg instance (cpg_nitialize) handle
  64. */
  65. static void cpg_instance_destructor (void *instance)
  66. {
  67. struct cpg_inst *cpg_inst = instance;
  68. pthread_mutex_destroy (&cpg_inst->response_mutex);
  69. pthread_mutex_destroy (&cpg_inst->dispatch_mutex);
  70. }
  71. /**
  72. * @defgroup cpg_coroipcc The closed process group API
  73. * @ingroup coroipcc
  74. *
  75. * @{
  76. */
  77. cs_error_t cpg_initialize (
  78. cpg_handle_t *handle,
  79. cpg_callbacks_t *callbacks)
  80. {
  81. cs_error_t error;
  82. struct cpg_inst *cpg_inst;
  83. error = saHandleCreate (&cpg_handle_t_db, sizeof (struct cpg_inst), handle);
  84. if (error != CS_OK) {
  85. goto error_no_destroy;
  86. }
  87. error = saHandleInstanceGet (&cpg_handle_t_db, *handle, (void *)&cpg_inst);
  88. if (error != CS_OK) {
  89. goto error_destroy;
  90. }
  91. error = coroipcc_service_connect (IPC_SOCKET_NAME, CPG_SERVICE, &cpg_inst->ipc_ctx);
  92. if (error != CS_OK) {
  93. goto error_put_destroy;
  94. }
  95. memcpy (&cpg_inst->callbacks, callbacks, sizeof (cpg_callbacks_t));
  96. pthread_mutex_init (&cpg_inst->response_mutex, NULL);
  97. pthread_mutex_init (&cpg_inst->dispatch_mutex, NULL);
  98. saHandleInstancePut (&cpg_handle_t_db, *handle);
  99. return (CS_OK);
  100. error_put_destroy:
  101. saHandleInstancePut (&cpg_handle_t_db, *handle);
  102. error_destroy:
  103. saHandleDestroy (&cpg_handle_t_db, *handle);
  104. error_no_destroy:
  105. return (error);
  106. }
  107. cs_error_t cpg_finalize (
  108. cpg_handle_t handle)
  109. {
  110. struct cpg_inst *cpg_inst;
  111. cs_error_t error;
  112. error = saHandleInstanceGet (&cpg_handle_t_db, handle, (void *)&cpg_inst);
  113. if (error != CS_OK) {
  114. return (error);
  115. }
  116. pthread_mutex_lock (&cpg_inst->response_mutex);
  117. /*
  118. * Another thread has already started finalizing
  119. */
  120. if (cpg_inst->finalize) {
  121. pthread_mutex_unlock (&cpg_inst->response_mutex);
  122. saHandleInstancePut (&cpg_handle_t_db, handle);
  123. return (CPG_ERR_BAD_HANDLE);
  124. }
  125. cpg_inst->finalize = 1;
  126. coroipcc_service_disconnect (cpg_inst->ipc_ctx);
  127. pthread_mutex_unlock (&cpg_inst->response_mutex);
  128. saHandleDestroy (&cpg_handle_t_db, handle);
  129. saHandleInstancePut (&cpg_handle_t_db, handle);
  130. return (CPG_OK);
  131. }
  132. cs_error_t cpg_fd_get (
  133. cpg_handle_t handle,
  134. int *fd)
  135. {
  136. cs_error_t error;
  137. struct cpg_inst *cpg_inst;
  138. error = saHandleInstanceGet (&cpg_handle_t_db, handle, (void *)&cpg_inst);
  139. if (error != CS_OK) {
  140. return (error);
  141. }
  142. *fd = coroipcc_fd_get (cpg_inst->ipc_ctx);
  143. saHandleInstancePut (&cpg_handle_t_db, handle);
  144. return (CS_OK);
  145. }
  146. cs_error_t cpg_context_get (
  147. cpg_handle_t handle,
  148. void **context)
  149. {
  150. cs_error_t error;
  151. struct cpg_inst *cpg_inst;
  152. error = saHandleInstanceGet (&cpg_handle_t_db, handle, (void *)&cpg_inst);
  153. if (error != CS_OK) {
  154. return (error);
  155. }
  156. *context = cpg_inst->context;
  157. saHandleInstancePut (&cpg_handle_t_db, handle);
  158. return (CS_OK);
  159. }
  160. cs_error_t cpg_context_set (
  161. cpg_handle_t handle,
  162. void *context)
  163. {
  164. cs_error_t error;
  165. struct cpg_inst *cpg_inst;
  166. error = saHandleInstanceGet (&cpg_handle_t_db, handle, (void *)&cpg_inst);
  167. if (error != CS_OK) {
  168. return (error);
  169. }
  170. cpg_inst->context = context;
  171. saHandleInstancePut (&cpg_handle_t_db, handle);
  172. return (CS_OK);
  173. }
  174. cs_error_t cpg_dispatch (
  175. cpg_handle_t handle,
  176. cs_dispatch_flags_t dispatch_types)
  177. {
  178. int timeout = -1;
  179. cs_error_t error;
  180. int cont = 1; /* always continue do loop except when set to 0 */
  181. int dispatch_avail;
  182. struct cpg_inst *cpg_inst;
  183. struct res_lib_cpg_confchg_callback *res_cpg_confchg_callback;
  184. struct res_lib_cpg_deliver_callback *res_cpg_deliver_callback;
  185. cpg_callbacks_t callbacks;
  186. mar_res_header_t *dispatch_data;
  187. int ignore_dispatch = 0;
  188. struct cpg_address member_list[CPG_MEMBERS_MAX];
  189. struct cpg_address left_list[CPG_MEMBERS_MAX];
  190. struct cpg_address joined_list[CPG_MEMBERS_MAX];
  191. struct cpg_name group_name;
  192. mar_cpg_address_t *left_list_start;
  193. mar_cpg_address_t *joined_list_start;
  194. unsigned int i;
  195. error = saHandleInstanceGet (&cpg_handle_t_db, handle, (void *)&cpg_inst);
  196. if (error != CS_OK) {
  197. return (error);
  198. }
  199. /*
  200. * Timeout instantly for SA_DISPATCH_ONE or SA_DISPATCH_ALL and
  201. * wait indefinately for SA_DISPATCH_BLOCKING
  202. */
  203. if (dispatch_types == CPG_DISPATCH_ALL) {
  204. timeout = 0;
  205. }
  206. do {
  207. pthread_mutex_lock (&cpg_inst->dispatch_mutex);
  208. dispatch_avail = coroipcc_dispatch_get (
  209. cpg_inst->ipc_ctx,
  210. (void **)&dispatch_data,
  211. timeout);
  212. pthread_mutex_unlock (&cpg_inst->dispatch_mutex);
  213. if (dispatch_avail == 0 && dispatch_types == CPG_DISPATCH_ALL) {
  214. pthread_mutex_unlock (&cpg_inst->dispatch_mutex);
  215. break; /* exit do while cont is 1 loop */
  216. } else
  217. if (dispatch_avail == 0) {
  218. pthread_mutex_unlock (&cpg_inst->dispatch_mutex);
  219. continue; /* next poll */
  220. }
  221. if (dispatch_avail == -1) {
  222. if (cpg_inst->finalize == 1) {
  223. error = CS_OK;
  224. } else {
  225. error = CS_ERR_LIBRARY;
  226. }
  227. goto error_put;
  228. }
  229. /*
  230. * Make copy of callbacks, message data, unlock instance, and call callback
  231. * A risk of this dispatch method is that the callback routines may
  232. * operate at the same time that cpgFinalize has been called.
  233. */
  234. memcpy (&callbacks, &cpg_inst->callbacks, sizeof (cpg_callbacks_t));
  235. /*
  236. * Dispatch incoming message
  237. */
  238. switch (dispatch_data->id) {
  239. case MESSAGE_RES_CPG_DELIVER_CALLBACK:
  240. res_cpg_deliver_callback = (struct res_lib_cpg_deliver_callback *)dispatch_data;
  241. marshall_from_mar_cpg_name_t (
  242. &group_name,
  243. &res_cpg_deliver_callback->group_name);
  244. callbacks.cpg_deliver_fn (handle,
  245. &group_name,
  246. res_cpg_deliver_callback->nodeid,
  247. res_cpg_deliver_callback->pid,
  248. &res_cpg_deliver_callback->message,
  249. res_cpg_deliver_callback->msglen);
  250. break;
  251. case MESSAGE_RES_CPG_CONFCHG_CALLBACK:
  252. res_cpg_confchg_callback = (struct res_lib_cpg_confchg_callback *)dispatch_data;
  253. for (i = 0; i < res_cpg_confchg_callback->member_list_entries; i++) {
  254. marshall_from_mar_cpg_address_t (&member_list[i],
  255. &res_cpg_confchg_callback->member_list[i]);
  256. }
  257. left_list_start = res_cpg_confchg_callback->member_list +
  258. res_cpg_confchg_callback->member_list_entries;
  259. for (i = 0; i < res_cpg_confchg_callback->left_list_entries; i++) {
  260. marshall_from_mar_cpg_address_t (&left_list[i],
  261. &left_list_start[i]);
  262. }
  263. joined_list_start = res_cpg_confchg_callback->member_list +
  264. res_cpg_confchg_callback->member_list_entries +
  265. res_cpg_confchg_callback->left_list_entries;
  266. for (i = 0; i < res_cpg_confchg_callback->joined_list_entries; i++) {
  267. marshall_from_mar_cpg_address_t (&joined_list[i],
  268. &joined_list_start[i]);
  269. }
  270. marshall_from_mar_cpg_name_t (
  271. &group_name,
  272. &res_cpg_confchg_callback->group_name);
  273. callbacks.cpg_confchg_fn (handle,
  274. &group_name,
  275. member_list,
  276. res_cpg_confchg_callback->member_list_entries,
  277. left_list,
  278. res_cpg_confchg_callback->left_list_entries,
  279. joined_list,
  280. res_cpg_confchg_callback->joined_list_entries);
  281. break;
  282. default:
  283. coroipcc_dispatch_put (cpg_inst->ipc_ctx);
  284. error = CS_ERR_LIBRARY;
  285. goto error_put;
  286. break;
  287. }
  288. coroipcc_dispatch_put (cpg_inst->ipc_ctx);
  289. /*
  290. * Determine if more messages should be processed
  291. * */
  292. switch (dispatch_types) {
  293. case CPG_DISPATCH_ONE:
  294. if (ignore_dispatch) {
  295. ignore_dispatch = 0;
  296. } else {
  297. cont = 0;
  298. }
  299. break;
  300. case CPG_DISPATCH_ALL:
  301. if (ignore_dispatch) {
  302. ignore_dispatch = 0;
  303. }
  304. break;
  305. case CPG_DISPATCH_BLOCKING:
  306. break;
  307. }
  308. } while (cont);
  309. error_put:
  310. saHandleInstancePut (&cpg_handle_t_db, handle);
  311. return (error);
  312. }
  313. cs_error_t cpg_join (
  314. cpg_handle_t handle,
  315. const struct cpg_name *group)
  316. {
  317. cs_error_t error;
  318. struct cpg_inst *cpg_inst;
  319. struct iovec iov[2];
  320. struct req_lib_cpg_join req_lib_cpg_join;
  321. struct res_lib_cpg_join res_lib_cpg_join;
  322. struct req_lib_cpg_trackstart req_lib_cpg_trackstart;
  323. struct res_lib_cpg_trackstart res_lib_cpg_trackstart;
  324. error = saHandleInstanceGet (&cpg_handle_t_db, handle, (void *)&cpg_inst);
  325. if (error != CS_OK) {
  326. return (error);
  327. }
  328. pthread_mutex_lock (&cpg_inst->response_mutex);
  329. /* Automatically add a tracker */
  330. req_lib_cpg_trackstart.header.size = sizeof (struct req_lib_cpg_trackstart);
  331. req_lib_cpg_trackstart.header.id = MESSAGE_REQ_CPG_TRACKSTART;
  332. marshall_to_mar_cpg_name_t (&req_lib_cpg_trackstart.group_name,
  333. group);
  334. iov[0].iov_base = &req_lib_cpg_trackstart;
  335. iov[0].iov_len = sizeof (struct req_lib_cpg_trackstart);
  336. error = coroipcc_msg_send_reply_receive (cpg_inst->ipc_ctx, iov, 1,
  337. &res_lib_cpg_trackstart, sizeof (struct res_lib_cpg_trackstart));
  338. if (error != CS_OK) {
  339. pthread_mutex_unlock (&cpg_inst->response_mutex);
  340. goto error_exit;
  341. }
  342. /* Now join */
  343. req_lib_cpg_join.header.size = sizeof (struct req_lib_cpg_join);
  344. req_lib_cpg_join.header.id = MESSAGE_REQ_CPG_JOIN;
  345. req_lib_cpg_join.pid = getpid();
  346. marshall_to_mar_cpg_name_t (&req_lib_cpg_join.group_name,
  347. group);
  348. iov[0].iov_base = &req_lib_cpg_join;
  349. iov[0].iov_len = sizeof (struct req_lib_cpg_join);
  350. error = coroipcc_msg_send_reply_receive (cpg_inst->ipc_ctx, iov, 1,
  351. &res_lib_cpg_join, sizeof (struct res_lib_cpg_join));
  352. pthread_mutex_unlock (&cpg_inst->response_mutex);
  353. if (error != CS_OK) {
  354. goto error_exit;
  355. }
  356. error = res_lib_cpg_join.header.error;
  357. error_exit:
  358. saHandleInstancePut (&cpg_handle_t_db, handle);
  359. return (error);
  360. }
  361. cs_error_t cpg_leave (
  362. cpg_handle_t handle,
  363. const struct cpg_name *group)
  364. {
  365. cs_error_t error;
  366. struct cpg_inst *cpg_inst;
  367. struct iovec iov[2];
  368. struct req_lib_cpg_leave req_lib_cpg_leave;
  369. struct res_lib_cpg_leave res_lib_cpg_leave;
  370. error = saHandleInstanceGet (&cpg_handle_t_db, handle, (void *)&cpg_inst);
  371. if (error != CS_OK) {
  372. return (error);
  373. }
  374. req_lib_cpg_leave.header.size = sizeof (struct req_lib_cpg_leave);
  375. req_lib_cpg_leave.header.id = MESSAGE_REQ_CPG_LEAVE;
  376. req_lib_cpg_leave.pid = getpid();
  377. marshall_to_mar_cpg_name_t (&req_lib_cpg_leave.group_name,
  378. group);
  379. iov[0].iov_base = &req_lib_cpg_leave;
  380. iov[0].iov_len = sizeof (struct req_lib_cpg_leave);
  381. pthread_mutex_lock (&cpg_inst->response_mutex);
  382. error = coroipcc_msg_send_reply_receive (cpg_inst->ipc_ctx, iov, 1,
  383. &res_lib_cpg_leave, sizeof (struct res_lib_cpg_leave));
  384. pthread_mutex_unlock (&cpg_inst->response_mutex);
  385. if (error != CS_OK) {
  386. goto error_exit;
  387. }
  388. error = res_lib_cpg_leave.header.error;
  389. error_exit:
  390. saHandleInstancePut (&cpg_handle_t_db, handle);
  391. return (error);
  392. }
  393. cs_error_t cpg_mcast_joined (
  394. cpg_handle_t handle,
  395. cpg_guarantee_t guarantee,
  396. const struct iovec *iovec,
  397. unsigned int iov_len)
  398. {
  399. int i;
  400. cs_error_t error;
  401. struct cpg_inst *cpg_inst;
  402. struct iovec iov[64];
  403. struct req_lib_cpg_mcast req_lib_cpg_mcast;
  404. struct res_lib_cpg_mcast res_lib_cpg_mcast;
  405. size_t msg_len = 0;
  406. error = saHandleInstanceGet (&cpg_handle_t_db, handle, (void *)&cpg_inst);
  407. if (error != CS_OK) {
  408. return (error);
  409. }
  410. for (i = 0; i < iov_len; i++ ) {
  411. msg_len += iovec[i].iov_len;
  412. }
  413. req_lib_cpg_mcast.header.size = sizeof (struct req_lib_cpg_mcast) +
  414. msg_len;
  415. req_lib_cpg_mcast.header.id = MESSAGE_REQ_CPG_MCAST;
  416. req_lib_cpg_mcast.guarantee = guarantee;
  417. req_lib_cpg_mcast.msglen = msg_len;
  418. iov[0].iov_base = &req_lib_cpg_mcast;
  419. iov[0].iov_len = sizeof (struct req_lib_cpg_mcast);
  420. memcpy (&iov[1], iovec, iov_len * sizeof (struct iovec));
  421. pthread_mutex_lock (&cpg_inst->response_mutex);
  422. error = coroipcc_msg_send_reply_receive (cpg_inst->ipc_ctx, iov,
  423. iov_len + 1, &res_lib_cpg_mcast, sizeof (res_lib_cpg_mcast));
  424. pthread_mutex_unlock (&cpg_inst->response_mutex);
  425. if (error != CS_OK) {
  426. goto error_exit;
  427. }
  428. error = res_lib_cpg_mcast.header.error;
  429. error_exit:
  430. saHandleInstancePut (&cpg_handle_t_db, handle);
  431. return (error);
  432. }
  433. cs_error_t cpg_membership_get (
  434. cpg_handle_t handle,
  435. struct cpg_name *group_name,
  436. struct cpg_address *member_list,
  437. int *member_list_entries)
  438. {
  439. cs_error_t error;
  440. struct cpg_inst *cpg_inst;
  441. struct iovec iov;
  442. struct req_lib_cpg_membership req_lib_cpg_membership_get;
  443. struct res_lib_cpg_confchg_callback res_lib_cpg_membership_get;
  444. unsigned int i;
  445. error = saHandleInstanceGet (&cpg_handle_t_db, handle, (void *)&cpg_inst);
  446. if (error != CS_OK) {
  447. return (error);
  448. }
  449. req_lib_cpg_membership_get.header.size = sizeof (mar_req_header_t);
  450. req_lib_cpg_membership_get.header.id = MESSAGE_REQ_CPG_MEMBERSHIP;
  451. iov.iov_base = &req_lib_cpg_membership_get;
  452. iov.iov_len = sizeof (mar_req_header_t);
  453. pthread_mutex_lock (&cpg_inst->response_mutex);
  454. error = coroipcc_msg_send_reply_receive (cpg_inst->ipc_ctx, &iov, 1,
  455. &res_lib_cpg_membership_get, sizeof (mar_res_header_t));
  456. pthread_mutex_unlock (&cpg_inst->response_mutex);
  457. if (error != CS_OK) {
  458. goto error_exit;
  459. }
  460. error = res_lib_cpg_membership_get.header.error;
  461. /*
  462. * Copy results to caller
  463. */
  464. *member_list_entries = res_lib_cpg_membership_get.member_list_entries;
  465. if (member_list) {
  466. for (i = 0; i < res_lib_cpg_membership_get.member_list_entries; i++) {
  467. marshall_from_mar_cpg_address_t (&member_list[i],
  468. &res_lib_cpg_membership_get.member_list[i]);
  469. }
  470. }
  471. error_exit:
  472. saHandleInstancePut (&cpg_handle_t_db, handle);
  473. return (error);
  474. }
  475. cs_error_t cpg_local_get (
  476. cpg_handle_t handle,
  477. unsigned int *local_nodeid)
  478. {
  479. cs_error_t error;
  480. struct cpg_inst *cpg_inst;
  481. struct iovec iov;
  482. struct req_lib_cpg_local_get req_lib_cpg_local_get;
  483. struct res_lib_cpg_local_get res_lib_cpg_local_get;
  484. error = saHandleInstanceGet (&cpg_handle_t_db, handle, (void *)&cpg_inst);
  485. if (error != CS_OK) {
  486. return (error);
  487. }
  488. req_lib_cpg_local_get.header.size = sizeof (mar_req_header_t);
  489. req_lib_cpg_local_get.header.id = MESSAGE_REQ_CPG_LOCAL_GET;
  490. iov.iov_base = &req_lib_cpg_local_get;
  491. iov.iov_len = sizeof (struct req_lib_cpg_local_get);
  492. pthread_mutex_lock (&cpg_inst->response_mutex);
  493. error = coroipcc_msg_send_reply_receive (cpg_inst->ipc_ctx, &iov, 1,
  494. &res_lib_cpg_local_get, sizeof (res_lib_cpg_local_get));
  495. pthread_mutex_unlock (&cpg_inst->response_mutex);
  496. if (error != CS_OK) {
  497. goto error_exit;
  498. }
  499. error = res_lib_cpg_local_get.header.error;
  500. *local_nodeid = res_lib_cpg_local_get.local_nodeid;
  501. error_exit:
  502. saHandleInstancePut (&cpg_handle_t_db, handle);
  503. return (error);
  504. }
  505. cs_error_t cpg_flow_control_state_get (
  506. cpg_handle_t handle,
  507. cpg_flow_control_state_t *flow_control_state)
  508. {
  509. cs_error_t error;
  510. struct cpg_inst *cpg_inst;
  511. error = saHandleInstanceGet (&cpg_handle_t_db, handle, (void *)&cpg_inst);
  512. if (error != CS_OK) {
  513. return (error);
  514. }
  515. *flow_control_state = coroipcc_dispatch_flow_control_get (cpg_inst->ipc_ctx);
  516. saHandleInstancePut (&cpg_handle_t_db, handle);
  517. return (error);
  518. }
  519. /** @} */