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;
  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_resourceopen res_lib_lck_resourceopen;
  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. 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_resourceopen,
  638. sizeof (struct res_lib_lck_resourceopen));
  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_resourceopen.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. }