4
0

cpg.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659
  1. /*
  2. * vi: set autoindent tabstop=4 shiftwidth=4 :
  3. *
  4. * Copyright (c) 2006-2008 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. static struct saHandleDatabase cpg_handle_t_db = {
  62. .handleCount = 0,
  63. .handles = 0,
  64. .mutex = PTHREAD_MUTEX_INITIALIZER,
  65. .handleInstanceDestructor = cpg_instance_destructor
  66. };
  67. /*
  68. * Clean up function for a cpg instance (cpg_nitialize) handle
  69. */
  70. static void cpg_instance_destructor (void *instance)
  71. {
  72. struct cpg_inst *cpg_inst = instance;
  73. pthread_mutex_destroy (&cpg_inst->response_mutex);
  74. pthread_mutex_destroy (&cpg_inst->dispatch_mutex);
  75. }
  76. /**
  77. * @defgroup cpg_coroipcc The closed process group API
  78. * @ingroup coroipcc
  79. *
  80. * @{
  81. */
  82. cs_error_t cpg_initialize (
  83. cpg_handle_t *handle,
  84. cpg_callbacks_t *callbacks)
  85. {
  86. cs_error_t error;
  87. struct cpg_inst *cpg_inst;
  88. error = saHandleCreate (&cpg_handle_t_db, sizeof (struct cpg_inst), handle);
  89. if (error != CS_OK) {
  90. goto error_no_destroy;
  91. }
  92. error = saHandleInstanceGet (&cpg_handle_t_db, *handle, (void *)&cpg_inst);
  93. if (error != CS_OK) {
  94. goto error_destroy;
  95. }
  96. error = coroipcc_service_connect (IPC_SOCKET_NAME, CPG_SERVICE, &cpg_inst->ipc_ctx);
  97. if (error != CS_OK) {
  98. goto error_put_destroy;
  99. }
  100. memcpy (&cpg_inst->callbacks, callbacks, sizeof (cpg_callbacks_t));
  101. pthread_mutex_init (&cpg_inst->response_mutex, NULL);
  102. pthread_mutex_init (&cpg_inst->dispatch_mutex, NULL);
  103. saHandleInstancePut (&cpg_handle_t_db, *handle);
  104. return (CS_OK);
  105. error_put_destroy:
  106. saHandleInstancePut (&cpg_handle_t_db, *handle);
  107. error_destroy:
  108. saHandleDestroy (&cpg_handle_t_db, *handle);
  109. error_no_destroy:
  110. return (error);
  111. }
  112. cs_error_t cpg_finalize (
  113. cpg_handle_t handle)
  114. {
  115. struct cpg_inst *cpg_inst;
  116. cs_error_t error;
  117. error = saHandleInstanceGet (&cpg_handle_t_db, handle, (void *)&cpg_inst);
  118. if (error != CS_OK) {
  119. return (error);
  120. }
  121. pthread_mutex_lock (&cpg_inst->response_mutex);
  122. /*
  123. * Another thread has already started finalizing
  124. */
  125. if (cpg_inst->finalize) {
  126. pthread_mutex_unlock (&cpg_inst->response_mutex);
  127. saHandleInstancePut (&cpg_handle_t_db, handle);
  128. return (CPG_ERR_BAD_HANDLE);
  129. }
  130. cpg_inst->finalize = 1;
  131. coroipcc_service_disconnect (cpg_inst->ipc_ctx);
  132. pthread_mutex_unlock (&cpg_inst->response_mutex);
  133. saHandleDestroy (&cpg_handle_t_db, handle);
  134. saHandleInstancePut (&cpg_handle_t_db, handle);
  135. return (CPG_OK);
  136. }
  137. cs_error_t cpg_fd_get (
  138. cpg_handle_t handle,
  139. int *fd)
  140. {
  141. cs_error_t error;
  142. struct cpg_inst *cpg_inst;
  143. error = saHandleInstanceGet (&cpg_handle_t_db, handle, (void *)&cpg_inst);
  144. if (error != CS_OK) {
  145. return (error);
  146. }
  147. *fd = coroipcc_fd_get (cpg_inst->ipc_ctx);
  148. saHandleInstancePut (&cpg_handle_t_db, handle);
  149. return (CS_OK);
  150. }
  151. cs_error_t cpg_context_get (
  152. cpg_handle_t handle,
  153. void **context)
  154. {
  155. cs_error_t error;
  156. struct cpg_inst *cpg_inst;
  157. error = saHandleInstanceGet (&cpg_handle_t_db, handle, (void *)&cpg_inst);
  158. if (error != CS_OK) {
  159. return (error);
  160. }
  161. *context = cpg_inst->context;
  162. saHandleInstancePut (&cpg_handle_t_db, handle);
  163. return (CS_OK);
  164. }
  165. cs_error_t cpg_context_set (
  166. cpg_handle_t handle,
  167. void *context)
  168. {
  169. cs_error_t error;
  170. struct cpg_inst *cpg_inst;
  171. error = saHandleInstanceGet (&cpg_handle_t_db, handle, (void *)&cpg_inst);
  172. if (error != CS_OK) {
  173. return (error);
  174. }
  175. cpg_inst->context = context;
  176. saHandleInstancePut (&cpg_handle_t_db, handle);
  177. return (CS_OK);
  178. }
  179. struct res_overlay {
  180. mar_res_header_t header __attribute__((aligned(8)));
  181. char data[512000];
  182. };
  183. cs_error_t cpg_dispatch (
  184. cpg_handle_t handle,
  185. cs_dispatch_flags_t dispatch_types)
  186. {
  187. int timeout = -1;
  188. cs_error_t error;
  189. int cont = 1; /* always continue do loop except when set to 0 */
  190. int dispatch_avail;
  191. struct cpg_inst *cpg_inst;
  192. struct res_lib_cpg_confchg_callback *res_cpg_confchg_callback;
  193. struct res_lib_cpg_deliver_callback *res_cpg_deliver_callback;
  194. cpg_callbacks_t callbacks;
  195. struct res_overlay dispatch_data;
  196. int ignore_dispatch = 0;
  197. struct cpg_address member_list[CPG_MEMBERS_MAX];
  198. struct cpg_address left_list[CPG_MEMBERS_MAX];
  199. struct cpg_address joined_list[CPG_MEMBERS_MAX];
  200. struct cpg_name group_name;
  201. mar_cpg_address_t *left_list_start;
  202. mar_cpg_address_t *joined_list_start;
  203. unsigned int i;
  204. error = saHandleInstanceGet (&cpg_handle_t_db, handle, (void *)&cpg_inst);
  205. if (error != CS_OK) {
  206. return (error);
  207. }
  208. /*
  209. * Timeout instantly for SA_DISPATCH_ONE or SA_DISPATCH_ALL and
  210. * wait indefinately for SA_DISPATCH_BLOCKING
  211. */
  212. if (dispatch_types == CPG_DISPATCH_ALL) {
  213. timeout = 0;
  214. }
  215. do {
  216. pthread_mutex_lock (&cpg_inst->dispatch_mutex);
  217. dispatch_avail = coroipcc_dispatch_recv (cpg_inst->ipc_ctx,
  218. (void *)&dispatch_data,
  219. sizeof (dispatch_data),
  220. timeout);
  221. pthread_mutex_unlock (&cpg_inst->dispatch_mutex);
  222. if (error != CS_OK) {
  223. goto error_put;
  224. }
  225. if (dispatch_avail == 0 && dispatch_types == CPG_DISPATCH_ALL) {
  226. pthread_mutex_unlock (&cpg_inst->dispatch_mutex);
  227. break; /* exit do while cont is 1 loop */
  228. } else
  229. if (dispatch_avail == 0) {
  230. pthread_mutex_unlock (&cpg_inst->dispatch_mutex);
  231. continue; /* next poll */
  232. }
  233. if (dispatch_avail == -1) {
  234. if (cpg_inst->finalize == 1) {
  235. error = CS_OK;
  236. } else {
  237. error = CS_ERR_LIBRARY;
  238. }
  239. goto error_put;
  240. }
  241. /*
  242. * Make copy of callbacks, message data, unlock instance, and call callback
  243. * A risk of this dispatch method is that the callback routines may
  244. * operate at the same time that cpgFinalize has been called.
  245. */
  246. memcpy (&callbacks, &cpg_inst->callbacks, sizeof (cpg_callbacks_t));
  247. /*
  248. * Dispatch incoming message
  249. */
  250. switch (dispatch_data.header.id) {
  251. case MESSAGE_RES_CPG_DELIVER_CALLBACK:
  252. res_cpg_deliver_callback = (struct res_lib_cpg_deliver_callback *)&dispatch_data;
  253. marshall_from_mar_cpg_name_t (
  254. &group_name,
  255. &res_cpg_deliver_callback->group_name);
  256. callbacks.cpg_deliver_fn (handle,
  257. &group_name,
  258. res_cpg_deliver_callback->nodeid,
  259. res_cpg_deliver_callback->pid,
  260. &res_cpg_deliver_callback->message,
  261. res_cpg_deliver_callback->msglen);
  262. break;
  263. case MESSAGE_RES_CPG_CONFCHG_CALLBACK:
  264. res_cpg_confchg_callback = (struct res_lib_cpg_confchg_callback *)&dispatch_data;
  265. for (i = 0; i < res_cpg_confchg_callback->member_list_entries; i++) {
  266. marshall_from_mar_cpg_address_t (&member_list[i],
  267. &res_cpg_confchg_callback->member_list[i]);
  268. }
  269. left_list_start = res_cpg_confchg_callback->member_list +
  270. res_cpg_confchg_callback->member_list_entries;
  271. for (i = 0; i < res_cpg_confchg_callback->left_list_entries; i++) {
  272. marshall_from_mar_cpg_address_t (&left_list[i],
  273. &left_list_start[i]);
  274. }
  275. joined_list_start = res_cpg_confchg_callback->member_list +
  276. res_cpg_confchg_callback->member_list_entries +
  277. res_cpg_confchg_callback->left_list_entries;
  278. for (i = 0; i < res_cpg_confchg_callback->joined_list_entries; i++) {
  279. marshall_from_mar_cpg_address_t (&joined_list[i],
  280. &joined_list_start[i]);
  281. }
  282. marshall_from_mar_cpg_name_t (
  283. &group_name,
  284. &res_cpg_confchg_callback->group_name);
  285. callbacks.cpg_confchg_fn (handle,
  286. &group_name,
  287. member_list,
  288. res_cpg_confchg_callback->member_list_entries,
  289. left_list,
  290. res_cpg_confchg_callback->left_list_entries,
  291. joined_list,
  292. res_cpg_confchg_callback->joined_list_entries);
  293. break;
  294. default:
  295. error = CS_ERR_LIBRARY;
  296. goto error_put;
  297. break;
  298. }
  299. /*
  300. * Determine if more messages should be processed
  301. * */
  302. switch (dispatch_types) {
  303. case CPG_DISPATCH_ONE:
  304. if (ignore_dispatch) {
  305. ignore_dispatch = 0;
  306. } else {
  307. cont = 0;
  308. }
  309. break;
  310. case CPG_DISPATCH_ALL:
  311. if (ignore_dispatch) {
  312. ignore_dispatch = 0;
  313. }
  314. break;
  315. case CPG_DISPATCH_BLOCKING:
  316. break;
  317. }
  318. } while (cont);
  319. error_put:
  320. saHandleInstancePut (&cpg_handle_t_db, handle);
  321. return (error);
  322. }
  323. cs_error_t cpg_join (
  324. cpg_handle_t handle,
  325. struct cpg_name *group)
  326. {
  327. cs_error_t error;
  328. struct cpg_inst *cpg_inst;
  329. struct iovec iov[2];
  330. struct req_lib_cpg_join req_lib_cpg_join;
  331. struct res_lib_cpg_join res_lib_cpg_join;
  332. struct req_lib_cpg_trackstart req_lib_cpg_trackstart;
  333. struct res_lib_cpg_trackstart res_lib_cpg_trackstart;
  334. error = saHandleInstanceGet (&cpg_handle_t_db, handle, (void *)&cpg_inst);
  335. if (error != CS_OK) {
  336. return (error);
  337. }
  338. pthread_mutex_lock (&cpg_inst->response_mutex);
  339. /* Automatically add a tracker */
  340. req_lib_cpg_trackstart.header.size = sizeof (struct req_lib_cpg_trackstart);
  341. req_lib_cpg_trackstart.header.id = MESSAGE_REQ_CPG_TRACKSTART;
  342. marshall_to_mar_cpg_name_t (&req_lib_cpg_trackstart.group_name,
  343. group);
  344. iov[0].iov_base = &req_lib_cpg_trackstart;
  345. iov[0].iov_len = sizeof (struct req_lib_cpg_trackstart);
  346. error = coroipcc_msg_send_reply_receive (cpg_inst->ipc_ctx, iov, 1,
  347. &res_lib_cpg_trackstart, sizeof (struct res_lib_cpg_trackstart));
  348. if (error != CS_OK) {
  349. pthread_mutex_unlock (&cpg_inst->response_mutex);
  350. goto error_exit;
  351. }
  352. /* Now join */
  353. req_lib_cpg_join.header.size = sizeof (struct req_lib_cpg_join);
  354. req_lib_cpg_join.header.id = MESSAGE_REQ_CPG_JOIN;
  355. req_lib_cpg_join.pid = getpid();
  356. marshall_to_mar_cpg_name_t (&req_lib_cpg_join.group_name,
  357. group);
  358. iov[0].iov_base = &req_lib_cpg_join;
  359. iov[0].iov_len = sizeof (struct req_lib_cpg_join);
  360. error = coroipcc_msg_send_reply_receive (cpg_inst->ipc_ctx, iov, 1,
  361. &res_lib_cpg_join, sizeof (struct res_lib_cpg_join));
  362. pthread_mutex_unlock (&cpg_inst->response_mutex);
  363. if (error != CS_OK) {
  364. goto error_exit;
  365. }
  366. error = res_lib_cpg_join.header.error;
  367. error_exit:
  368. saHandleInstancePut (&cpg_handle_t_db, handle);
  369. return (error);
  370. }
  371. cs_error_t cpg_leave (
  372. cpg_handle_t handle,
  373. struct cpg_name *group)
  374. {
  375. cs_error_t error;
  376. struct cpg_inst *cpg_inst;
  377. struct iovec iov[2];
  378. struct req_lib_cpg_leave req_lib_cpg_leave;
  379. struct res_lib_cpg_leave res_lib_cpg_leave;
  380. error = saHandleInstanceGet (&cpg_handle_t_db, handle, (void *)&cpg_inst);
  381. if (error != CS_OK) {
  382. return (error);
  383. }
  384. req_lib_cpg_leave.header.size = sizeof (struct req_lib_cpg_leave);
  385. req_lib_cpg_leave.header.id = MESSAGE_REQ_CPG_LEAVE;
  386. req_lib_cpg_leave.pid = getpid();
  387. marshall_to_mar_cpg_name_t (&req_lib_cpg_leave.group_name,
  388. group);
  389. iov[0].iov_base = &req_lib_cpg_leave;
  390. iov[0].iov_len = sizeof (struct req_lib_cpg_leave);
  391. pthread_mutex_lock (&cpg_inst->response_mutex);
  392. error = coroipcc_msg_send_reply_receive (cpg_inst->ipc_ctx, iov, 1,
  393. &res_lib_cpg_leave, sizeof (struct res_lib_cpg_leave));
  394. pthread_mutex_unlock (&cpg_inst->response_mutex);
  395. if (error != CS_OK) {
  396. goto error_exit;
  397. }
  398. error = res_lib_cpg_leave.header.error;
  399. error_exit:
  400. saHandleInstancePut (&cpg_handle_t_db, handle);
  401. return (error);
  402. }
  403. cs_error_t cpg_mcast_joined (
  404. cpg_handle_t handle,
  405. cpg_guarantee_t guarantee,
  406. struct iovec *iovec,
  407. unsigned int iov_len)
  408. {
  409. int i;
  410. cs_error_t error;
  411. struct cpg_inst *cpg_inst;
  412. struct iovec iov[64];
  413. struct req_lib_cpg_mcast req_lib_cpg_mcast;
  414. struct res_lib_cpg_mcast res_lib_cpg_mcast;
  415. int msg_len = 0;
  416. error = saHandleInstanceGet (&cpg_handle_t_db, handle, (void *)&cpg_inst);
  417. if (error != CS_OK) {
  418. return (error);
  419. }
  420. for (i = 0; i < iov_len; i++ ) {
  421. msg_len += iovec[i].iov_len;
  422. }
  423. req_lib_cpg_mcast.header.size = sizeof (struct req_lib_cpg_mcast) +
  424. msg_len;
  425. req_lib_cpg_mcast.header.id = MESSAGE_REQ_CPG_MCAST;
  426. req_lib_cpg_mcast.guarantee = guarantee;
  427. req_lib_cpg_mcast.msglen = msg_len;
  428. iov[0].iov_base = &req_lib_cpg_mcast;
  429. iov[0].iov_len = sizeof (struct req_lib_cpg_mcast);
  430. memcpy (&iov[1], iovec, iov_len * sizeof (struct iovec));
  431. pthread_mutex_lock (&cpg_inst->response_mutex);
  432. error = coroipcc_msg_send_reply_receive (cpg_inst->ipc_ctx, iov,
  433. iov_len + 1, &res_lib_cpg_mcast, sizeof (res_lib_cpg_mcast));
  434. pthread_mutex_unlock (&cpg_inst->response_mutex);
  435. if (error != CS_OK) {
  436. goto error_exit;
  437. }
  438. error = res_lib_cpg_mcast.header.error;
  439. error_exit:
  440. saHandleInstancePut (&cpg_handle_t_db, handle);
  441. return (error);
  442. }
  443. cs_error_t cpg_membership_get (
  444. cpg_handle_t handle,
  445. struct cpg_name *group_name,
  446. struct cpg_address *member_list,
  447. int *member_list_entries)
  448. {
  449. cs_error_t error;
  450. struct cpg_inst *cpg_inst;
  451. struct iovec iov;
  452. struct req_lib_cpg_membership req_lib_cpg_membership_get;
  453. struct res_lib_cpg_confchg_callback res_lib_cpg_membership_get;
  454. unsigned int i;
  455. error = saHandleInstanceGet (&cpg_handle_t_db, handle, (void *)&cpg_inst);
  456. if (error != CS_OK) {
  457. return (error);
  458. }
  459. req_lib_cpg_membership_get.header.size = sizeof (mar_req_header_t);
  460. req_lib_cpg_membership_get.header.id = MESSAGE_REQ_CPG_MEMBERSHIP;
  461. iov.iov_base = &req_lib_cpg_membership_get;
  462. iov.iov_len = sizeof (mar_req_header_t);
  463. pthread_mutex_lock (&cpg_inst->response_mutex);
  464. error = coroipcc_msg_send_reply_receive (cpg_inst->ipc_ctx, &iov, 1,
  465. &res_lib_cpg_membership_get, sizeof (mar_res_header_t));
  466. pthread_mutex_unlock (&cpg_inst->response_mutex);
  467. if (error != CS_OK) {
  468. goto error_exit;
  469. }
  470. error = res_lib_cpg_membership_get.header.error;
  471. /*
  472. * Copy results to caller
  473. */
  474. *member_list_entries = res_lib_cpg_membership_get.member_list_entries;
  475. if (member_list) {
  476. for (i = 0; i < res_lib_cpg_membership_get.member_list_entries; i++) {
  477. marshall_from_mar_cpg_address_t (&member_list[i],
  478. &res_lib_cpg_membership_get.member_list[i]);
  479. }
  480. }
  481. error_exit:
  482. saHandleInstancePut (&cpg_handle_t_db, handle);
  483. return (error);
  484. }
  485. cs_error_t cpg_local_get (
  486. cpg_handle_t handle,
  487. unsigned int *local_nodeid)
  488. {
  489. cs_error_t error;
  490. struct cpg_inst *cpg_inst;
  491. struct iovec iov;
  492. struct req_lib_cpg_local_get req_lib_cpg_local_get;
  493. struct res_lib_cpg_local_get res_lib_cpg_local_get;
  494. error = saHandleInstanceGet (&cpg_handle_t_db, handle, (void *)&cpg_inst);
  495. if (error != CS_OK) {
  496. return (error);
  497. }
  498. req_lib_cpg_local_get.header.size = sizeof (mar_req_header_t);
  499. req_lib_cpg_local_get.header.id = MESSAGE_REQ_CPG_LOCAL_GET;
  500. iov.iov_base = &req_lib_cpg_local_get;
  501. iov.iov_len = sizeof (struct req_lib_cpg_local_get);
  502. pthread_mutex_lock (&cpg_inst->response_mutex);
  503. error = coroipcc_msg_send_reply_receive (cpg_inst->ipc_ctx, &iov, 1,
  504. &res_lib_cpg_local_get, sizeof (res_lib_cpg_local_get));
  505. pthread_mutex_unlock (&cpg_inst->response_mutex);
  506. if (error != CS_OK) {
  507. goto error_exit;
  508. }
  509. error = res_lib_cpg_local_get.header.error;
  510. *local_nodeid = res_lib_cpg_local_get.local_nodeid;
  511. error_exit:
  512. saHandleInstancePut (&cpg_handle_t_db, handle);
  513. return (error);
  514. }
  515. cs_error_t cpg_flow_control_state_get (
  516. cpg_handle_t handle,
  517. cpg_flow_control_state_t *flow_control_state)
  518. {
  519. cs_error_t error;
  520. struct cpg_inst *cpg_inst;
  521. error = saHandleInstanceGet (&cpg_handle_t_db, handle, (void *)&cpg_inst);
  522. if (error != CS_OK) {
  523. return (error);
  524. }
  525. *flow_control_state = coroipcc_dispatch_flow_control_get (cpg_inst->ipc_ctx);
  526. saHandleInstancePut (&cpg_handle_t_db, handle);
  527. return (error);
  528. }
  529. /** @} */