cpg.c 17 KB

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