lck.c 33 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150
  1. /*
  2. * Copyright (c) 2005 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 <assert.h>
  38. #include <unistd.h>
  39. #include <errno.h>
  40. #include <pthread.h>
  41. #include <sys/types.h>
  42. #include <sys/uio.h>
  43. #include <sys/socket.h>
  44. #include <sys/select.h>
  45. #include <sys/un.h>
  46. #include "../include/saAis.h"
  47. #include "../include/list.h"
  48. #include "../include/saLck.h"
  49. #include "../include/ipc_gen.h"
  50. #include "../include/ipc_lck.h"
  51. #include "util.h"
  52. struct message_overlay {
  53. struct res_header header;
  54. char data[4096];
  55. };
  56. /*
  57. * Data structure for instance data
  58. */
  59. struct lckInstance {
  60. int response_fd;
  61. int dispatch_fd;
  62. SaLckCallbacksT callbacks;
  63. int finalize;
  64. SaLckHandleT lckHandle;
  65. struct list_head resource_list;
  66. pthread_mutex_t response_mutex;
  67. pthread_mutex_t dispatch_mutex;
  68. };
  69. struct lckResourceInstance {
  70. int response_fd;
  71. SaLckHandleT lckHandle;
  72. SaLckResourceHandleT lckResourceHandle;
  73. SaLckResourceOpenFlagsT resourceOpenFlags;
  74. SaNameT lockResourceName;
  75. struct list_head list;
  76. struct message_source source;
  77. pthread_mutex_t *response_mutex;
  78. };
  79. struct lckLockIdInstance {
  80. int response_fd;
  81. SaLckResourceHandleT lckResourceHandle;
  82. struct list_head list;
  83. void *resource_lock;
  84. pthread_mutex_t *response_mutex;
  85. };
  86. void lckHandleInstanceDestructor (void *instance);
  87. void lckResourceHandleInstanceDestructor (void *instance);
  88. void lckResourceHandleLockIdInstanceDestructor (void *instance);
  89. /*
  90. * All LCK instances in this database
  91. */
  92. static struct saHandleDatabase lckHandleDatabase = {
  93. .handleCount = 0,
  94. .handles = 0,
  95. .mutex = PTHREAD_MUTEX_INITIALIZER,
  96. .handleInstanceDestructor = lckHandleInstanceDestructor
  97. };
  98. /*
  99. * All Resource instances in this database
  100. */
  101. static struct saHandleDatabase lckResourceHandleDatabase = {
  102. .handleCount = 0,
  103. .handles = 0,
  104. .mutex = PTHREAD_MUTEX_INITIALIZER,
  105. .handleInstanceDestructor = lckResourceHandleInstanceDestructor
  106. };
  107. /*
  108. * All Resource Lock Identifier instances in this database
  109. */
  110. static struct saHandleDatabase lckLockIdHandleDatabase = {
  111. .handleCount = 0,
  112. .handles = 0,
  113. .mutex = PTHREAD_MUTEX_INITIALIZER,
  114. .handleInstanceDestructor = lckResourceHandleLockIdInstanceDestructor
  115. };
  116. /*
  117. * Versions supported
  118. */
  119. static SaVersionT lckVersionsSupported[] = {
  120. { 'B', 1, 1 }
  121. };
  122. static struct saVersionDatabase lckVersionDatabase = {
  123. sizeof (lckVersionsSupported) / sizeof (SaVersionT),
  124. lckVersionsSupported
  125. };
  126. /*
  127. * Implementation
  128. */
  129. void lckHandleInstanceDestructor (void *instance)
  130. {
  131. }
  132. void lckResourceHandleInstanceDestructor (void *instance)
  133. {
  134. return;
  135. }
  136. void lckResourceHandleLockIdInstanceDestructor (void *instance)
  137. {
  138. }
  139. #ifdef NOT_DONE
  140. static void lckSectionIterationInstanceFinalize (struct lckSectionIterationInstance *lckSectionIterationInstance)
  141. {
  142. struct iteratorSectionIdListEntry *iteratorSectionIdListEntry;
  143. struct list_head *sectionIdIterationList;
  144. struct list_head *sectionIdIterationListNext;
  145. /*
  146. * iterate list of section ids for this iterator to free the allocated memory
  147. * be careful to cache next pointer because free removes memory from use
  148. */
  149. for (sectionIdIterationList = lckSectionIterationInstance->sectionIdListHead.next,
  150. sectionIdIterationListNext = sectionIdIterationList->next;
  151. sectionIdIterationList != &lckSectionIterationInstance->sectionIdListHead;
  152. sectionIdIterationList = sectionIdIterationListNext,
  153. sectionIdIterationListNext = sectionIdIterationList->next) {
  154. iteratorSectionIdListEntry = list_entry (sectionIdIterationList,
  155. struct iteratorSectionIdListEntry, list);
  156. free (iteratorSectionIdListEntry);
  157. }
  158. list_del (&lckSectionIterationInstance->list);
  159. saHandleDestroy (&lckSectionIterationHandleDatabase,
  160. lckSectionIterationInstance->sectionIterationHandle);
  161. }
  162. static void lckResourceInstanceFinalize (struct lckResourceInstance *lckResourceInstance)
  163. {
  164. struct lckSectionIterationInstance *sectionIterationInstance;
  165. struct list_head *sectionIterationList;
  166. struct list_head *sectionIterationListNext;
  167. for (sectionIterationList = lckResourceInstance->section_iteration_list_head.next,
  168. sectionIterationListNext = sectionIterationList->next;
  169. sectionIterationList != &lckResourceInstance->section_iteration_list_head;
  170. sectionIterationList = sectionIterationListNext,
  171. sectionIterationListNext = sectionIterationList->next) {
  172. sectionIterationInstance = list_entry (sectionIterationList,
  173. struct lckSectionIterationInstance, list);
  174. lckSectionIterationInstanceFinalize (sectionIterationInstance);
  175. }
  176. list_del (&lckResourceInstance->list);
  177. saHandleDestroy (&lckResourceHandleDatabase, lckResourceInstance->lckResourceHandle);
  178. }
  179. static void lckInstanceFinalize (struct lckInstance *lckInstance)
  180. {
  181. struct lckResourceInstance *lckResourceInstance;
  182. struct list_head *resourceInstanceList;
  183. struct list_head *resourceInstanceListNext;
  184. for (resourceInstanceList = lckInstance->resource_list.next,
  185. resourceInstanceListNext = resourceInstanceList->next;
  186. resourceInstanceList != &lckInstance->resource_list;
  187. resourceInstanceList = resourceInstanceListNext,
  188. resourceInstanceListNext = resourceInstanceList->next) {
  189. lckResourceInstance = list_entry (resourceInstanceList,
  190. struct lckResourceInstance, list);
  191. lckResourceInstanceFinalize (lckResourceInstance);
  192. }
  193. saHandleDestroy (&lckHandleDatabase, lckInstance->lckHandle);
  194. }
  195. #endif
  196. SaAisErrorT
  197. saLckInitialize (
  198. SaLckHandleT *lckHandle,
  199. const SaLckCallbacksT *callbacks,
  200. SaVersionT *version)
  201. {
  202. struct lckInstance *lckInstance;
  203. SaAisErrorT error = SA_AIS_OK;
  204. if (lckHandle == NULL) {
  205. return (SA_AIS_ERR_INVALID_PARAM);
  206. }
  207. error = saVersionVerify (&lckVersionDatabase, version);
  208. if (error != SA_AIS_OK) {
  209. goto error_no_destroy;
  210. }
  211. error = saHandleCreate (&lckHandleDatabase, sizeof (struct lckInstance),
  212. lckHandle);
  213. if (error != SA_AIS_OK) {
  214. goto error_no_destroy;
  215. }
  216. error = saHandleInstanceGet (&lckHandleDatabase, *lckHandle,
  217. (void *)&lckInstance);
  218. if (error != SA_AIS_OK) {
  219. goto error_destroy;
  220. }
  221. lckInstance->response_fd = -1;
  222. error = saServiceConnectTwo (&lckInstance->response_fd,
  223. &lckInstance->dispatch_fd, LCK_SERVICE);
  224. if (error != SA_AIS_OK) {
  225. goto error_put_destroy;
  226. }
  227. if (callbacks) {
  228. memcpy (&lckInstance->callbacks, callbacks, sizeof (SaLckCallbacksT));
  229. } else {
  230. memset (&lckInstance->callbacks, 0, sizeof (SaLckCallbacksT));
  231. }
  232. list_init (&lckInstance->resource_list);
  233. lckInstance->lckHandle = *lckHandle;
  234. pthread_mutex_init (&lckInstance->response_mutex, NULL);
  235. saHandleInstancePut (&lckHandleDatabase, *lckHandle);
  236. return (SA_AIS_OK);
  237. error_put_destroy:
  238. saHandleInstancePut (&lckHandleDatabase, *lckHandle);
  239. error_destroy:
  240. saHandleDestroy (&lckHandleDatabase, *lckHandle);
  241. error_no_destroy:
  242. return (error);
  243. }
  244. SaAisErrorT
  245. saLckSelectionObjectGet (
  246. const SaLckHandleT lckHandle,
  247. SaSelectionObjectT *selectionObject)
  248. {
  249. struct lckInstance *lckInstance;
  250. SaAisErrorT error;
  251. if (selectionObject == NULL) {
  252. return (SA_AIS_ERR_INVALID_PARAM);
  253. }
  254. error = saHandleInstanceGet (&lckHandleDatabase, lckHandle, (void *)&lckInstance);
  255. if (error != SA_AIS_OK) {
  256. return (error);
  257. }
  258. *selectionObject = lckInstance->dispatch_fd;
  259. saHandleInstancePut (&lckHandleDatabase, lckHandle);
  260. return (SA_AIS_OK);
  261. }
  262. SaAisErrorT
  263. saLckOptionCheck (
  264. SaLckHandleT lckHandle,
  265. SaLckOptionsT *lckOptions)
  266. {
  267. return (SA_AIS_OK);
  268. }
  269. SaAisErrorT
  270. saLckDispatch (
  271. const SaLckHandleT lckHandle,
  272. SaDispatchFlagsT dispatchFlags)
  273. {
  274. struct pollfd ufds;
  275. int poll_fd;
  276. int timeout = 1;
  277. SaLckCallbacksT callbacks;
  278. SaAisErrorT error;
  279. int dispatch_avail;
  280. struct lckInstance *lckInstance;
  281. struct lckResourceInstance *lckResourceInstance;
  282. struct lckLockIdInstance *lckLockIdInstance;
  283. int cont = 1; /* always continue do loop except when set to 0 */
  284. struct message_overlay dispatch_data;
  285. struct res_lib_lck_lockwaitercallback *res_lib_lck_lockwaitercallback;
  286. struct res_lib_lck_resourceopenasync *res_lib_lck_resourceopenasync;
  287. struct res_lib_lck_resourcelockasync *res_lib_lck_resourcelockasync;
  288. struct res_lib_lck_resourceunlockasync *res_lib_lck_resourceunlockasync;
  289. if (dispatchFlags != SA_DISPATCH_ONE &&
  290. dispatchFlags != SA_DISPATCH_ALL &&
  291. dispatchFlags != SA_DISPATCH_BLOCKING) {
  292. return (SA_AIS_ERR_INVALID_PARAM);
  293. }
  294. error = saHandleInstanceGet (&lckHandleDatabase, lckHandle,
  295. (void *)&lckInstance);
  296. if (error != SA_AIS_OK) {
  297. goto error_exit;
  298. }
  299. /*
  300. * Timeout instantly for SA_DISPATCH_ALL
  301. */
  302. if (dispatchFlags == SA_DISPATCH_ALL) {
  303. timeout = 0;
  304. }
  305. do {
  306. /*
  307. * Read data directly from socket
  308. */
  309. poll_fd = lckInstance->dispatch_fd;
  310. ufds.fd = poll_fd;
  311. ufds.events = POLLIN;
  312. ufds.revents = 0;
  313. error = saPollRetry(&ufds, 1, timeout);
  314. if (error != SA_AIS_OK) {
  315. goto error_put;
  316. }
  317. pthread_mutex_lock(&lckInstance->dispatch_mutex);
  318. if (lckInstance->finalize == 1) {
  319. error = SA_AIS_OK;
  320. goto error_unlock;
  321. }
  322. if ((ufds.revents & (POLLERR|POLLHUP|POLLNVAL)) != 0) {
  323. error = SA_AIS_ERR_BAD_HANDLE;
  324. goto error_unlock;
  325. }
  326. dispatch_avail = (ufds.revents & POLLIN);
  327. if (dispatch_avail == 0 && dispatchFlags == SA_DISPATCH_ALL) {
  328. pthread_mutex_unlock(&lckInstance->dispatch_mutex);
  329. break; /* exit do while cont is 1 loop */
  330. } else
  331. if (dispatch_avail == 0) {
  332. pthread_mutex_unlock(&lckInstance->dispatch_mutex);
  333. continue;
  334. }
  335. memset(&dispatch_data,0, sizeof(struct message_overlay));
  336. error = saRecvRetry (lckInstance->dispatch_fd, &dispatch_data.header, sizeof (struct res_header), MSG_WAITALL | MSG_NOSIGNAL);
  337. if (error != SA_AIS_OK) {
  338. goto error_unlock;
  339. }
  340. if (dispatch_data.header.size > sizeof (struct res_header)) {
  341. error = saRecvRetry (lckInstance->dispatch_fd, &dispatch_data.data,
  342. dispatch_data.header.size - sizeof (struct res_header),
  343. MSG_WAITALL | MSG_NOSIGNAL);
  344. if (error != SA_AIS_OK) {
  345. goto error_unlock;
  346. }
  347. }
  348. /*
  349. * Make copy of callbacks, message data, unlock instance,
  350. * and call callback. A risk of this dispatch method is that
  351. * the callback routines may operate at the same time that
  352. * LckFinalize has been called in another thread.
  353. */
  354. memcpy(&callbacks,&lckInstance->callbacks, sizeof(lckInstance->callbacks));
  355. pthread_mutex_unlock(&lckInstance->dispatch_mutex);
  356. /*
  357. * Dispatch incoming response
  358. */
  359. switch (dispatch_data.header.id) {
  360. case MESSAGE_RES_LCK_LOCKWAITERCALLBACK:
  361. if (callbacks.saLckResourceOpenCallback == NULL) {
  362. continue;
  363. }
  364. res_lib_lck_lockwaitercallback = (struct res_lib_lck_lockwaitercallback *)&dispatch_data;
  365. callbacks.saLckLockWaiterCallback (
  366. res_lib_lck_lockwaitercallback->waiter_signal,
  367. res_lib_lck_lockwaitercallback->lock_id,
  368. res_lib_lck_lockwaitercallback->mode_held,
  369. res_lib_lck_lockwaitercallback->mode_requested);
  370. break;
  371. case MESSAGE_RES_LCK_RESOURCEOPENASYNC:
  372. if (callbacks.saLckLockWaiterCallback == NULL) {
  373. continue;
  374. }
  375. res_lib_lck_resourceopenasync = (struct res_lib_lck_resourceopenasync *)&dispatch_data;
  376. /*
  377. * This instance get/listadd/put required so that close
  378. * later has the proper list of resources
  379. */
  380. if (res_lib_lck_resourceopenasync->header.error == SA_AIS_OK) {
  381. error = saHandleInstanceGet (&lckResourceHandleDatabase,
  382. res_lib_lck_resourceopenasync->resourceHandle,
  383. (void *)&lckResourceInstance);
  384. assert (error == SA_AIS_OK); /* should only be valid handles here */
  385. /*
  386. * open succeeded without error
  387. */
  388. callbacks.saLckResourceOpenCallback(
  389. res_lib_lck_resourceopenasync->invocation,
  390. res_lib_lck_resourceopenasync->resourceHandle,
  391. res_lib_lck_resourceopenasync->header.error);
  392. saHandleInstancePut (&lckResourceHandleDatabase,
  393. res_lib_lck_resourceopenasync->resourceHandle);
  394. } else {
  395. /*
  396. * open failed with error
  397. */
  398. callbacks.saLckResourceOpenCallback(
  399. res_lib_lck_resourceopenasync->invocation,
  400. -1,
  401. res_lib_lck_resourceopenasync->header.error);
  402. }
  403. break;
  404. case MESSAGE_RES_LCK_RESOURCELOCKASYNC:
  405. printf ("grant\n");
  406. if (callbacks.saLckLockGrantCallback == NULL) {
  407. continue;
  408. }
  409. res_lib_lck_resourcelockasync = (struct res_lib_lck_resourcelockasync *)&dispatch_data;
  410. /*
  411. * This instance get/listadd/put required so that close
  412. * later has the proper list of resources
  413. */
  414. if (res_lib_lck_resourcelockasync->header.error == SA_AIS_OK) {
  415. error = saHandleInstanceGet (&lckLockIdHandleDatabase,
  416. res_lib_lck_resourcelockasync->lockId,
  417. (void *)&lckLockIdInstance);
  418. assert (error == SA_AIS_OK); /* should only be valid handles here */
  419. /*
  420. * open succeeded without error
  421. */
  422. lckLockIdInstance->resource_lock = res_lib_lck_resourcelockasync->resource_lock;
  423. callbacks.saLckLockGrantCallback(
  424. res_lib_lck_resourcelockasync->invocation,
  425. res_lib_lck_resourcelockasync->lockStatus,
  426. res_lib_lck_resourcelockasync->header.error);
  427. saHandleInstancePut (&lckLockIdHandleDatabase,
  428. res_lib_lck_resourcelockasync->lockId);
  429. } else {
  430. /*
  431. * open failed with error
  432. */
  433. callbacks.saLckLockGrantCallback (
  434. res_lib_lck_resourceopenasync->invocation,
  435. -1,
  436. res_lib_lck_resourceopenasync->header.error);
  437. }
  438. break;
  439. case MESSAGE_RES_LCK_RESOURCEUNLOCKASYNC:
  440. if (callbacks.saLckResourceUnlockCallback == NULL) {
  441. continue;
  442. }
  443. res_lib_lck_resourceunlockasync = (struct res_lib_lck_resourceunlockasync *)&dispatch_data;
  444. callbacks.saLckResourceUnlockCallback (
  445. res_lib_lck_resourceunlockasync->invocation,
  446. res_lib_lck_resourceunlockasync->header.error);
  447. break;
  448. #ifdef NOT_DONE_YET
  449. case MESSAGE_RES_LCK_RESOURCESYNCHRONIZEASYNC:
  450. if (callbacks.saLckResourceSynchronizeCallback == NULL) {
  451. continue;
  452. }
  453. res_lib_lck_resourcesynchronizeasync = (struct res_lib_lck_resourcesynchronizeasync *) &dispatch_data;
  454. callbacks.saLckResourceSynchronizeCallback(
  455. res_lib_lck_resourcesynchronizeasync->invocation,
  456. res_lib_lck_resourcesynchronizeasync->header.error);
  457. break;
  458. #endif
  459. default:
  460. /* TODO */
  461. break;
  462. }
  463. /*
  464. * Determine if more messages should be processed
  465. */
  466. switch (dispatchFlags) {
  467. case SA_DISPATCH_ONE:
  468. cont = 0;
  469. break;
  470. case SA_DISPATCH_ALL:
  471. break;
  472. case SA_DISPATCH_BLOCKING:
  473. break;
  474. }
  475. } while (cont);
  476. error_unlock:
  477. pthread_mutex_unlock(&lckInstance->dispatch_mutex);
  478. error_put:
  479. saHandleInstancePut(&lckHandleDatabase, lckHandle);
  480. error_exit:
  481. return (error);
  482. }
  483. SaAisErrorT
  484. saLckFinalize (
  485. const SaLckHandleT lckHandle)
  486. {
  487. struct lckInstance *lckInstance;
  488. SaAisErrorT error;
  489. error = saHandleInstanceGet (&lckHandleDatabase, lckHandle,
  490. (void *)&lckInstance);
  491. if (error != SA_AIS_OK) {
  492. return (error);
  493. }
  494. pthread_mutex_lock (&lckInstance->response_mutex);
  495. /*
  496. * Another thread has already started finalizing
  497. */
  498. if (lckInstance->finalize) {
  499. pthread_mutex_unlock (&lckInstance->response_mutex);
  500. saHandleInstancePut (&lckHandleDatabase, lckHandle);
  501. return (SA_AIS_ERR_BAD_HANDLE);
  502. }
  503. lckInstance->finalize = 1;
  504. pthread_mutex_unlock (&lckInstance->response_mutex);
  505. // TODO lckInstanceFinalize (lckInstance);
  506. if (lckInstance->response_fd != -1) {
  507. shutdown (lckInstance->response_fd, 0);
  508. close (lckInstance->response_fd);
  509. }
  510. if (lckInstance->dispatch_fd != -1) {
  511. shutdown (lckInstance->dispatch_fd, 0);
  512. close (lckInstance->dispatch_fd);
  513. }
  514. saHandleInstancePut (&lckHandleDatabase, lckHandle);
  515. return (SA_AIS_OK);
  516. }
  517. SaAisErrorT
  518. saLckResourceOpen (
  519. SaLckHandleT lckHandle,
  520. const SaNameT *lockResourceName,
  521. SaLckResourceOpenFlagsT resourceOpenFlags,
  522. SaTimeT timeout,
  523. SaLckResourceHandleT *lckResourceHandle)
  524. {
  525. SaAisErrorT error;
  526. struct lckResourceInstance *lckResourceInstance;
  527. struct lckInstance *lckInstance;
  528. struct req_lib_lck_resourceopen req_lib_lck_resourceopen;
  529. struct res_lib_lck_resourceopen res_lib_lck_resourceopen;
  530. if (lckResourceHandle == NULL) {
  531. return (SA_AIS_ERR_INVALID_PARAM);
  532. }
  533. if (lockResourceName == NULL) {
  534. return (SA_AIS_ERR_INVALID_PARAM);
  535. }
  536. error = saHandleInstanceGet (&lckHandleDatabase, lckHandle,
  537. (void *)&lckInstance);
  538. if (error != SA_AIS_OK) {
  539. goto error_exit;
  540. }
  541. error = saHandleCreate (&lckResourceHandleDatabase,
  542. sizeof (struct lckResourceInstance), lckResourceHandle);
  543. if (error != SA_AIS_OK) {
  544. goto error_put_lck;
  545. }
  546. error = saHandleInstanceGet (&lckResourceHandleDatabase,
  547. *lckResourceHandle, (void *)&lckResourceInstance);
  548. if (error != SA_AIS_OK) {
  549. goto error_destroy;
  550. }
  551. lckResourceInstance->response_fd = lckInstance->response_fd;
  552. lckResourceInstance->lckHandle = lckHandle;
  553. lckResourceInstance->lckResourceHandle = *lckResourceHandle;
  554. lckResourceInstance->response_mutex = &lckInstance->response_mutex;
  555. req_lib_lck_resourceopen.header.size = sizeof (struct req_lib_lck_resourceopen);
  556. req_lib_lck_resourceopen.header.id = MESSAGE_REQ_LCK_RESOURCEOPEN;
  557. memcpy (&req_lib_lck_resourceopen.lockResourceName, lockResourceName, sizeof (SaNameT));
  558. memcpy (&lckResourceInstance->lockResourceName, lockResourceName, sizeof (SaNameT));
  559. req_lib_lck_resourceopen.resourceOpenFlags = resourceOpenFlags;
  560. req_lib_lck_resourceopen.resourceHandle = *lckResourceHandle;
  561. req_lib_lck_resourceopen.async_call = 0;
  562. pthread_mutex_lock (&lckInstance->response_mutex);
  563. error = saSendReceiveReply (lckResourceInstance->response_fd,
  564. &req_lib_lck_resourceopen,
  565. sizeof (struct req_lib_lck_resourceopen),
  566. &res_lib_lck_resourceopen,
  567. sizeof (struct res_lib_lck_resourceopen));
  568. pthread_mutex_unlock (&lckInstance->response_mutex);
  569. if (res_lib_lck_resourceopen.header.error != SA_AIS_OK) {
  570. error = res_lib_lck_resourceopen.header.error;
  571. goto error_put_destroy;
  572. }
  573. memcpy (&lckResourceInstance->source,
  574. &res_lib_lck_resourceopen.source,
  575. sizeof (struct message_source));
  576. saHandleInstancePut (&lckResourceHandleDatabase, *lckResourceHandle);
  577. saHandleInstancePut (&lckHandleDatabase, lckHandle);
  578. list_init (&lckResourceInstance->list);
  579. list_add (&lckResourceInstance->list, &lckInstance->resource_list);
  580. return (error);
  581. error_put_destroy:
  582. saHandleInstancePut (&lckResourceHandleDatabase, *lckResourceHandle);
  583. error_destroy:
  584. saHandleDestroy (&lckResourceHandleDatabase, *lckResourceHandle);
  585. error_put_lck:
  586. saHandleInstancePut (&lckHandleDatabase, lckHandle);
  587. error_exit:
  588. return (error);
  589. }
  590. SaAisErrorT
  591. saLckResourceOpenAsync (
  592. SaLckHandleT lckHandle,
  593. SaInvocationT invocation,
  594. const SaNameT *lockResourceName,
  595. SaLckResourceOpenFlagsT resourceOpenFlags)
  596. {
  597. struct lckResourceInstance *lckResourceInstance;
  598. struct lckInstance *lckInstance;
  599. SaLckResourceHandleT lckResourceHandle;
  600. SaAisErrorT error;
  601. struct req_lib_lck_resourceopen req_lib_lck_resourceopen;
  602. struct res_lib_lck_resourceopenasync res_lib_lck_resourceopenasync;
  603. error = saHandleInstanceGet (&lckHandleDatabase, lckHandle,
  604. (void *)&lckInstance);
  605. if (error != SA_AIS_OK) {
  606. goto error_exit;
  607. }
  608. if (lckInstance->callbacks.saLckResourceOpenCallback == NULL) {
  609. error = SA_AIS_ERR_INIT;
  610. goto error_put_lck;
  611. }
  612. error = saHandleCreate (&lckResourceHandleDatabase,
  613. sizeof (struct lckResourceInstance), &lckResourceHandle);
  614. if (error != SA_AIS_OK) {
  615. goto error_put_lck;
  616. }
  617. error = saHandleInstanceGet (&lckResourceHandleDatabase, lckResourceHandle,
  618. (void *)&lckResourceInstance);
  619. if (error != SA_AIS_OK) {
  620. goto error_destroy;
  621. }
  622. lckResourceInstance->response_fd = lckInstance->response_fd;
  623. lckResourceInstance->response_mutex = &lckInstance->response_mutex;
  624. lckResourceInstance->lckHandle = lckHandle;
  625. lckResourceInstance->lckResourceHandle = lckResourceHandle;
  626. lckResourceInstance->resourceOpenFlags = resourceOpenFlags;
  627. memcpy (&lckResourceInstance->lockResourceName, lockResourceName, sizeof (SaNameT));
  628. req_lib_lck_resourceopen.header.size = sizeof (struct req_lib_lck_resourceopen);
  629. req_lib_lck_resourceopen.header.id = MESSAGE_REQ_LCK_RESOURCEOPENASYNC;
  630. req_lib_lck_resourceopen.invocation = invocation;
  631. req_lib_lck_resourceopen.resourceOpenFlags = resourceOpenFlags;
  632. req_lib_lck_resourceopen.resourceHandle = lckResourceHandle;
  633. req_lib_lck_resourceopen.async_call = 1;
  634. pthread_mutex_lock (&lckInstance->response_mutex);
  635. error = saSendReceiveReply (lckResourceInstance->response_fd,
  636. &req_lib_lck_resourceopen,
  637. sizeof (struct req_lib_lck_resourceopen),
  638. &res_lib_lck_resourceopenasync,
  639. sizeof (struct res_lib_lck_resourceopenasync));
  640. pthread_mutex_unlock (&lckInstance->response_mutex);
  641. if (error == SA_AIS_OK) {
  642. saHandleInstancePut (&lckResourceHandleDatabase,
  643. lckResourceHandle);
  644. saHandleInstancePut (&lckHandleDatabase, lckHandle);
  645. return (res_lib_lck_resourceopenasync.header.error);
  646. }
  647. saHandleInstancePut (&lckResourceHandleDatabase, lckResourceHandle);
  648. error_destroy:
  649. saHandleDestroy (&lckResourceHandleDatabase, lckResourceHandle);
  650. error_put_lck:
  651. saHandleInstancePut (&lckHandleDatabase, lckHandle);
  652. error_exit:
  653. return (error);
  654. }
  655. SaAisErrorT
  656. saLckResourceClose (
  657. SaLckResourceHandleT lckResourceHandle)
  658. {
  659. struct req_lib_lck_resourceclose req_lib_lck_resourceclose;
  660. struct res_lib_lck_resourceclose res_lib_lck_resourceclose;
  661. SaAisErrorT error;
  662. struct lckResourceInstance *lckResourceInstance;
  663. error = saHandleInstanceGet (&lckResourceHandleDatabase, lckResourceHandle,
  664. (void *)&lckResourceInstance);
  665. if (error != SA_AIS_OK) {
  666. return (error);
  667. }
  668. req_lib_lck_resourceclose.header.size = sizeof (struct req_lib_lck_resourceclose);
  669. req_lib_lck_resourceclose.header.id = MESSAGE_REQ_LCK_RESOURCECLOSE;
  670. memcpy (&req_lib_lck_resourceclose.lockResourceName,
  671. &lckResourceInstance->lockResourceName, sizeof (SaNameT));
  672. req_lib_lck_resourceclose.resourceHandle = lckResourceHandle;
  673. pthread_mutex_lock (lckResourceInstance->response_mutex);
  674. error = saSendReceiveReply (lckResourceInstance->response_fd,
  675. &req_lib_lck_resourceclose,
  676. sizeof (struct req_lib_lck_resourceclose),
  677. &res_lib_lck_resourceclose,
  678. sizeof (struct res_lib_lck_resourceclose));
  679. pthread_mutex_unlock (lckResourceInstance->response_mutex);
  680. saHandleInstancePut (&lckResourceHandleDatabase, lckResourceHandle);
  681. saHandleDestroy (&lckResourceHandleDatabase, lckResourceHandle);
  682. return (error == SA_AIS_OK ? res_lib_lck_resourceclose.header.error : error);
  683. }
  684. SaAisErrorT
  685. saLckResourceLock (
  686. SaLckResourceHandleT lckResourceHandle,
  687. SaLckLockIdT *lockId,
  688. SaLckLockModeT lockMode,
  689. SaLckLockFlagsT lockFlags,
  690. SaLckWaiterSignalT waiterSignal,
  691. SaTimeT timeout,
  692. SaLckLockStatusT *lockStatus)
  693. {
  694. struct req_lib_lck_resourcelock req_lib_lck_resourcelock;
  695. struct res_lib_lck_resourcelock res_lib_lck_resourcelock;
  696. SaAisErrorT error;
  697. struct lckResourceInstance *lckResourceInstance;
  698. struct lckLockIdInstance *lckLockIdInstance;
  699. int lock_fd;
  700. int dummy_fd;
  701. error = saHandleInstanceGet (&lckResourceHandleDatabase, lckResourceHandle,
  702. (void *)&lckResourceInstance);
  703. if (error != SA_AIS_OK) {
  704. return (error);
  705. }
  706. error = saHandleCreate (&lckLockIdHandleDatabase,
  707. sizeof (struct lckLockIdInstance), lockId);
  708. if (error != SA_AIS_OK) {
  709. goto error_put_lck;
  710. }
  711. error = saHandleInstanceGet (&lckLockIdHandleDatabase, *lockId,
  712. (void *)&lckLockIdInstance);
  713. if (error != SA_AIS_OK) {
  714. goto error_destroy;
  715. }
  716. error = saServiceConnectTwo (&lock_fd, &dummy_fd, LCK_SERVICE);
  717. if (error != SA_AIS_OK) { // TODO error handling
  718. goto error_destroy;
  719. }
  720. lckLockIdInstance->response_mutex = lckResourceInstance->response_mutex;
  721. lckLockIdInstance->response_fd = lckResourceInstance->response_fd;
  722. lckLockIdInstance->lckResourceHandle = lckResourceHandle;
  723. req_lib_lck_resourcelock.header.size = sizeof (struct req_lib_lck_resourcelock);
  724. req_lib_lck_resourcelock.header.id = MESSAGE_REQ_LCK_RESOURCELOCK;
  725. memcpy (&req_lib_lck_resourcelock.lockResourceName,
  726. &lckResourceInstance->lockResourceName, sizeof (SaNameT));
  727. req_lib_lck_resourcelock.lockMode = lockMode;
  728. req_lib_lck_resourcelock.lockFlags = lockFlags;
  729. req_lib_lck_resourcelock.waiterSignal = waiterSignal;
  730. req_lib_lck_resourcelock.lockId = *lockId;
  731. req_lib_lck_resourcelock.async_call = 0;
  732. req_lib_lck_resourcelock.invocation = 0;
  733. req_lib_lck_resourcelock.resourceHandle = lckResourceHandle;
  734. memcpy (&req_lib_lck_resourcelock.source,
  735. &lckResourceInstance->source,
  736. sizeof (struct message_source));
  737. /*
  738. * no mutex needed here since its a new connection
  739. */
  740. error = saSendReceiveReply (lock_fd,
  741. &req_lib_lck_resourcelock,
  742. sizeof (struct req_lib_lck_resourcelock),
  743. &res_lib_lck_resourcelock,
  744. sizeof (struct res_lib_lck_resourcelock));
  745. close (lock_fd);
  746. close (dummy_fd);
  747. if (error == SA_AIS_OK) {
  748. lckLockIdInstance->resource_lock = res_lib_lck_resourcelock.resource_lock;
  749. *lockStatus = res_lib_lck_resourcelock.lockStatus;
  750. return (res_lib_lck_resourcelock.header.error);
  751. }
  752. /*
  753. * Error
  754. */
  755. saHandleInstancePut (&lckLockIdHandleDatabase, *lockId);
  756. error_destroy:
  757. saHandleDestroy (&lckLockIdHandleDatabase, *lockId);
  758. error_put_lck:
  759. saHandleInstancePut (&lckResourceHandleDatabase, lckResourceHandle);
  760. return (error);
  761. }
  762. SaAisErrorT
  763. saLckResourceLockAsync (
  764. SaLckResourceHandleT lckResourceHandle,
  765. SaInvocationT invocation,
  766. SaLckLockIdT *lockId,
  767. SaLckLockModeT lockMode,
  768. SaLckLockFlagsT lockFlags,
  769. SaLckWaiterSignalT waiterSignal)
  770. {
  771. struct req_lib_lck_resourcelock req_lib_lck_resourcelock;
  772. struct res_lib_lck_resourcelockasync res_lib_lck_resourcelockasync;
  773. SaAisErrorT error;
  774. struct lckResourceInstance *lckResourceInstance;
  775. struct lckLockIdInstance *lckLockIdInstance;
  776. int lock_fd;
  777. int dummy_fd;
  778. error = saHandleInstanceGet (&lckResourceHandleDatabase, lckResourceHandle,
  779. (void *)&lckResourceInstance);
  780. if (error != SA_AIS_OK) {
  781. return (error);
  782. }
  783. error = saHandleCreate (&lckLockIdHandleDatabase,
  784. sizeof (struct lckLockIdInstance), lockId);
  785. if (error != SA_AIS_OK) {
  786. goto error_put_lck;
  787. }
  788. error = saHandleInstanceGet (&lckLockIdHandleDatabase, *lockId,
  789. (void *)&lckLockIdInstance);
  790. if (error != SA_AIS_OK) {
  791. goto error_destroy;
  792. }
  793. error = saServiceConnectTwo (&lock_fd, &dummy_fd, LCK_SERVICE);
  794. if (error != SA_AIS_OK) { // TODO error handling
  795. goto error_destroy;
  796. }
  797. lckLockIdInstance->response_mutex = lckResourceInstance->response_mutex;
  798. lckLockIdInstance->response_fd = lckResourceInstance->response_fd;
  799. lckLockIdInstance->lckResourceHandle = lckResourceHandle;
  800. req_lib_lck_resourcelock.header.size = sizeof (struct req_lib_lck_resourcelock);
  801. req_lib_lck_resourcelock.header.id = MESSAGE_REQ_LCK_RESOURCELOCKASYNC;
  802. memcpy (&req_lib_lck_resourcelock.lockResourceName,
  803. &lckResourceInstance->lockResourceName, sizeof (SaNameT));
  804. req_lib_lck_resourcelock.lockMode = lockMode;
  805. req_lib_lck_resourcelock.lockFlags = lockFlags;
  806. req_lib_lck_resourcelock.waiterSignal = waiterSignal;
  807. req_lib_lck_resourcelock.lockId = *lockId;
  808. req_lib_lck_resourcelock.async_call = 1;
  809. req_lib_lck_resourcelock.invocation = invocation;
  810. req_lib_lck_resourcelock.resourceHandle = lckResourceHandle;
  811. memcpy (&req_lib_lck_resourcelock.source,
  812. &lckResourceInstance->source,
  813. sizeof (struct message_source));
  814. /*
  815. * no mutex needed here since its a new connection
  816. */
  817. error = saSendReceiveReply (lock_fd,
  818. &req_lib_lck_resourcelock,
  819. sizeof (struct req_lib_lck_resourcelock),
  820. &res_lib_lck_resourcelockasync,
  821. sizeof (struct res_lib_lck_resourcelock));
  822. close (lock_fd);
  823. close (dummy_fd);
  824. if (error == SA_AIS_OK) {
  825. return (res_lib_lck_resourcelockasync.header.error);
  826. }
  827. /*
  828. * Error
  829. */
  830. saHandleInstancePut (&lckLockIdHandleDatabase, *lockId);
  831. error_destroy:
  832. saHandleDestroy (&lckLockIdHandleDatabase, *lockId);
  833. error_put_lck:
  834. saHandleInstancePut (&lckResourceHandleDatabase, lckResourceHandle);
  835. return (error);
  836. }
  837. SaAisErrorT
  838. saLckResourceUnlock (
  839. SaLckLockIdT lockId,
  840. SaTimeT timeout)
  841. {
  842. struct req_lib_lck_resourceunlock req_lib_lck_resourceunlock;
  843. struct res_lib_lck_resourceunlockasync res_lib_lck_resourceunlockasync;
  844. SaAisErrorT error;
  845. struct lckLockIdInstance *lckLockIdInstance;
  846. struct lckResourceInstance *lckResourceInstance;
  847. error = saHandleInstanceGet (&lckLockIdHandleDatabase, lockId,
  848. (void *)&lckLockIdInstance);
  849. if (error != SA_AIS_OK) {
  850. return (error);
  851. }
  852. /*
  853. * Retrieve resource name
  854. */
  855. error = saHandleInstanceGet (&lckResourceHandleDatabase,
  856. lckLockIdInstance->lckResourceHandle, (void *)&lckResourceInstance);
  857. if (error != SA_AIS_OK) {
  858. saHandleInstancePut (&lckLockIdHandleDatabase, lockId);
  859. return (error);
  860. }
  861. memcpy (&req_lib_lck_resourceunlock.lockResourceName,
  862. &lckResourceInstance->lockResourceName, sizeof (SaNameT));
  863. saHandleInstancePut (&lckResourceHandleDatabase,
  864. lckLockIdInstance->lckResourceHandle);
  865. req_lib_lck_resourceunlock.header.size = sizeof (struct req_lib_lck_resourceunlock);
  866. req_lib_lck_resourceunlock.header.id = MESSAGE_REQ_LCK_RESOURCEUNLOCK;
  867. req_lib_lck_resourceunlock.lockId = lockId;
  868. req_lib_lck_resourceunlock.timeout = timeout;
  869. req_lib_lck_resourceunlock.invocation = -1;
  870. req_lib_lck_resourceunlock.async_call = 0;
  871. req_lib_lck_resourceunlock.resource_lock = lckLockIdInstance->resource_lock;
  872. pthread_mutex_lock (lckLockIdInstance->response_mutex);
  873. error = saSendReceiveReply (lckLockIdInstance->response_fd,
  874. &req_lib_lck_resourceunlock,
  875. sizeof (struct req_lib_lck_resourceunlock),
  876. &res_lib_lck_resourceunlockasync,
  877. sizeof (struct res_lib_lck_resourceunlockasync));
  878. pthread_mutex_unlock (lckLockIdInstance->response_mutex);
  879. saHandleInstancePut (&lckLockIdHandleDatabase, lockId);
  880. saHandleDestroy (&lckLockIdHandleDatabase, lockId);
  881. return (error == SA_AIS_OK ? res_lib_lck_resourceunlockasync.header.error : error);
  882. }
  883. SaAisErrorT
  884. saLckResourceUnlockAsync (
  885. SaInvocationT invocation,
  886. SaLckLockIdT lockId)
  887. {
  888. struct req_lib_lck_resourceunlock req_lib_lck_resourceunlock;
  889. struct res_lib_lck_resourceunlockasync res_lib_lck_resourceunlockasync;
  890. SaAisErrorT error;
  891. struct lckLockIdInstance *lckLockIdInstance;
  892. struct lckResourceInstance *lckResourceInstance;
  893. error = saHandleInstanceGet (&lckLockIdHandleDatabase, lockId,
  894. (void *)&lckLockIdInstance);
  895. if (error != SA_AIS_OK) {
  896. return (error);
  897. }
  898. /*
  899. * Retrieve resource name
  900. */
  901. error = saHandleInstanceGet (&lckResourceHandleDatabase,
  902. lckLockIdInstance->lckResourceHandle, (void *)&lckResourceInstance);
  903. if (error != SA_AIS_OK) {
  904. saHandleInstancePut (&lckLockIdHandleDatabase, lockId);
  905. return (error);
  906. }
  907. memcpy (&req_lib_lck_resourceunlock.lockResourceName,
  908. &lckResourceInstance->lockResourceName, sizeof (SaNameT));
  909. saHandleInstancePut (&lckResourceHandleDatabase,
  910. lckLockIdInstance->lckResourceHandle);
  911. /*
  912. * Build and send request
  913. */
  914. req_lib_lck_resourceunlock.header.size = sizeof (struct req_lib_lck_resourceunlock);
  915. req_lib_lck_resourceunlock.header.id = MESSAGE_REQ_LCK_RESOURCEUNLOCKASYNC;
  916. req_lib_lck_resourceunlock.invocation = invocation;
  917. req_lib_lck_resourceunlock.lockId = lockId;
  918. req_lib_lck_resourceunlock.async_call = 1;
  919. pthread_mutex_lock (lckLockIdInstance->response_mutex);
  920. error = saSendReceiveReply (lckLockIdInstance->response_fd,
  921. &req_lib_lck_resourceunlock,
  922. sizeof (struct req_lib_lck_resourceunlock),
  923. &res_lib_lck_resourceunlockasync,
  924. sizeof (struct res_lib_lck_resourceunlockasync));
  925. pthread_mutex_unlock (lckLockIdInstance->response_mutex);
  926. saHandleInstancePut (&lckLockIdHandleDatabase, lockId);
  927. return (error == SA_AIS_OK ? res_lib_lck_resourceunlockasync.header.error : error);
  928. }
  929. SaAisErrorT
  930. saLckLockPurge (
  931. SaLckResourceHandleT lckResourceHandle)
  932. {
  933. struct req_lib_lck_lockpurge req_lib_lck_lockpurge;
  934. struct res_lib_lck_lockpurge res_lib_lck_lockpurge;
  935. SaAisErrorT error;
  936. struct lckResourceInstance *lckResourceInstance;
  937. error = saHandleInstanceGet (&lckResourceHandleDatabase, lckResourceHandle,
  938. (void *)&lckResourceInstance);
  939. if (error != SA_AIS_OK) {
  940. return (error);
  941. }
  942. req_lib_lck_lockpurge.header.size = sizeof (struct req_lib_lck_lockpurge);
  943. req_lib_lck_lockpurge.header.id = MESSAGE_REQ_LCK_LOCKPURGE;
  944. memcpy (&req_lib_lck_lockpurge.lockResourceName,
  945. &lckResourceInstance->lockResourceName, sizeof (SaNameT));
  946. pthread_mutex_lock (lckResourceInstance->response_mutex);
  947. error = saSendReceiveReply (lckResourceInstance->response_fd,
  948. &req_lib_lck_lockpurge,
  949. sizeof (struct req_lib_lck_lockpurge),
  950. &res_lib_lck_lockpurge,
  951. sizeof (struct res_lib_lck_lockpurge));
  952. pthread_mutex_unlock (lckResourceInstance->response_mutex);
  953. saHandleInstancePut (&lckResourceHandleDatabase, lckResourceHandle);
  954. return (error == SA_AIS_OK ? res_lib_lck_lockpurge.header.error : error);
  955. }