lck.c 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149
  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 = NULL;
  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));
  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. if (error != SA_AIS_OK) {
  344. goto error_unlock;
  345. }
  346. }
  347. /*
  348. * Make copy of callbacks, message data, unlock instance,
  349. * and call callback. A risk of this dispatch method is that
  350. * the callback routines may operate at the same time that
  351. * LckFinalize has been called in another thread.
  352. */
  353. memcpy(&callbacks,&lckInstance->callbacks, sizeof(lckInstance->callbacks));
  354. pthread_mutex_unlock(&lckInstance->dispatch_mutex);
  355. /*
  356. * Dispatch incoming response
  357. */
  358. switch (dispatch_data.header.id) {
  359. case MESSAGE_RES_LCK_LOCKWAITERCALLBACK:
  360. if (callbacks.saLckResourceOpenCallback == NULL) {
  361. continue;
  362. }
  363. res_lib_lck_lockwaitercallback = (struct res_lib_lck_lockwaitercallback *)&dispatch_data;
  364. callbacks.saLckLockWaiterCallback (
  365. res_lib_lck_lockwaitercallback->waiter_signal,
  366. res_lib_lck_lockwaitercallback->lock_id,
  367. res_lib_lck_lockwaitercallback->mode_held,
  368. res_lib_lck_lockwaitercallback->mode_requested);
  369. break;
  370. case MESSAGE_RES_LCK_RESOURCEOPENASYNC:
  371. if (callbacks.saLckLockWaiterCallback == NULL) {
  372. continue;
  373. }
  374. res_lib_lck_resourceopenasync = (struct res_lib_lck_resourceopenasync *)&dispatch_data;
  375. /*
  376. * This instance get/listadd/put required so that close
  377. * later has the proper list of resources
  378. */
  379. if (res_lib_lck_resourceopenasync->header.error == SA_AIS_OK) {
  380. error = saHandleInstanceGet (&lckResourceHandleDatabase,
  381. res_lib_lck_resourceopenasync->resourceHandle,
  382. (void *)&lckResourceInstance);
  383. assert (error == SA_AIS_OK); /* should only be valid handles here */
  384. /*
  385. * open succeeded without error
  386. */
  387. callbacks.saLckResourceOpenCallback(
  388. res_lib_lck_resourceopenasync->invocation,
  389. res_lib_lck_resourceopenasync->resourceHandle,
  390. res_lib_lck_resourceopenasync->header.error);
  391. saHandleInstancePut (&lckResourceHandleDatabase,
  392. res_lib_lck_resourceopenasync->resourceHandle);
  393. } else {
  394. /*
  395. * open failed with error
  396. */
  397. callbacks.saLckResourceOpenCallback(
  398. res_lib_lck_resourceopenasync->invocation,
  399. -1,
  400. res_lib_lck_resourceopenasync->header.error);
  401. }
  402. break;
  403. case MESSAGE_RES_LCK_RESOURCELOCKASYNC:
  404. DPRINT (("grant\n"));
  405. if (callbacks.saLckLockGrantCallback == NULL) {
  406. continue;
  407. }
  408. res_lib_lck_resourcelockasync = (struct res_lib_lck_resourcelockasync *)&dispatch_data;
  409. /*
  410. * This instance get/listadd/put required so that close
  411. * later has the proper list of resources
  412. */
  413. if (res_lib_lck_resourcelockasync->header.error == SA_AIS_OK) {
  414. error = saHandleInstanceGet (&lckLockIdHandleDatabase,
  415. res_lib_lck_resourcelockasync->lockId,
  416. (void *)&lckLockIdInstance);
  417. assert (error == SA_AIS_OK); /* should only be valid handles here */
  418. /*
  419. * open succeeded without error
  420. */
  421. lckLockIdInstance->resource_lock = res_lib_lck_resourcelockasync->resource_lock;
  422. callbacks.saLckLockGrantCallback(
  423. res_lib_lck_resourcelockasync->invocation,
  424. res_lib_lck_resourcelockasync->lockStatus,
  425. res_lib_lck_resourcelockasync->header.error);
  426. saHandleInstancePut (&lckLockIdHandleDatabase,
  427. res_lib_lck_resourcelockasync->lockId);
  428. } else {
  429. /*
  430. * open failed with error
  431. */
  432. callbacks.saLckLockGrantCallback (
  433. res_lib_lck_resourceopenasync->invocation,
  434. -1,
  435. res_lib_lck_resourceopenasync->header.error);
  436. }
  437. break;
  438. case MESSAGE_RES_LCK_RESOURCEUNLOCKASYNC:
  439. if (callbacks.saLckResourceUnlockCallback == NULL) {
  440. continue;
  441. }
  442. res_lib_lck_resourceunlockasync = (struct res_lib_lck_resourceunlockasync *)&dispatch_data;
  443. callbacks.saLckResourceUnlockCallback (
  444. res_lib_lck_resourceunlockasync->invocation,
  445. res_lib_lck_resourceunlockasync->header.error);
  446. break;
  447. #ifdef NOT_DONE_YET
  448. case MESSAGE_RES_LCK_RESOURCESYNCHRONIZEASYNC:
  449. if (callbacks.saLckResourceSynchronizeCallback == NULL) {
  450. continue;
  451. }
  452. res_lib_lck_resourcesynchronizeasync = (struct res_lib_lck_resourcesynchronizeasync *) &dispatch_data;
  453. callbacks.saLckResourceSynchronizeCallback(
  454. res_lib_lck_resourcesynchronizeasync->invocation,
  455. res_lib_lck_resourcesynchronizeasync->header.error);
  456. break;
  457. #endif
  458. default:
  459. /* TODO */
  460. break;
  461. }
  462. /*
  463. * Determine if more messages should be processed
  464. */
  465. switch (dispatchFlags) {
  466. case SA_DISPATCH_ONE:
  467. cont = 0;
  468. break;
  469. case SA_DISPATCH_ALL:
  470. break;
  471. case SA_DISPATCH_BLOCKING:
  472. break;
  473. }
  474. } while (cont);
  475. error_unlock:
  476. pthread_mutex_unlock(&lckInstance->dispatch_mutex);
  477. error_put:
  478. saHandleInstancePut(&lckHandleDatabase, lckHandle);
  479. error_exit:
  480. return (error);
  481. }
  482. SaAisErrorT
  483. saLckFinalize (
  484. const SaLckHandleT lckHandle)
  485. {
  486. struct lckInstance *lckInstance;
  487. SaAisErrorT error;
  488. error = saHandleInstanceGet (&lckHandleDatabase, lckHandle,
  489. (void *)&lckInstance);
  490. if (error != SA_AIS_OK) {
  491. return (error);
  492. }
  493. pthread_mutex_lock (&lckInstance->response_mutex);
  494. /*
  495. * Another thread has already started finalizing
  496. */
  497. if (lckInstance->finalize) {
  498. pthread_mutex_unlock (&lckInstance->response_mutex);
  499. saHandleInstancePut (&lckHandleDatabase, lckHandle);
  500. return (SA_AIS_ERR_BAD_HANDLE);
  501. }
  502. lckInstance->finalize = 1;
  503. pthread_mutex_unlock (&lckInstance->response_mutex);
  504. // TODO lckInstanceFinalize (lckInstance);
  505. if (lckInstance->response_fd != -1) {
  506. shutdown (lckInstance->response_fd, 0);
  507. close (lckInstance->response_fd);
  508. }
  509. if (lckInstance->dispatch_fd != -1) {
  510. shutdown (lckInstance->dispatch_fd, 0);
  511. close (lckInstance->dispatch_fd);
  512. }
  513. saHandleInstancePut (&lckHandleDatabase, lckHandle);
  514. return (SA_AIS_OK);
  515. }
  516. SaAisErrorT
  517. saLckResourceOpen (
  518. SaLckHandleT lckHandle,
  519. const SaNameT *lockResourceName,
  520. SaLckResourceOpenFlagsT resourceOpenFlags,
  521. SaTimeT timeout,
  522. SaLckResourceHandleT *lckResourceHandle)
  523. {
  524. SaAisErrorT error;
  525. struct lckResourceInstance *lckResourceInstance;
  526. struct lckInstance *lckInstance;
  527. struct req_lib_lck_resourceopen req_lib_lck_resourceopen;
  528. struct res_lib_lck_resourceopen res_lib_lck_resourceopen;
  529. if (lckResourceHandle == NULL) {
  530. return (SA_AIS_ERR_INVALID_PARAM);
  531. }
  532. if (lockResourceName == NULL) {
  533. return (SA_AIS_ERR_INVALID_PARAM);
  534. }
  535. error = saHandleInstanceGet (&lckHandleDatabase, lckHandle,
  536. (void *)&lckInstance);
  537. if (error != SA_AIS_OK) {
  538. goto error_exit;
  539. }
  540. error = saHandleCreate (&lckResourceHandleDatabase,
  541. sizeof (struct lckResourceInstance), lckResourceHandle);
  542. if (error != SA_AIS_OK) {
  543. goto error_put_lck;
  544. }
  545. error = saHandleInstanceGet (&lckResourceHandleDatabase,
  546. *lckResourceHandle, (void *)&lckResourceInstance);
  547. if (error != SA_AIS_OK) {
  548. goto error_destroy;
  549. }
  550. lckResourceInstance->response_fd = lckInstance->response_fd;
  551. lckResourceInstance->lckHandle = lckHandle;
  552. lckResourceInstance->lckResourceHandle = *lckResourceHandle;
  553. lckResourceInstance->response_mutex = &lckInstance->response_mutex;
  554. req_lib_lck_resourceopen.header.size = sizeof (struct req_lib_lck_resourceopen);
  555. req_lib_lck_resourceopen.header.id = MESSAGE_REQ_LCK_RESOURCEOPEN;
  556. memcpy (&req_lib_lck_resourceopen.lockResourceName, lockResourceName, sizeof (SaNameT));
  557. memcpy (&lckResourceInstance->lockResourceName, lockResourceName, sizeof (SaNameT));
  558. req_lib_lck_resourceopen.resourceOpenFlags = resourceOpenFlags;
  559. req_lib_lck_resourceopen.resourceHandle = *lckResourceHandle;
  560. req_lib_lck_resourceopen.async_call = 0;
  561. pthread_mutex_lock (&lckInstance->response_mutex);
  562. error = saSendReceiveReply (lckResourceInstance->response_fd,
  563. &req_lib_lck_resourceopen,
  564. sizeof (struct req_lib_lck_resourceopen),
  565. &res_lib_lck_resourceopen,
  566. sizeof (struct res_lib_lck_resourceopen));
  567. pthread_mutex_unlock (&lckInstance->response_mutex);
  568. if (res_lib_lck_resourceopen.header.error != SA_AIS_OK) {
  569. error = res_lib_lck_resourceopen.header.error;
  570. goto error_put_destroy;
  571. }
  572. memcpy (&lckResourceInstance->source,
  573. &res_lib_lck_resourceopen.source,
  574. sizeof (struct message_source));
  575. saHandleInstancePut (&lckResourceHandleDatabase, *lckResourceHandle);
  576. saHandleInstancePut (&lckHandleDatabase, lckHandle);
  577. list_init (&lckResourceInstance->list);
  578. list_add (&lckResourceInstance->list, &lckInstance->resource_list);
  579. return (error);
  580. error_put_destroy:
  581. saHandleInstancePut (&lckResourceHandleDatabase, *lckResourceHandle);
  582. error_destroy:
  583. saHandleDestroy (&lckResourceHandleDatabase, *lckResourceHandle);
  584. error_put_lck:
  585. saHandleInstancePut (&lckHandleDatabase, lckHandle);
  586. error_exit:
  587. return (error);
  588. }
  589. SaAisErrorT
  590. saLckResourceOpenAsync (
  591. SaLckHandleT lckHandle,
  592. SaInvocationT invocation,
  593. const SaNameT *lockResourceName,
  594. SaLckResourceOpenFlagsT resourceOpenFlags)
  595. {
  596. struct lckResourceInstance *lckResourceInstance;
  597. struct lckInstance *lckInstance;
  598. SaLckResourceHandleT lckResourceHandle;
  599. SaAisErrorT error;
  600. struct req_lib_lck_resourceopen req_lib_lck_resourceopen;
  601. struct res_lib_lck_resourceopenasync res_lib_lck_resourceopenasync;
  602. error = saHandleInstanceGet (&lckHandleDatabase, lckHandle,
  603. (void *)&lckInstance);
  604. if (error != SA_AIS_OK) {
  605. goto error_exit;
  606. }
  607. if (lckInstance->callbacks.saLckResourceOpenCallback == NULL) {
  608. error = SA_AIS_ERR_INIT;
  609. goto error_put_lck;
  610. }
  611. error = saHandleCreate (&lckResourceHandleDatabase,
  612. sizeof (struct lckResourceInstance), &lckResourceHandle);
  613. if (error != SA_AIS_OK) {
  614. goto error_put_lck;
  615. }
  616. error = saHandleInstanceGet (&lckResourceHandleDatabase, lckResourceHandle,
  617. (void *)&lckResourceInstance);
  618. if (error != SA_AIS_OK) {
  619. goto error_destroy;
  620. }
  621. lckResourceInstance->response_fd = lckInstance->response_fd;
  622. lckResourceInstance->response_mutex = &lckInstance->response_mutex;
  623. lckResourceInstance->lckHandle = lckHandle;
  624. lckResourceInstance->lckResourceHandle = lckResourceHandle;
  625. lckResourceInstance->resourceOpenFlags = resourceOpenFlags;
  626. memcpy (&lckResourceInstance->lockResourceName, lockResourceName, sizeof (SaNameT));
  627. req_lib_lck_resourceopen.header.size = sizeof (struct req_lib_lck_resourceopen);
  628. req_lib_lck_resourceopen.header.id = MESSAGE_REQ_LCK_RESOURCEOPENASYNC;
  629. req_lib_lck_resourceopen.invocation = invocation;
  630. req_lib_lck_resourceopen.resourceOpenFlags = resourceOpenFlags;
  631. req_lib_lck_resourceopen.resourceHandle = lckResourceHandle;
  632. req_lib_lck_resourceopen.async_call = 1;
  633. pthread_mutex_lock (&lckInstance->response_mutex);
  634. error = saSendReceiveReply (lckResourceInstance->response_fd,
  635. &req_lib_lck_resourceopen,
  636. sizeof (struct req_lib_lck_resourceopen),
  637. &res_lib_lck_resourceopenasync,
  638. sizeof (struct res_lib_lck_resourceopenasync));
  639. pthread_mutex_unlock (&lckInstance->response_mutex);
  640. if (error == SA_AIS_OK) {
  641. saHandleInstancePut (&lckResourceHandleDatabase,
  642. lckResourceHandle);
  643. saHandleInstancePut (&lckHandleDatabase, lckHandle);
  644. return (res_lib_lck_resourceopenasync.header.error);
  645. }
  646. saHandleInstancePut (&lckResourceHandleDatabase, lckResourceHandle);
  647. error_destroy:
  648. saHandleDestroy (&lckResourceHandleDatabase, lckResourceHandle);
  649. error_put_lck:
  650. saHandleInstancePut (&lckHandleDatabase, lckHandle);
  651. error_exit:
  652. return (error);
  653. }
  654. SaAisErrorT
  655. saLckResourceClose (
  656. SaLckResourceHandleT lckResourceHandle)
  657. {
  658. struct req_lib_lck_resourceclose req_lib_lck_resourceclose;
  659. struct res_lib_lck_resourceclose res_lib_lck_resourceclose;
  660. SaAisErrorT error;
  661. struct lckResourceInstance *lckResourceInstance;
  662. error = saHandleInstanceGet (&lckResourceHandleDatabase, lckResourceHandle,
  663. (void *)&lckResourceInstance);
  664. if (error != SA_AIS_OK) {
  665. return (error);
  666. }
  667. req_lib_lck_resourceclose.header.size = sizeof (struct req_lib_lck_resourceclose);
  668. req_lib_lck_resourceclose.header.id = MESSAGE_REQ_LCK_RESOURCECLOSE;
  669. memcpy (&req_lib_lck_resourceclose.lockResourceName,
  670. &lckResourceInstance->lockResourceName, sizeof (SaNameT));
  671. req_lib_lck_resourceclose.resourceHandle = lckResourceHandle;
  672. pthread_mutex_lock (lckResourceInstance->response_mutex);
  673. error = saSendReceiveReply (lckResourceInstance->response_fd,
  674. &req_lib_lck_resourceclose,
  675. sizeof (struct req_lib_lck_resourceclose),
  676. &res_lib_lck_resourceclose,
  677. sizeof (struct res_lib_lck_resourceclose));
  678. pthread_mutex_unlock (lckResourceInstance->response_mutex);
  679. saHandleInstancePut (&lckResourceHandleDatabase, lckResourceHandle);
  680. saHandleDestroy (&lckResourceHandleDatabase, lckResourceHandle);
  681. return (error == SA_AIS_OK ? res_lib_lck_resourceclose.header.error : error);
  682. }
  683. SaAisErrorT
  684. saLckResourceLock (
  685. SaLckResourceHandleT lckResourceHandle,
  686. SaLckLockIdT *lockId,
  687. SaLckLockModeT lockMode,
  688. SaLckLockFlagsT lockFlags,
  689. SaLckWaiterSignalT waiterSignal,
  690. SaTimeT timeout,
  691. SaLckLockStatusT *lockStatus)
  692. {
  693. struct req_lib_lck_resourcelock req_lib_lck_resourcelock;
  694. struct res_lib_lck_resourcelock res_lib_lck_resourcelock;
  695. SaAisErrorT error;
  696. struct lckResourceInstance *lckResourceInstance;
  697. struct lckLockIdInstance *lckLockIdInstance;
  698. int lock_fd;
  699. int dummy_fd;
  700. error = saHandleInstanceGet (&lckResourceHandleDatabase, lckResourceHandle,
  701. (void *)&lckResourceInstance);
  702. if (error != SA_AIS_OK) {
  703. return (error);
  704. }
  705. error = saHandleCreate (&lckLockIdHandleDatabase,
  706. sizeof (struct lckLockIdInstance), lockId);
  707. if (error != SA_AIS_OK) {
  708. goto error_put_lck;
  709. }
  710. error = saHandleInstanceGet (&lckLockIdHandleDatabase, *lockId,
  711. (void *)&lckLockIdInstance);
  712. if (error != SA_AIS_OK) {
  713. goto error_destroy;
  714. }
  715. error = saServiceConnectTwo (&lock_fd, &dummy_fd, LCK_SERVICE);
  716. if (error != SA_AIS_OK) { // TODO error handling
  717. goto error_destroy;
  718. }
  719. lckLockIdInstance->response_mutex = lckResourceInstance->response_mutex;
  720. lckLockIdInstance->response_fd = lckResourceInstance->response_fd;
  721. lckLockIdInstance->lckResourceHandle = lckResourceHandle;
  722. req_lib_lck_resourcelock.header.size = sizeof (struct req_lib_lck_resourcelock);
  723. req_lib_lck_resourcelock.header.id = MESSAGE_REQ_LCK_RESOURCELOCK;
  724. memcpy (&req_lib_lck_resourcelock.lockResourceName,
  725. &lckResourceInstance->lockResourceName, sizeof (SaNameT));
  726. req_lib_lck_resourcelock.lockMode = lockMode;
  727. req_lib_lck_resourcelock.lockFlags = lockFlags;
  728. req_lib_lck_resourcelock.waiterSignal = waiterSignal;
  729. req_lib_lck_resourcelock.lockId = *lockId;
  730. req_lib_lck_resourcelock.async_call = 0;
  731. req_lib_lck_resourcelock.invocation = 0;
  732. req_lib_lck_resourcelock.resourceHandle = lckResourceHandle;
  733. memcpy (&req_lib_lck_resourcelock.source,
  734. &lckResourceInstance->source,
  735. sizeof (struct message_source));
  736. /*
  737. * no mutex needed here since its a new connection
  738. */
  739. error = saSendReceiveReply (lock_fd,
  740. &req_lib_lck_resourcelock,
  741. sizeof (struct req_lib_lck_resourcelock),
  742. &res_lib_lck_resourcelock,
  743. sizeof (struct res_lib_lck_resourcelock));
  744. close (lock_fd);
  745. close (dummy_fd);
  746. if (error == SA_AIS_OK) {
  747. lckLockIdInstance->resource_lock = res_lib_lck_resourcelock.resource_lock;
  748. *lockStatus = res_lib_lck_resourcelock.lockStatus;
  749. return (res_lib_lck_resourcelock.header.error);
  750. }
  751. /*
  752. * Error
  753. */
  754. saHandleInstancePut (&lckLockIdHandleDatabase, *lockId);
  755. error_destroy:
  756. saHandleDestroy (&lckLockIdHandleDatabase, *lockId);
  757. error_put_lck:
  758. saHandleInstancePut (&lckResourceHandleDatabase, lckResourceHandle);
  759. return (error);
  760. }
  761. SaAisErrorT
  762. saLckResourceLockAsync (
  763. SaLckResourceHandleT lckResourceHandle,
  764. SaInvocationT invocation,
  765. SaLckLockIdT *lockId,
  766. SaLckLockModeT lockMode,
  767. SaLckLockFlagsT lockFlags,
  768. SaLckWaiterSignalT waiterSignal)
  769. {
  770. struct req_lib_lck_resourcelock req_lib_lck_resourcelock;
  771. struct res_lib_lck_resourcelockasync res_lib_lck_resourcelockasync;
  772. SaAisErrorT error;
  773. struct lckResourceInstance *lckResourceInstance;
  774. struct lckLockIdInstance *lckLockIdInstance;
  775. int lock_fd;
  776. int dummy_fd;
  777. error = saHandleInstanceGet (&lckResourceHandleDatabase, lckResourceHandle,
  778. (void *)&lckResourceInstance);
  779. if (error != SA_AIS_OK) {
  780. return (error);
  781. }
  782. error = saHandleCreate (&lckLockIdHandleDatabase,
  783. sizeof (struct lckLockIdInstance), lockId);
  784. if (error != SA_AIS_OK) {
  785. goto error_put_lck;
  786. }
  787. error = saHandleInstanceGet (&lckLockIdHandleDatabase, *lockId,
  788. (void *)&lckLockIdInstance);
  789. if (error != SA_AIS_OK) {
  790. goto error_destroy;
  791. }
  792. error = saServiceConnectTwo (&lock_fd, &dummy_fd, LCK_SERVICE);
  793. if (error != SA_AIS_OK) { // TODO error handling
  794. goto error_destroy;
  795. }
  796. lckLockIdInstance->response_mutex = lckResourceInstance->response_mutex;
  797. lckLockIdInstance->response_fd = lckResourceInstance->response_fd;
  798. lckLockIdInstance->lckResourceHandle = lckResourceHandle;
  799. req_lib_lck_resourcelock.header.size = sizeof (struct req_lib_lck_resourcelock);
  800. req_lib_lck_resourcelock.header.id = MESSAGE_REQ_LCK_RESOURCELOCKASYNC;
  801. memcpy (&req_lib_lck_resourcelock.lockResourceName,
  802. &lckResourceInstance->lockResourceName, sizeof (SaNameT));
  803. req_lib_lck_resourcelock.lockMode = lockMode;
  804. req_lib_lck_resourcelock.lockFlags = lockFlags;
  805. req_lib_lck_resourcelock.waiterSignal = waiterSignal;
  806. req_lib_lck_resourcelock.lockId = *lockId;
  807. req_lib_lck_resourcelock.async_call = 1;
  808. req_lib_lck_resourcelock.invocation = invocation;
  809. req_lib_lck_resourcelock.resourceHandle = lckResourceHandle;
  810. memcpy (&req_lib_lck_resourcelock.source,
  811. &lckResourceInstance->source,
  812. sizeof (struct message_source));
  813. /*
  814. * no mutex needed here since its a new connection
  815. */
  816. error = saSendReceiveReply (lock_fd,
  817. &req_lib_lck_resourcelock,
  818. sizeof (struct req_lib_lck_resourcelock),
  819. &res_lib_lck_resourcelockasync,
  820. sizeof (struct res_lib_lck_resourcelock));
  821. close (lock_fd);
  822. close (dummy_fd);
  823. if (error == SA_AIS_OK) {
  824. return (res_lib_lck_resourcelockasync.header.error);
  825. }
  826. /*
  827. * Error
  828. */
  829. saHandleInstancePut (&lckLockIdHandleDatabase, *lockId);
  830. error_destroy:
  831. saHandleDestroy (&lckLockIdHandleDatabase, *lockId);
  832. error_put_lck:
  833. saHandleInstancePut (&lckResourceHandleDatabase, lckResourceHandle);
  834. return (error);
  835. }
  836. SaAisErrorT
  837. saLckResourceUnlock (
  838. SaLckLockIdT lockId,
  839. SaTimeT timeout)
  840. {
  841. struct req_lib_lck_resourceunlock req_lib_lck_resourceunlock;
  842. struct res_lib_lck_resourceunlock res_lib_lck_resourceunlock;
  843. SaAisErrorT error;
  844. struct lckLockIdInstance *lckLockIdInstance;
  845. struct lckResourceInstance *lckResourceInstance;
  846. error = saHandleInstanceGet (&lckLockIdHandleDatabase, lockId,
  847. (void *)&lckLockIdInstance);
  848. if (error != SA_AIS_OK) {
  849. return (error);
  850. }
  851. /*
  852. * Retrieve resource name
  853. */
  854. error = saHandleInstanceGet (&lckResourceHandleDatabase,
  855. lckLockIdInstance->lckResourceHandle, (void *)&lckResourceInstance);
  856. if (error != SA_AIS_OK) {
  857. saHandleInstancePut (&lckLockIdHandleDatabase, lockId);
  858. return (error);
  859. }
  860. memcpy (&req_lib_lck_resourceunlock.lockResourceName,
  861. &lckResourceInstance->lockResourceName, sizeof (SaNameT));
  862. saHandleInstancePut (&lckResourceHandleDatabase,
  863. lckLockIdInstance->lckResourceHandle);
  864. req_lib_lck_resourceunlock.header.size = sizeof (struct req_lib_lck_resourceunlock);
  865. req_lib_lck_resourceunlock.header.id = MESSAGE_REQ_LCK_RESOURCEUNLOCK;
  866. req_lib_lck_resourceunlock.lockId = lockId;
  867. req_lib_lck_resourceunlock.timeout = timeout;
  868. req_lib_lck_resourceunlock.invocation = -1;
  869. req_lib_lck_resourceunlock.async_call = 0;
  870. req_lib_lck_resourceunlock.resource_lock = lckLockIdInstance->resource_lock;
  871. pthread_mutex_lock (lckLockIdInstance->response_mutex);
  872. error = saSendReceiveReply (lckLockIdInstance->response_fd,
  873. &req_lib_lck_resourceunlock,
  874. sizeof (struct req_lib_lck_resourceunlock),
  875. &res_lib_lck_resourceunlock,
  876. sizeof (struct res_lib_lck_resourceunlock));
  877. pthread_mutex_unlock (lckLockIdInstance->response_mutex);
  878. saHandleInstancePut (&lckLockIdHandleDatabase, lockId);
  879. saHandleDestroy (&lckLockIdHandleDatabase, lockId);
  880. return (error == SA_AIS_OK ? res_lib_lck_resourceunlock.header.error : error);
  881. }
  882. SaAisErrorT
  883. saLckResourceUnlockAsync (
  884. SaInvocationT invocation,
  885. SaLckLockIdT lockId)
  886. {
  887. struct req_lib_lck_resourceunlock req_lib_lck_resourceunlock;
  888. struct res_lib_lck_resourceunlockasync res_lib_lck_resourceunlockasync;
  889. SaAisErrorT error;
  890. struct lckLockIdInstance *lckLockIdInstance;
  891. struct lckResourceInstance *lckResourceInstance;
  892. error = saHandleInstanceGet (&lckLockIdHandleDatabase, lockId,
  893. (void *)&lckLockIdInstance);
  894. if (error != SA_AIS_OK) {
  895. return (error);
  896. }
  897. /*
  898. * Retrieve resource name
  899. */
  900. error = saHandleInstanceGet (&lckResourceHandleDatabase,
  901. lckLockIdInstance->lckResourceHandle, (void *)&lckResourceInstance);
  902. if (error != SA_AIS_OK) {
  903. saHandleInstancePut (&lckLockIdHandleDatabase, lockId);
  904. return (error);
  905. }
  906. memcpy (&req_lib_lck_resourceunlock.lockResourceName,
  907. &lckResourceInstance->lockResourceName, sizeof (SaNameT));
  908. saHandleInstancePut (&lckResourceHandleDatabase,
  909. lckLockIdInstance->lckResourceHandle);
  910. /*
  911. * Build and send request
  912. */
  913. req_lib_lck_resourceunlock.header.size = sizeof (struct req_lib_lck_resourceunlock);
  914. req_lib_lck_resourceunlock.header.id = MESSAGE_REQ_LCK_RESOURCEUNLOCKASYNC;
  915. req_lib_lck_resourceunlock.invocation = invocation;
  916. req_lib_lck_resourceunlock.lockId = lockId;
  917. req_lib_lck_resourceunlock.async_call = 1;
  918. pthread_mutex_lock (lckLockIdInstance->response_mutex);
  919. error = saSendReceiveReply (lckLockIdInstance->response_fd,
  920. &req_lib_lck_resourceunlock,
  921. sizeof (struct req_lib_lck_resourceunlock),
  922. &res_lib_lck_resourceunlockasync,
  923. sizeof (struct res_lib_lck_resourceunlockasync));
  924. pthread_mutex_unlock (lckLockIdInstance->response_mutex);
  925. saHandleInstancePut (&lckLockIdHandleDatabase, lockId);
  926. return (error == SA_AIS_OK ? res_lib_lck_resourceunlockasync.header.error : error);
  927. }
  928. SaAisErrorT
  929. saLckLockPurge (
  930. SaLckResourceHandleT lckResourceHandle)
  931. {
  932. struct req_lib_lck_lockpurge req_lib_lck_lockpurge;
  933. struct res_lib_lck_lockpurge res_lib_lck_lockpurge;
  934. SaAisErrorT error;
  935. struct lckResourceInstance *lckResourceInstance;
  936. error = saHandleInstanceGet (&lckResourceHandleDatabase, lckResourceHandle,
  937. (void *)&lckResourceInstance);
  938. if (error != SA_AIS_OK) {
  939. return (error);
  940. }
  941. req_lib_lck_lockpurge.header.size = sizeof (struct req_lib_lck_lockpurge);
  942. req_lib_lck_lockpurge.header.id = MESSAGE_REQ_LCK_LOCKPURGE;
  943. memcpy (&req_lib_lck_lockpurge.lockResourceName,
  944. &lckResourceInstance->lockResourceName, sizeof (SaNameT));
  945. pthread_mutex_lock (lckResourceInstance->response_mutex);
  946. error = saSendReceiveReply (lckResourceInstance->response_fd,
  947. &req_lib_lck_lockpurge,
  948. sizeof (struct req_lib_lck_lockpurge),
  949. &res_lib_lck_lockpurge,
  950. sizeof (struct res_lib_lck_lockpurge));
  951. pthread_mutex_unlock (lckResourceInstance->response_mutex);
  952. saHandleInstancePut (&lckResourceHandleDatabase, lckResourceHandle);
  953. return (error == SA_AIS_OK ? res_lib_lck_lockpurge.header.error : error);
  954. }