clm.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628
  1. /*
  2. * Copyright (c) 2002-2003 MontaVista Software, Inc.
  3. *
  4. * All rights reserved.
  5. *
  6. * Author: Steven Dake (sdake@mvista.com)
  7. *
  8. * This software licensed under BSD license, the text of which follows:
  9. *
  10. * Redistribution and use in source and binary forms, with or without
  11. * modification, are permitted provided that the following conditions are met:
  12. *
  13. * - Redistributions of source code must retain the above copyright notice,
  14. * this list of conditions and the following disclaimer.
  15. * - Redistributions in binary form must reproduce the above copyright notice,
  16. * this list of conditions and the following disclaimer in the documentation
  17. * and/or other materials provided with the distribution.
  18. * - Neither the name of the MontaVista Software, Inc. nor the names of its
  19. * contributors may be used to endorse or promote products derived from this
  20. * software without specific prior written permission.
  21. *
  22. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  23. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  24. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  25. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  26. * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  27. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  28. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  29. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  30. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  31. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
  32. * THE POSSIBILITY OF SUCH DAMAGE.
  33. */
  34. #include <stdio.h>
  35. #include <string.h>
  36. #include <stdlib.h>
  37. #include <unistd.h>
  38. #include <assert.h>
  39. #include <errno.h>
  40. #include <pthread.h>
  41. #include <sys/types.h>
  42. #include <sys/socket.h>
  43. #include <sys/select.h>
  44. #include <sys/un.h>
  45. #include "../include/saAis.h"
  46. #include "../include/saClm.h"
  47. #include "../include/ipc_gen.h"
  48. #include "../include/ipc_clm.h"
  49. #include "util.h"
  50. struct res_overlay {
  51. struct res_header header;
  52. char data[512000];
  53. };
  54. struct clmInstance {
  55. int response_fd;
  56. int dispatch_fd;
  57. SaClmCallbacksT callbacks;
  58. int finalize;
  59. pthread_mutex_t response_mutex;
  60. pthread_mutex_t dispatch_mutex;
  61. };
  62. static void clmHandleInstanceDestructor (void *);
  63. static struct saHandleDatabase clmHandleDatabase = {
  64. .handleCount = 0,
  65. .handles = 0,
  66. .mutex = PTHREAD_MUTEX_INITIALIZER,
  67. .handleInstanceDestructor = clmHandleInstanceDestructor
  68. };
  69. /*
  70. * Versions supported
  71. */
  72. static SaVersionT clmVersionsSupported[] = {
  73. { 'B', 1, 1 }
  74. };
  75. static struct saVersionDatabase clmVersionDatabase = {
  76. sizeof (clmVersionsSupported) / sizeof (SaVersionT),
  77. clmVersionsSupported
  78. };
  79. void clmHandleInstanceDestructor (void *instance)
  80. {
  81. }
  82. SaAisErrorT
  83. saClmInitialize (
  84. SaClmHandleT *clmHandle,
  85. const SaClmCallbacksT *clmCallbacks,
  86. SaVersionT *version)
  87. {
  88. struct clmInstance *clmInstance;
  89. SaAisErrorT error = SA_AIS_OK;
  90. if (clmHandle == NULL) {
  91. return (SA_AIS_ERR_INVALID_PARAM);
  92. }
  93. if (version == NULL) {
  94. return (SA_AIS_ERR_VERSION);
  95. }
  96. error = saVersionVerify (&clmVersionDatabase, version);
  97. if (error != SA_AIS_OK) {
  98. goto error_no_destroy;
  99. }
  100. error = saHandleCreate (&clmHandleDatabase, sizeof (struct clmInstance),
  101. clmHandle);
  102. if (error != SA_AIS_OK) {
  103. goto error_no_destroy;
  104. }
  105. error = saHandleInstanceGet (&clmHandleDatabase, *clmHandle,
  106. (void *)&clmInstance);
  107. if (error != SA_AIS_OK) {
  108. goto error_destroy;
  109. }
  110. clmInstance->response_fd = -1;
  111. clmInstance->dispatch_fd = -1;
  112. error = saServiceConnectTwo (&clmInstance->response_fd,
  113. &clmInstance->dispatch_fd, CLM_SERVICE);
  114. if (error != SA_AIS_OK) {
  115. goto error_put_destroy;
  116. }
  117. if (clmCallbacks) {
  118. memcpy (&clmInstance->callbacks, clmCallbacks, sizeof (SaClmCallbacksT));
  119. } else {
  120. memset (&clmInstance->callbacks, 0, sizeof (SaClmCallbacksT));
  121. }
  122. pthread_mutex_init (&clmInstance->response_mutex, NULL);
  123. pthread_mutex_init (&clmInstance->dispatch_mutex, NULL);
  124. saHandleInstancePut (&clmHandleDatabase, *clmHandle);
  125. return (SA_AIS_OK);
  126. error_put_destroy:
  127. saHandleInstancePut (&clmHandleDatabase, *clmHandle);
  128. error_destroy:
  129. saHandleDestroy (&clmHandleDatabase, *clmHandle);
  130. error_no_destroy:
  131. return (error);
  132. }
  133. SaAisErrorT
  134. saClmSelectionObjectGet (
  135. SaClmHandleT clmHandle,
  136. SaSelectionObjectT *selectionObject)
  137. {
  138. struct clmInstance *clmInstance;
  139. SaAisErrorT error;
  140. if (selectionObject == NULL) {
  141. return (SA_AIS_ERR_INVALID_PARAM);
  142. }
  143. error = saHandleInstanceGet (&clmHandleDatabase, clmHandle,
  144. (void *)&clmInstance);
  145. if (error != SA_AIS_OK) {
  146. return (error);
  147. }
  148. *selectionObject = clmInstance->dispatch_fd;
  149. saHandleInstancePut (&clmHandleDatabase, clmHandle);
  150. return (SA_AIS_OK);
  151. }
  152. SaAisErrorT
  153. saClmDispatch (
  154. SaClmHandleT clmHandle,
  155. SaDispatchFlagsT dispatchFlags)
  156. {
  157. struct pollfd ufds;
  158. int timeout = -1;
  159. SaAisErrorT error;
  160. int cont = 1; /* always continue do loop except when set to 0 */
  161. int dispatch_avail;
  162. struct clmInstance *clmInstance;
  163. struct res_lib_clm_clustertrack *res_lib_clm_clustertrack;
  164. struct res_clm_nodegetcallback *res_clm_nodegetcallback;
  165. SaClmCallbacksT callbacks;
  166. struct res_overlay dispatch_data;
  167. SaClmClusterNotificationBufferT notificationBuffer;
  168. SaClmClusterNotificationT notification[32];
  169. int items_to_copy;
  170. if (dispatchFlags != SA_DISPATCH_ONE &&
  171. dispatchFlags != SA_DISPATCH_ALL &&
  172. dispatchFlags != SA_DISPATCH_BLOCKING) {
  173. return (SA_AIS_ERR_INVALID_PARAM);
  174. }
  175. error = saHandleInstanceGet (&clmHandleDatabase, clmHandle,
  176. (void *)&clmInstance);
  177. if (error != SA_AIS_OK) {
  178. return (error);
  179. }
  180. /*
  181. * Timeout instantly for SA_DISPATCH_ONE or SA_DISPATCH_ALL and
  182. * wait indefinately for SA_DISPATCH_BLOCKING
  183. */
  184. if (dispatchFlags == SA_DISPATCH_ALL) {
  185. timeout = 0;
  186. }
  187. do {
  188. ufds.fd = clmInstance->dispatch_fd;
  189. ufds.events = POLLIN;
  190. ufds.revents = 0;
  191. pthread_mutex_lock (&clmInstance->dispatch_mutex);
  192. error = saPollRetry (&ufds, 1, timeout);
  193. if (error != SA_AIS_OK) {
  194. goto error_unlock;
  195. }
  196. /*
  197. * Handle has been finalized in another thread
  198. */
  199. if (clmInstance->finalize == 1) {
  200. error = SA_AIS_OK;
  201. goto error_unlock;
  202. }
  203. if ((ufds.revents & (POLLERR|POLLHUP|POLLNVAL)) != 0) {
  204. error = SA_AIS_ERR_BAD_HANDLE;
  205. goto error_unlock;
  206. }
  207. dispatch_avail = ufds.revents & POLLIN;
  208. if (dispatch_avail == 0 && dispatchFlags == SA_DISPATCH_ALL) {
  209. pthread_mutex_unlock (&clmInstance->dispatch_mutex);
  210. break; /* exit do while cont is 1 loop */
  211. } else
  212. if (dispatch_avail == 0) {
  213. pthread_mutex_unlock (&clmInstance->dispatch_mutex);
  214. continue; /* next poll */
  215. }
  216. if (ufds.revents & POLLIN) {
  217. error = saRecvRetry (clmInstance->dispatch_fd, &dispatch_data.header,
  218. sizeof (struct res_header), MSG_WAITALL | MSG_NOSIGNAL);
  219. if (error != SA_AIS_OK) {
  220. goto error_unlock;
  221. }
  222. if (dispatch_data.header.size > sizeof (struct res_header)) {
  223. error = saRecvRetry (clmInstance->dispatch_fd, &dispatch_data.data,
  224. dispatch_data.header.size - sizeof (struct res_header),
  225. MSG_WAITALL | MSG_NOSIGNAL);
  226. if (error != SA_AIS_OK) {
  227. goto error_unlock;
  228. }
  229. }
  230. } else {
  231. pthread_mutex_unlock (&clmInstance->dispatch_mutex);
  232. continue;
  233. }
  234. /*
  235. * Make copy of callbacks, message data, unlock instance, and call callback
  236. * A risk of this dispatch method is that the callback routines may
  237. * operate at the same time that clmFinalize has been called in another thread.
  238. */
  239. memcpy (&callbacks, &clmInstance->callbacks, sizeof (SaClmCallbacksT));
  240. pthread_mutex_unlock (&clmInstance->dispatch_mutex);
  241. /*
  242. * Dispatch incoming message
  243. */
  244. switch (dispatch_data.header.id) {
  245. case MESSAGE_RES_CLM_TRACKCALLBACK:
  246. if (callbacks.saClmClusterTrackCallback == NULL) {
  247. continue;
  248. }
  249. res_lib_clm_clustertrack = (struct res_lib_clm_clustertrack *)&dispatch_data;
  250. error = SA_AIS_OK;
  251. notificationBuffer.viewNumber = res_lib_clm_clustertrack->view;
  252. notificationBuffer.notification = notification;
  253. notificationBuffer.numberOfItems =
  254. res_lib_clm_clustertrack->numberOfItems;
  255. items_to_copy = notificationBuffer.numberOfItems
  256. < res_lib_clm_clustertrack->numberOfItems ?
  257. notificationBuffer.numberOfItems :
  258. res_lib_clm_clustertrack->numberOfItems;
  259. memcpy (notificationBuffer.notification,
  260. &res_lib_clm_clustertrack->notification,
  261. items_to_copy * sizeof (SaClmClusterNotificationT));
  262. callbacks.saClmClusterTrackCallback (
  263. (const SaClmClusterNotificationBufferT *)&notificationBuffer,
  264. res_lib_clm_clustertrack->numberOfItems, error);
  265. break;
  266. case MESSAGE_RES_CLM_NODEGETCALLBACK:
  267. if (callbacks.saClmClusterNodeGetCallback == NULL) {
  268. continue;
  269. }
  270. res_clm_nodegetcallback = (struct res_clm_nodegetcallback *)&dispatch_data;
  271. callbacks.saClmClusterNodeGetCallback (
  272. res_clm_nodegetcallback->invocation,
  273. &res_clm_nodegetcallback->clusterNode,
  274. res_clm_nodegetcallback->header.error);
  275. break;
  276. default:
  277. error = SA_AIS_ERR_LIBRARY;
  278. goto error_put;
  279. break;
  280. }
  281. /*
  282. * Determine if more messages should be processed
  283. * */
  284. switch (dispatchFlags) {
  285. case SA_DISPATCH_ONE:
  286. cont = 0;
  287. break;
  288. case SA_DISPATCH_ALL:
  289. break;
  290. case SA_DISPATCH_BLOCKING:
  291. break;
  292. }
  293. } while (cont);
  294. goto error_put;
  295. error_unlock:
  296. pthread_mutex_unlock (&clmInstance->dispatch_mutex);
  297. error_put:
  298. saHandleInstancePut (&clmHandleDatabase, clmHandle);
  299. return (error);
  300. }
  301. SaAisErrorT
  302. saClmFinalize (
  303. SaClmHandleT clmHandle)
  304. {
  305. struct clmInstance *clmInstance;
  306. SaAisErrorT error;
  307. error = saHandleInstanceGet (&clmHandleDatabase, clmHandle,
  308. (void *)&clmInstance);
  309. if (error != SA_AIS_OK) {
  310. return (error);
  311. }
  312. pthread_mutex_lock (&clmInstance->response_mutex);
  313. /*
  314. * Another thread has already started finalizing
  315. */
  316. if (clmInstance->finalize) {
  317. pthread_mutex_unlock (&clmInstance->response_mutex);
  318. saHandleInstancePut (&clmHandleDatabase, clmHandle);
  319. return (SA_AIS_ERR_BAD_HANDLE);
  320. }
  321. clmInstance->finalize = 1;
  322. pthread_mutex_unlock (&clmInstance->response_mutex);
  323. saHandleDestroy (&clmHandleDatabase, clmHandle);
  324. if (clmInstance->response_fd != -1) {
  325. shutdown (clmInstance->response_fd, 0);
  326. close (clmInstance->response_fd);
  327. }
  328. if (clmInstance->dispatch_fd != -1) {
  329. shutdown (clmInstance->dispatch_fd, 0);
  330. close (clmInstance->dispatch_fd);
  331. }
  332. saHandleInstancePut (&clmHandleDatabase, clmHandle);
  333. return (error);
  334. }
  335. SaAisErrorT
  336. saClmClusterTrack (
  337. SaClmHandleT clmHandle,
  338. SaUint8T trackFlags,
  339. SaClmClusterNotificationBufferT *notificationBuffer)
  340. {
  341. struct req_lib_clm_clustertrack req_lib_clm_clustertrack;
  342. struct res_lib_clm_clustertrack res_lib_clm_clustertrack;
  343. struct clmInstance *clmInstance;
  344. SaAisErrorT error = SA_AIS_OK;
  345. int items_to_copy;
  346. if ((trackFlags & SA_TRACK_CHANGES) && (trackFlags & SA_TRACK_CHANGES_ONLY)) {
  347. return (SA_AIS_ERR_BAD_FLAGS);
  348. }
  349. if (trackFlags & ~(SA_TRACK_CURRENT | SA_TRACK_CHANGES | SA_TRACK_CHANGES_ONLY)) {
  350. return (SA_AIS_ERR_BAD_FLAGS);
  351. }
  352. if ((notificationBuffer != NULL) &&
  353. (notificationBuffer->notification != NULL) &&
  354. (notificationBuffer->numberOfItems == 0)) {
  355. return (SA_AIS_ERR_INVALID_PARAM);
  356. }
  357. error = saHandleInstanceGet (&clmHandleDatabase, clmHandle,
  358. (void *)&clmInstance);
  359. if (error != SA_AIS_OK) {
  360. return (error);
  361. }
  362. req_lib_clm_clustertrack.header.size = sizeof (struct req_lib_clm_clustertrack);
  363. req_lib_clm_clustertrack.header.id = MESSAGE_REQ_CLM_TRACKSTART;
  364. req_lib_clm_clustertrack.trackFlags = trackFlags;
  365. req_lib_clm_clustertrack.return_in_callback = 0;
  366. if ((trackFlags & SA_TRACK_CURRENT) && (notificationBuffer == NULL)) {
  367. req_lib_clm_clustertrack.return_in_callback = 1;
  368. }
  369. pthread_mutex_lock (&clmInstance->response_mutex);
  370. if ((clmInstance->callbacks.saClmClusterTrackCallback == 0) &&
  371. ((notificationBuffer == NULL) ||
  372. (trackFlags & (SA_TRACK_CHANGES | SA_TRACK_CHANGES_ONLY)))) {
  373. error = SA_AIS_ERR_INIT;
  374. goto error_exit;
  375. }
  376. error = saSendReceiveReply (clmInstance->response_fd,
  377. &req_lib_clm_clustertrack,
  378. sizeof (struct req_lib_clm_clustertrack),
  379. &res_lib_clm_clustertrack,
  380. sizeof (struct res_lib_clm_clustertrack));
  381. if ((trackFlags & SA_TRACK_CURRENT) && (notificationBuffer != NULL)) {
  382. if (notificationBuffer->notification == 0) {
  383. notificationBuffer->viewNumber = res_lib_clm_clustertrack.view;
  384. notificationBuffer->notification =
  385. malloc (res_lib_clm_clustertrack.numberOfItems *
  386. sizeof (SaClmClusterNotificationT));
  387. notificationBuffer->numberOfItems =
  388. res_lib_clm_clustertrack.numberOfItems;
  389. }
  390. items_to_copy = notificationBuffer->numberOfItems <
  391. res_lib_clm_clustertrack.numberOfItems ?
  392. notificationBuffer->numberOfItems :
  393. res_lib_clm_clustertrack.numberOfItems;
  394. memcpy (notificationBuffer->notification,
  395. res_lib_clm_clustertrack.notification,
  396. items_to_copy * sizeof (SaClmClusterNotificationT));
  397. notificationBuffer->viewNumber = res_lib_clm_clustertrack.view;
  398. notificationBuffer->numberOfItems = items_to_copy;
  399. }
  400. // TODO get response packet with saRecvRetry, but need to implement that
  401. // in executive service
  402. error_exit:
  403. pthread_mutex_unlock (&clmInstance->response_mutex);
  404. saHandleInstancePut (&clmHandleDatabase, clmHandle);
  405. return (error == SA_AIS_OK ? res_lib_clm_clustertrack.header.error : error);
  406. }
  407. SaAisErrorT
  408. saClmClusterTrackStop (
  409. SaClmHandleT clmHandle)
  410. {
  411. struct clmInstance *clmInstance;
  412. struct req_lib_clm_trackstop req_lib_clm_trackstop;
  413. struct res_lib_clm_trackstop res_lib_clm_trackstop;
  414. SaAisErrorT error = SA_AIS_OK;
  415. req_lib_clm_trackstop.header.size = sizeof (struct req_lib_clm_trackstop);
  416. req_lib_clm_trackstop.header.id = MESSAGE_REQ_CLM_TRACKSTOP;
  417. printf ("cluster track stop\n");
  418. error = saHandleInstanceGet (&clmHandleDatabase, clmHandle,
  419. (void *)&clmInstance);
  420. if (error != SA_AIS_OK) {
  421. return (error);
  422. }
  423. pthread_mutex_lock (&clmInstance->response_mutex);
  424. error = saSendReceiveReply (clmInstance->response_fd,
  425. &req_lib_clm_trackstop,
  426. sizeof (struct req_lib_clm_trackstop),
  427. &res_lib_clm_trackstop,
  428. sizeof (struct res_lib_clm_trackstop));
  429. pthread_mutex_unlock (&clmInstance->response_mutex);
  430. saHandleInstancePut (&clmHandleDatabase, clmHandle);
  431. return (error == SA_AIS_OK ? res_lib_clm_trackstop.header.error : error);
  432. }
  433. SaAisErrorT
  434. saClmClusterNodeGet (
  435. SaClmHandleT clmHandle,
  436. SaClmNodeIdT nodeId,
  437. SaTimeT timeout,
  438. SaClmClusterNodeT *clusterNode)
  439. {
  440. struct clmInstance *clmInstance;
  441. struct req_lib_clm_nodeget req_lib_clm_nodeget;
  442. struct res_clm_nodeget res_clm_nodeget;
  443. SaAisErrorT error = SA_AIS_OK;
  444. if (clusterNode == NULL) {
  445. return (SA_AIS_ERR_INVALID_PARAM);
  446. }
  447. if (timeout == 0) {
  448. return (SA_AIS_ERR_TIMEOUT);
  449. }
  450. error = saHandleInstanceGet (&clmHandleDatabase, clmHandle,
  451. (void *)&clmInstance);
  452. if (error != SA_AIS_OK) {
  453. return (error);
  454. }
  455. pthread_mutex_lock (&clmInstance->response_mutex);
  456. /*
  457. * Send request message
  458. */
  459. req_lib_clm_nodeget.header.size = sizeof (struct req_lib_clm_nodeget);
  460. req_lib_clm_nodeget.header.id = MESSAGE_REQ_CLM_NODEGET;
  461. req_lib_clm_nodeget.nodeId = nodeId;
  462. error = saSendReceiveReply (clmInstance->response_fd, &req_lib_clm_nodeget,
  463. sizeof (struct req_lib_clm_nodeget), &res_clm_nodeget, sizeof (res_clm_nodeget));
  464. if (error != SA_AIS_OK) {
  465. goto error_exit;
  466. }
  467. error = res_clm_nodeget.header.error;
  468. memcpy (clusterNode, &res_clm_nodeget.clusterNode,
  469. sizeof (SaClmClusterNodeT));
  470. error_exit:
  471. pthread_mutex_unlock (&clmInstance->response_mutex);
  472. saHandleInstancePut (&clmHandleDatabase, clmHandle);
  473. return (error);
  474. }
  475. SaAisErrorT
  476. saClmClusterNodeGetAsync (
  477. SaClmHandleT clmHandle,
  478. SaInvocationT invocation,
  479. SaClmNodeIdT nodeId)
  480. {
  481. struct clmInstance *clmInstance;
  482. struct req_lib_clm_nodegetasync req_lib_clm_nodegetasync;
  483. struct res_clm_nodegetasync res_clm_nodegetasync;
  484. SaAisErrorT error = SA_AIS_OK;
  485. req_lib_clm_nodegetasync.header.size = sizeof (struct req_lib_clm_nodegetasync);
  486. req_lib_clm_nodegetasync.header.id = MESSAGE_REQ_CLM_NODEGETASYNC;
  487. memcpy (&req_lib_clm_nodegetasync.invocation, &invocation,
  488. sizeof (SaInvocationT));
  489. memcpy (&req_lib_clm_nodegetasync.nodeId, &nodeId, sizeof (SaClmNodeIdT));
  490. error = saHandleInstanceGet (&clmHandleDatabase, clmHandle,
  491. (void *)&clmInstance);
  492. if (error != SA_AIS_OK) {
  493. return (error);
  494. }
  495. pthread_mutex_lock (&clmInstance->response_mutex);
  496. if (clmInstance->callbacks.saClmClusterNodeGetCallback == NULL) {
  497. error = SA_AIS_ERR_INIT;
  498. goto error_exit;
  499. }
  500. error = saSendReceiveReply (clmInstance->response_fd, &req_lib_clm_nodegetasync,
  501. sizeof (struct req_lib_clm_nodegetasync),
  502. &res_clm_nodegetasync, sizeof (struct res_clm_nodegetasync));
  503. if (error != SA_AIS_OK) {
  504. goto error_exit;
  505. }
  506. error = res_clm_nodegetasync.header.error;
  507. error_exit:
  508. pthread_mutex_unlock (&clmInstance->response_mutex);
  509. saHandleInstancePut (&clmHandleDatabase, clmHandle);
  510. return (error);
  511. }