ckpt.c 49 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564
  1. /*
  2. * Copyright (c) 2002-2004 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 "util.h"
  47. #include "../include/list.h"
  48. #include "../include/saCkpt.h"
  49. #include "../include/ipc_gen.h"
  50. #include "../include/ipc_ckpt.h"
  51. struct message_overlay {
  52. struct res_header header;
  53. char data[4096];
  54. };
  55. /*
  56. * Data structure for instance data
  57. */
  58. struct ckptInstance {
  59. int response_fd;
  60. int dispatch_fd;
  61. SaCkptCallbacksT callbacks;
  62. int finalize;
  63. pthread_mutex_t response_mutex;
  64. pthread_mutex_t dispatch_mutex;
  65. struct list_head checkpoint_list;
  66. };
  67. struct ckptCheckpointInstance {
  68. int response_fd;
  69. SaCkptHandleT ckptHandle;
  70. SaCkptCheckpointHandleT checkpointHandle;
  71. SaCkptCheckpointOpenFlagsT checkpointOpenFlags;
  72. SaNameT checkpointName;
  73. pthread_mutex_t response_mutex;
  74. struct list_head list;
  75. };
  76. struct ckptSectionIterationInstance {
  77. int response_fd;
  78. SaCkptCheckpointHandleT checkpointHandle;
  79. struct list_head sectionIdListHead;
  80. pthread_mutex_t response_mutex;
  81. };
  82. void ckptHandleInstanceDestructor (void *instance);
  83. void checkpointHandleInstanceDestructor (void *instance);
  84. void ckptSectionIterationHandleInstanceDestructor (void *instance);
  85. /*
  86. * All CKPT instances in this database
  87. */
  88. static struct saHandleDatabase ckptHandleDatabase = {
  89. .handleCount = 0,
  90. .handles = 0,
  91. .mutex = PTHREAD_MUTEX_INITIALIZER,
  92. .handleInstanceDestructor = ckptHandleInstanceDestructor
  93. };
  94. /*
  95. * All Checkpoint instances in this database
  96. */
  97. static struct saHandleDatabase checkpointHandleDatabase = {
  98. .handleCount = 0,
  99. .handles = 0,
  100. .mutex = PTHREAD_MUTEX_INITIALIZER,
  101. .handleInstanceDestructor = checkpointHandleInstanceDestructor
  102. };
  103. /*
  104. * All section iterators in this database
  105. */
  106. static struct saHandleDatabase ckptSectionIterationHandleDatabase = {
  107. .handleCount = 0,
  108. .handles = 0,
  109. .mutex = PTHREAD_MUTEX_INITIALIZER,
  110. .handleInstanceDestructor = ckptSectionIterationHandleInstanceDestructor
  111. };
  112. /*
  113. * Versions supported
  114. */
  115. static SaVersionT ckptVersionsSupported[] = {
  116. { 'B', 1, 1 },
  117. { 'b', 1, 1 }
  118. };
  119. static struct saVersionDatabase ckptVersionDatabase = {
  120. sizeof (ckptVersionsSupported) / sizeof (SaVersionT),
  121. ckptVersionsSupported
  122. };
  123. /*
  124. * Implementation
  125. */
  126. void ckptHandleInstanceDestructor (void *instance)
  127. {
  128. struct ckptInstance *ckptInstance = (struct ckptInstance *)instance;
  129. if (ckptInstance->response_fd != -1) {
  130. shutdown (ckptInstance->response_fd, 0);
  131. close (ckptInstance->response_fd);
  132. }
  133. }
  134. void checkpointHandleInstanceDestructor (void *instance)
  135. {
  136. return;
  137. }
  138. void ckptSectionIterationHandleInstanceDestructor (void *instance)
  139. {
  140. struct ckptSectionIterationInstance *ckptSectionIterationInstance = (struct ckptSectionIterationInstance *)instance;
  141. if (ckptSectionIterationInstance->response_fd != -1) {
  142. shutdown (ckptSectionIterationInstance->response_fd, 0);
  143. close (ckptSectionIterationInstance->response_fd);
  144. }
  145. }
  146. SaAisErrorT
  147. saCkptInitialize (
  148. SaCkptHandleT *ckptHandle,
  149. const SaCkptCallbacksT *callbacks,
  150. SaVersionT *version)
  151. {
  152. struct ckptInstance *ckptInstance;
  153. SaAisErrorT error = SA_AIS_OK;
  154. error = saVersionVerify (&ckptVersionDatabase, version);
  155. if (error != SA_AIS_OK) {
  156. goto error_no_destroy;
  157. }
  158. error = saHandleCreate (&ckptHandleDatabase, sizeof (struct ckptInstance),
  159. ckptHandle);
  160. if (error != SA_AIS_OK) {
  161. goto error_no_destroy;
  162. }
  163. error = saHandleInstanceGet (&ckptHandleDatabase, *ckptHandle,
  164. (void *)&ckptInstance);
  165. if (error != SA_AIS_OK) {
  166. goto error_destroy;
  167. }
  168. ckptInstance->response_fd = -1;
  169. error = saServiceConnectTwo (&ckptInstance->response_fd,
  170. &ckptInstance->dispatch_fd, CKPT_SERVICE);
  171. if (error != SA_AIS_OK) {
  172. goto error_put_destroy;
  173. }
  174. memcpy (&ckptInstance->callbacks, callbacks, sizeof (SaCkptCallbacksT));
  175. list_init (&ckptInstance->checkpoint_list);
  176. pthread_mutex_init (&ckptInstance->response_mutex, NULL);
  177. saHandleInstancePut (&ckptHandleDatabase, *ckptHandle);
  178. return (SA_AIS_OK);
  179. error_put_destroy:
  180. saHandleInstancePut (&ckptHandleDatabase, *ckptHandle);
  181. error_destroy:
  182. saHandleDestroy (&ckptHandleDatabase, *ckptHandle);
  183. error_no_destroy:
  184. return (error);
  185. }
  186. SaAisErrorT
  187. saCkptSelectionObjectGet (
  188. const SaCkptHandleT ckptHandle,
  189. SaSelectionObjectT *selectionObject)
  190. {
  191. struct ckptInstance *ckptInstance;
  192. SaAisErrorT error;
  193. error = saHandleInstanceGet (&ckptHandleDatabase, ckptHandle, (void *)&ckptInstance);
  194. if (error != SA_AIS_OK) {
  195. return (error);
  196. }
  197. *selectionObject = ckptInstance->dispatch_fd;
  198. saHandleInstancePut (&ckptHandleDatabase, ckptHandle);
  199. return (SA_AIS_OK);
  200. }
  201. SaAisErrorT
  202. saCkptDispatch (
  203. const SaCkptHandleT ckptHandle,
  204. SaDispatchFlagsT dispatchFlags)
  205. {
  206. struct pollfd ufds;
  207. int poll_fd;
  208. int timeout = 1;
  209. SaCkptCallbacksT callbacks;
  210. SaAisErrorT error;
  211. int dispatch_avail;
  212. struct ckptInstance *ckptInstance;
  213. int cont = 1; /* always continue do loop except when set to 0 */
  214. struct message_overlay dispatch_data;
  215. struct res_lib_ckpt_checkpointopenasync *res_lib_ckpt_checkpointopenasync;
  216. struct ckptCheckpointInstance *ckptCheckpointInstance;
  217. error = saHandleInstanceGet (&ckptHandleDatabase, ckptHandle,
  218. (void *)&ckptInstance);
  219. if (error != SA_AIS_OK) {
  220. goto error_exit;
  221. }
  222. /*
  223. * Timeout instantly for SA_DISPATCH_ALL
  224. */
  225. if (dispatchFlags == SA_DISPATCH_ALL) {
  226. timeout = 0;
  227. }
  228. do {
  229. /*
  230. * Read data directly from socket
  231. */
  232. poll_fd = ckptInstance->dispatch_fd;
  233. ufds.fd = poll_fd;
  234. ufds.events = POLLIN;
  235. ufds.revents = 0;
  236. error = saPollRetry(&ufds, 1, timeout);
  237. if (error != SA_AIS_OK) {
  238. goto error_put;
  239. }
  240. pthread_mutex_lock(&ckptInstance->dispatch_mutex);
  241. if (ckptInstance->finalize == 1) {
  242. error = SA_AIS_OK;
  243. goto error_unlock;
  244. }
  245. if ((ufds.revents & (POLLERR|POLLHUP|POLLNVAL)) != 0) {
  246. error = SA_AIS_ERR_BAD_HANDLE;
  247. goto error_unlock;
  248. }
  249. dispatch_avail = (ufds.revents & POLLIN);
  250. if (dispatch_avail == 0 && dispatchFlags == SA_DISPATCH_ALL) {
  251. pthread_mutex_unlock(&ckptInstance->dispatch_mutex);
  252. break; /* exit do while cont is 1 loop */
  253. } else
  254. if (dispatch_avail == 0) {
  255. pthread_mutex_unlock(&ckptInstance->dispatch_mutex);
  256. continue;
  257. }
  258. memset(&dispatch_data,0, sizeof(struct message_overlay));
  259. error = saRecvRetry (ckptInstance->dispatch_fd, &dispatch_data.header, sizeof (struct res_header), MSG_WAITALL | MSG_NOSIGNAL);
  260. if (error != SA_AIS_OK) {
  261. goto error_unlock;
  262. }
  263. if (dispatch_data.header.size > sizeof (struct res_header)) {
  264. error = saRecvRetry (ckptInstance->dispatch_fd, &dispatch_data.data,
  265. dispatch_data.header.size - sizeof (struct res_header),
  266. MSG_WAITALL | MSG_NOSIGNAL);
  267. if (error != SA_AIS_OK) {
  268. goto error_unlock;
  269. }
  270. }
  271. /*
  272. * Make copy of callbacks, message data, unlock instance,
  273. * and call callback. A risk of this dispatch method is that
  274. * the callback routines may operate at the same time that
  275. * CkptFinalize has been called in another thread.
  276. */
  277. memcpy(&callbacks,&ckptInstance->callbacks, sizeof(ckptInstance->callbacks));
  278. pthread_mutex_unlock(&ckptInstance->dispatch_mutex);
  279. /*
  280. * Dispatch incoming response
  281. */
  282. switch (dispatch_data.header.id) {
  283. case MESSAGE_RES_CKPT_CHECKPOINT_CHECKPOINTOPENASYNC:
  284. res_lib_ckpt_checkpointopenasync = (struct res_lib_ckpt_checkpointopenasync *) &dispatch_data;
  285. /*
  286. * This instance get/listadd/put required so that close
  287. * later has the proper list of checkpoints
  288. */
  289. error = saHandleInstanceGet (&checkpointHandleDatabase,
  290. res_lib_ckpt_checkpointopenasync->checkpointHandle,
  291. (void *)&ckptCheckpointInstance);
  292. assert (error == SA_AIS_OK); /* should only be valid handles here */
  293. if (res_lib_ckpt_checkpointopenasync->header.error == SA_AIS_OK) {
  294. /*
  295. * open succeeded without error
  296. */
  297. list_init (&ckptCheckpointInstance->list);
  298. list_add (&ckptCheckpointInstance->list,
  299. &ckptInstance->checkpoint_list);
  300. callbacks.saCkptCheckpointOpenCallback(
  301. res_lib_ckpt_checkpointopenasync->invocation,
  302. res_lib_ckpt_checkpointopenasync->checkpointHandle,
  303. res_lib_ckpt_checkpointopenasync->header.error);
  304. saHandleInstancePut (&checkpointHandleDatabase,
  305. res_lib_ckpt_checkpointopenasync->checkpointHandle);
  306. } else {
  307. /*
  308. * open failed with error
  309. */
  310. saHandleInstancePut (&checkpointHandleDatabase,
  311. res_lib_ckpt_checkpointopenasync->checkpointHandle);
  312. saHandleDestroy (&checkpointHandleDatabase,
  313. res_lib_ckpt_checkpointopenasync->checkpointHandle);
  314. callbacks.saCkptCheckpointOpenCallback(
  315. res_lib_ckpt_checkpointopenasync->invocation,
  316. -1,
  317. res_lib_ckpt_checkpointopenasync->header.error);
  318. }
  319. break;
  320. default:
  321. /* TODO */
  322. break;
  323. }
  324. /*
  325. * Determine if more messages should be processed
  326. */
  327. switch (dispatchFlags) {
  328. case SA_DISPATCH_ONE:
  329. cont = 0;
  330. break;
  331. case SA_DISPATCH_ALL:
  332. break;
  333. case SA_DISPATCH_BLOCKING:
  334. break;
  335. }
  336. } while (cont);
  337. error_unlock:
  338. pthread_mutex_unlock(&ckptInstance->dispatch_mutex);
  339. error_put:
  340. saHandleInstancePut(&ckptHandleDatabase, ckptHandle);
  341. error_exit:
  342. return (error);
  343. }
  344. SaAisErrorT
  345. saCkptFinalize (
  346. const SaCkptHandleT ckptHandle)
  347. {
  348. struct ckptInstance *ckptInstance;
  349. SaAisErrorT error;
  350. struct list_head *list;
  351. struct ckptCheckpointInstance *ckptCheckpointInstance;
  352. error = saHandleInstanceGet (&ckptHandleDatabase, ckptHandle,
  353. (void *)&ckptInstance);
  354. if (error != SA_AIS_OK) {
  355. return (error);
  356. }
  357. pthread_mutex_lock (&ckptInstance->response_mutex);
  358. /*
  359. * Another thread has already started finalizing
  360. */
  361. if (ckptInstance->finalize) {
  362. pthread_mutex_unlock (&ckptInstance->response_mutex);
  363. saHandleInstancePut (&ckptHandleDatabase, ckptHandle);
  364. return (SA_AIS_ERR_BAD_HANDLE);
  365. }
  366. ckptInstance->finalize = 1;
  367. pthread_mutex_unlock (&ckptInstance->response_mutex);
  368. for (list = ckptInstance->checkpoint_list.next;
  369. list != &ckptInstance->checkpoint_list;
  370. list = list->next) {
  371. ckptCheckpointInstance = list_entry (list,
  372. struct ckptCheckpointInstance, list);
  373. saHandleInstancePut (&checkpointHandleDatabase,
  374. ckptCheckpointInstance->checkpointHandle);
  375. }
  376. saHandleInstancePut (&ckptHandleDatabase, ckptHandle);
  377. saHandleDestroy (&ckptHandleDatabase, ckptHandle);
  378. return (SA_AIS_OK);
  379. }
  380. SaAisErrorT
  381. saCkptCheckpointOpen (
  382. SaCkptHandleT ckptHandle,
  383. const SaNameT *checkpointName,
  384. const SaCkptCheckpointCreationAttributesT *checkpointCreationAttributes,
  385. SaCkptCheckpointOpenFlagsT checkpointOpenFlags,
  386. SaTimeT timeout,
  387. SaCkptCheckpointHandleT *checkpointHandle)
  388. {
  389. SaAisErrorT error;
  390. struct ckptCheckpointInstance *ckptCheckpointInstance;
  391. struct ckptInstance *ckptInstance;
  392. struct req_lib_ckpt_checkpointopen req_lib_ckpt_checkpointopen;
  393. struct res_lib_ckpt_checkpointopen res_lib_ckpt_checkpointopen;
  394. if ((checkpointOpenFlags & SA_CKPT_CHECKPOINT_CREATE) &&
  395. checkpointCreationAttributes == NULL) {
  396. return (SA_AIS_ERR_INVALID_PARAM);
  397. }
  398. if (((checkpointOpenFlags & SA_CKPT_CHECKPOINT_CREATE) == 0) &&
  399. checkpointCreationAttributes != NULL) {
  400. return (SA_AIS_ERR_INVALID_PARAM);
  401. }
  402. error = saHandleInstanceGet (&ckptHandleDatabase, ckptHandle,
  403. (void *)&ckptInstance);
  404. if (error != SA_AIS_OK) {
  405. goto error_exit;
  406. }
  407. error = saHandleCreate (&checkpointHandleDatabase,
  408. sizeof (struct ckptCheckpointInstance), checkpointHandle);
  409. if (error != SA_AIS_OK) {
  410. goto error_put_ckpt;
  411. }
  412. error = saHandleInstanceGet (&checkpointHandleDatabase,
  413. *checkpointHandle, (void *)&ckptCheckpointInstance);
  414. if (error != SA_AIS_OK) {
  415. goto error_destroy;
  416. }
  417. ckptCheckpointInstance->response_fd = ckptInstance->response_fd;
  418. ckptCheckpointInstance->ckptHandle = ckptHandle;
  419. ckptCheckpointInstance->checkpointHandle = *checkpointHandle;
  420. ckptCheckpointInstance->checkpointOpenFlags = checkpointOpenFlags;
  421. req_lib_ckpt_checkpointopen.header.size = sizeof (struct req_lib_ckpt_checkpointopen);
  422. req_lib_ckpt_checkpointopen.header.id = MESSAGE_REQ_CKPT_CHECKPOINT_CHECKPOINTOPEN;
  423. memcpy (&req_lib_ckpt_checkpointopen.checkpointName, checkpointName, sizeof (SaNameT));
  424. memcpy (&ckptCheckpointInstance->checkpointName, checkpointName, sizeof (SaNameT));
  425. req_lib_ckpt_checkpointopen.checkpointCreationAttributesSet = 0;
  426. if (checkpointCreationAttributes) {
  427. memcpy (&req_lib_ckpt_checkpointopen.checkpointCreationAttributes,
  428. checkpointCreationAttributes,
  429. sizeof (SaCkptCheckpointCreationAttributesT));
  430. req_lib_ckpt_checkpointopen.checkpointCreationAttributesSet = 1;
  431. }
  432. req_lib_ckpt_checkpointopen.checkpointOpenFlags = checkpointOpenFlags;
  433. error = saSendRetry (ckptCheckpointInstance->response_fd, &req_lib_ckpt_checkpointopen,
  434. sizeof (struct req_lib_ckpt_checkpointopen), MSG_NOSIGNAL);
  435. if (error != SA_AIS_OK) {
  436. goto error_put_destroy;
  437. }
  438. error = saRecvRetry (ckptCheckpointInstance->response_fd, &res_lib_ckpt_checkpointopen,
  439. sizeof (struct res_lib_ckpt_checkpointopen), MSG_WAITALL | MSG_NOSIGNAL);
  440. if (error != SA_AIS_OK) {
  441. goto error_put_destroy;
  442. }
  443. if (res_lib_ckpt_checkpointopen.header.error != SA_AIS_OK) {
  444. error = res_lib_ckpt_checkpointopen.header.error;
  445. goto error_put_destroy;
  446. }
  447. pthread_mutex_init (&ckptCheckpointInstance->response_mutex, NULL);
  448. saHandleInstancePut (&checkpointHandleDatabase, *checkpointHandle);
  449. saHandleInstancePut (&ckptHandleDatabase, ckptHandle);
  450. list_init (&ckptCheckpointInstance->list);
  451. list_add (&ckptCheckpointInstance->list, &ckptInstance->checkpoint_list);
  452. return (error);
  453. error_put_destroy:
  454. saHandleInstancePut (&checkpointHandleDatabase, *checkpointHandle);
  455. error_destroy:
  456. saHandleDestroy (&checkpointHandleDatabase, *checkpointHandle);
  457. error_put_ckpt:
  458. saHandleInstancePut (&ckptHandleDatabase, ckptHandle);
  459. error_exit:
  460. return (error);
  461. }
  462. SaAisErrorT
  463. saCkptCheckpointOpenAsync (
  464. const SaCkptHandleT ckptHandle,
  465. SaInvocationT invocation,
  466. const SaNameT *checkpointName,
  467. const SaCkptCheckpointCreationAttributesT *checkpointCreationAttributes,
  468. SaCkptCheckpointOpenFlagsT checkpointOpenFlags)
  469. {
  470. struct ckptCheckpointInstance *ckptCheckpointInstance;
  471. struct ckptInstance *ckptInstance;
  472. SaCkptCheckpointHandleT checkpointHandle;
  473. SaAisErrorT error;
  474. struct req_lib_ckpt_checkpointopenasync req_lib_ckpt_checkpointopenasync;
  475. if ((checkpointOpenFlags & SA_CKPT_CHECKPOINT_CREATE) &&
  476. checkpointCreationAttributes == NULL) {
  477. return (SA_AIS_ERR_INVALID_PARAM);
  478. }
  479. if (((checkpointOpenFlags & SA_CKPT_CHECKPOINT_CREATE) == 0) &&
  480. checkpointCreationAttributes != NULL) {
  481. return (SA_AIS_ERR_INVALID_PARAM);
  482. }
  483. error = saHandleInstanceGet (&ckptHandleDatabase, ckptHandle,
  484. (void *)&ckptInstance);
  485. if (error != SA_AIS_OK) {
  486. goto error_exit;
  487. }
  488. error = saHandleCreate (&checkpointHandleDatabase,
  489. sizeof (struct ckptCheckpointInstance), &checkpointHandle);
  490. if (error != SA_AIS_OK) {
  491. goto error_put_ckpt;
  492. }
  493. error = saHandleInstanceGet (&checkpointHandleDatabase, checkpointHandle,
  494. (void *)&ckptCheckpointInstance);
  495. if (error != SA_AIS_OK) {
  496. goto error_destroy;
  497. }
  498. ckptCheckpointInstance->response_fd = ckptInstance->response_fd;
  499. ckptCheckpointInstance->ckptHandle = ckptHandle;
  500. ckptCheckpointInstance->checkpointHandle = checkpointHandle;
  501. ckptCheckpointInstance->checkpointOpenFlags = checkpointOpenFlags;
  502. memcpy (&ckptCheckpointInstance->checkpointName, checkpointName, sizeof (SaNameT));
  503. req_lib_ckpt_checkpointopenasync.header.size = sizeof (struct req_lib_ckpt_checkpointopenasync);
  504. req_lib_ckpt_checkpointopenasync.header.id = MESSAGE_REQ_CKPT_CHECKPOINT_CHECKPOINTOPENASYNC;
  505. req_lib_ckpt_checkpointopenasync.invocation = invocation;
  506. memcpy (&req_lib_ckpt_checkpointopenasync.checkpointName, checkpointName, sizeof (SaNameT));
  507. req_lib_ckpt_checkpointopenasync.checkpointCreationAttributesSet = 0;
  508. if (checkpointCreationAttributes) {
  509. memcpy (&req_lib_ckpt_checkpointopenasync.checkpointCreationAttributes,
  510. checkpointCreationAttributes,
  511. sizeof (SaCkptCheckpointCreationAttributesT));
  512. req_lib_ckpt_checkpointopenasync.checkpointCreationAttributesSet = 1;
  513. }
  514. req_lib_ckpt_checkpointopenasync.checkpointOpenFlags = checkpointOpenFlags;
  515. req_lib_ckpt_checkpointopenasync.checkpointHandle = checkpointHandle;
  516. error = saSendRetry (ckptInstance->response_fd, &req_lib_ckpt_checkpointopenasync,
  517. sizeof (struct req_lib_ckpt_checkpointopenasync), MSG_NOSIGNAL);
  518. if (error != SA_AIS_OK) {
  519. goto error_put_destroy;
  520. }
  521. pthread_mutex_init (&ckptCheckpointInstance->response_mutex, NULL);
  522. saHandleInstancePut (&checkpointHandleDatabase, checkpointHandle);
  523. saHandleInstancePut (&ckptHandleDatabase, ckptHandle);
  524. return (error);
  525. error_put_destroy:
  526. saHandleInstancePut (&checkpointHandleDatabase, checkpointHandle);
  527. error_destroy:
  528. saHandleDestroy (&checkpointHandleDatabase, checkpointHandle);
  529. error_put_ckpt:
  530. saHandleInstancePut (&ckptHandleDatabase, ckptHandle);
  531. error_exit:
  532. return (error);
  533. }
  534. SaAisErrorT
  535. saCkptCheckpointClose (
  536. SaCkptCheckpointHandleT checkpointHandle)
  537. {
  538. struct req_lib_ckpt_checkpointclose req_lib_ckpt_checkpointclose;
  539. struct res_lib_ckpt_checkpointclose res_lib_ckpt_checkpointclose;
  540. SaAisErrorT error;
  541. struct ckptCheckpointInstance *ckptCheckpointInstance;
  542. error = saHandleInstanceGet (&checkpointHandleDatabase, checkpointHandle,
  543. (void *)&ckptCheckpointInstance);
  544. if (error != SA_AIS_OK) {
  545. goto error_exit;
  546. }
  547. req_lib_ckpt_checkpointclose.header.size = sizeof (struct req_lib_ckpt_checkpointclose);
  548. req_lib_ckpt_checkpointclose.header.id = MESSAGE_REQ_CKPT_CHECKPOINT_CHECKPOINTCLOSE;
  549. memcpy (&req_lib_ckpt_checkpointclose.checkpointName,
  550. &ckptCheckpointInstance->checkpointName, sizeof (SaNameT));
  551. error = saSendRetry (ckptCheckpointInstance->response_fd, &req_lib_ckpt_checkpointclose,
  552. sizeof (struct req_lib_ckpt_checkpointclose), MSG_NOSIGNAL);
  553. if (error != SA_AIS_OK) {
  554. goto exit_put;
  555. }
  556. error = saRecvRetry (ckptCheckpointInstance->response_fd, &res_lib_ckpt_checkpointclose,
  557. sizeof (struct res_lib_ckpt_checkpointclose), MSG_WAITALL | MSG_NOSIGNAL);
  558. list_del (&ckptCheckpointInstance->list);
  559. saHandleDestroy (&checkpointHandleDatabase, checkpointHandle);
  560. exit_put:
  561. saHandleInstancePut (&checkpointHandleDatabase, checkpointHandle);
  562. error_exit:
  563. return (error);
  564. }
  565. SaAisErrorT
  566. saCkptCheckpointUnlink (
  567. SaCkptHandleT ckptHandle,
  568. const SaNameT *checkpointName)
  569. {
  570. SaAisErrorT error;
  571. struct ckptInstance *ckptInstance;
  572. struct req_lib_ckpt_checkpointunlink req_lib_ckpt_checkpointunlink;
  573. struct res_lib_ckpt_checkpointunlink res_lib_ckpt_checkpointunlink;
  574. error = saHandleInstanceGet (&ckptHandleDatabase, ckptHandle, (void *)&ckptInstance);
  575. if (error != SA_AIS_OK) {
  576. goto exit_noclose;
  577. }
  578. req_lib_ckpt_checkpointunlink.header.size = sizeof (struct req_lib_ckpt_checkpointunlink);
  579. req_lib_ckpt_checkpointunlink.header.id = MESSAGE_REQ_CKPT_CHECKPOINT_CHECKPOINTUNLINK;
  580. memcpy (&req_lib_ckpt_checkpointunlink.checkpointName, checkpointName, sizeof (SaNameT));
  581. error = saSendRetry (ckptInstance->response_fd, &req_lib_ckpt_checkpointunlink,
  582. sizeof (struct req_lib_ckpt_checkpointunlink), MSG_NOSIGNAL);
  583. if (error != SA_AIS_OK) {
  584. goto exit_put;
  585. }
  586. error = saRecvRetry (ckptInstance->response_fd, &res_lib_ckpt_checkpointunlink,
  587. sizeof (struct res_lib_ckpt_checkpointunlink), MSG_WAITALL | MSG_NOSIGNAL);
  588. exit_put:
  589. saHandleInstancePut (&ckptHandleDatabase, ckptHandle);
  590. return (error == SA_AIS_OK ? res_lib_ckpt_checkpointunlink.header.error : error);
  591. exit_noclose:
  592. return (error);
  593. }
  594. SaAisErrorT
  595. saCkptCheckpointRetentionDurationSet (
  596. SaCkptCheckpointHandleT checkpointHandle,
  597. SaTimeT retentionDuration)
  598. {
  599. SaAisErrorT error;
  600. struct ckptCheckpointInstance *ckptCheckpointInstance;
  601. struct req_lib_ckpt_checkpointretentiondurationset req_lib_ckpt_checkpointretentiondurationset;
  602. struct res_lib_ckpt_checkpointretentiondurationset res_lib_ckpt_checkpointretentiondurationset;
  603. error = saHandleInstanceGet (&checkpointHandleDatabase, checkpointHandle,
  604. (void *)&ckptCheckpointInstance);
  605. if (error != SA_AIS_OK) {
  606. goto error_exit_noput;
  607. }
  608. req_lib_ckpt_checkpointretentiondurationset.header.size = sizeof (struct req_lib_ckpt_checkpointretentiondurationset);
  609. req_lib_ckpt_checkpointretentiondurationset.header.id = MESSAGE_REQ_CKPT_CHECKPOINT_CHECKPOINTRETENTIONDURATIONSET;
  610. req_lib_ckpt_checkpointretentiondurationset.retentionDuration = retentionDuration;
  611. memcpy (&req_lib_ckpt_checkpointretentiondurationset.checkpointName,
  612. &ckptCheckpointInstance->checkpointName, sizeof (SaNameT));
  613. pthread_mutex_lock (&ckptCheckpointInstance->response_mutex);
  614. error = saSendRetry (ckptCheckpointInstance->response_fd, &req_lib_ckpt_checkpointretentiondurationset, sizeof (struct req_lib_ckpt_checkpointretentiondurationset), MSG_NOSIGNAL);
  615. if (error != SA_AIS_OK) {
  616. goto error_exit;
  617. }
  618. error = saRecvRetry (ckptCheckpointInstance->response_fd,
  619. &res_lib_ckpt_checkpointretentiondurationset,
  620. sizeof (struct res_lib_ckpt_checkpointretentiondurationset),
  621. MSG_WAITALL | MSG_NOSIGNAL);
  622. pthread_mutex_unlock (&ckptCheckpointInstance->response_mutex);
  623. error_exit:
  624. saHandleInstancePut (&checkpointHandleDatabase, checkpointHandle);
  625. error_exit_noput:
  626. return (error == SA_AIS_OK ? res_lib_ckpt_checkpointretentiondurationset.header.error : error);
  627. }
  628. SaAisErrorT
  629. saCkptActiveReplicaSet (
  630. SaCkptCheckpointHandleT checkpointHandle)
  631. {
  632. SaAisErrorT error;
  633. struct ckptCheckpointInstance *ckptCheckpointInstance;
  634. struct req_lib_ckpt_activereplicaset req_lib_ckpt_activereplicaset;
  635. struct res_lib_ckpt_activereplicaset res_lib_ckpt_activereplicaset;
  636. error = saHandleInstanceGet (&checkpointHandleDatabase, checkpointHandle,
  637. (void *)&ckptCheckpointInstance);
  638. if (error != SA_AIS_OK) {
  639. goto error_noput;
  640. }
  641. if ((ckptCheckpointInstance->checkpointOpenFlags & SA_CKPT_CHECKPOINT_WRITE) == 0) {
  642. error = SA_AIS_ERR_ACCESS;
  643. goto error_put;
  644. }
  645. req_lib_ckpt_activereplicaset.header.size = sizeof (struct req_lib_ckpt_activereplicaset);
  646. req_lib_ckpt_activereplicaset.header.id = MESSAGE_REQ_CKPT_ACTIVEREPLICASET;
  647. memcpy (&req_lib_ckpt_activereplicaset.checkpointName,
  648. &ckptCheckpointInstance->checkpointName, sizeof (SaNameT));
  649. pthread_mutex_lock (&ckptCheckpointInstance->response_mutex);
  650. error = saSendRetry (ckptCheckpointInstance->response_fd, &req_lib_ckpt_activereplicaset,
  651. sizeof (struct req_lib_ckpt_activereplicaset), MSG_NOSIGNAL);
  652. if (error != SA_AIS_OK) {
  653. goto error_put;
  654. }
  655. error = saRecvRetry (ckptCheckpointInstance->response_fd,
  656. &res_lib_ckpt_activereplicaset,
  657. sizeof (struct res_lib_ckpt_activereplicaset),
  658. MSG_WAITALL | MSG_NOSIGNAL);
  659. pthread_mutex_unlock (&ckptCheckpointInstance->response_mutex);
  660. error_put:
  661. saHandleInstancePut (&checkpointHandleDatabase, checkpointHandle);
  662. error_noput:
  663. return (error == SA_AIS_OK ? res_lib_ckpt_activereplicaset.header.error : error);
  664. }
  665. SaAisErrorT
  666. saCkptCheckpointStatusGet (
  667. SaCkptCheckpointHandleT checkpointHandle,
  668. SaCkptCheckpointDescriptorT *checkpointStatus)
  669. {
  670. SaAisErrorT error;
  671. struct ckptCheckpointInstance *ckptCheckpointInstance;
  672. struct req_lib_ckpt_checkpointstatusget req_lib_ckpt_checkpointstatusget;
  673. struct res_lib_ckpt_checkpointstatusget res_lib_ckpt_checkpointstatusget;
  674. error = saHandleInstanceGet (&checkpointHandleDatabase, checkpointHandle,
  675. (void *)&ckptCheckpointInstance);
  676. if (error != SA_AIS_OK) {
  677. return (error);
  678. }
  679. req_lib_ckpt_checkpointstatusget.header.size = sizeof (struct req_lib_ckpt_checkpointstatusget);
  680. req_lib_ckpt_checkpointstatusget.header.id = MESSAGE_REQ_CKPT_CHECKPOINT_CHECKPOINTSTATUSGET;
  681. memcpy (&req_lib_ckpt_checkpointstatusget.checkpointName,
  682. &ckptCheckpointInstance->checkpointName, sizeof (SaNameT));
  683. pthread_mutex_lock (&ckptCheckpointInstance->response_mutex);
  684. error = saSendRetry (ckptCheckpointInstance->response_fd, &req_lib_ckpt_checkpointstatusget,
  685. sizeof (struct req_lib_ckpt_checkpointstatusget), MSG_NOSIGNAL);
  686. if (error != SA_AIS_OK) {
  687. goto error_exit;
  688. }
  689. error = saRecvRetry (ckptCheckpointInstance->response_fd,
  690. &res_lib_ckpt_checkpointstatusget,
  691. sizeof (struct res_lib_ckpt_checkpointstatusget),
  692. MSG_WAITALL | MSG_NOSIGNAL);
  693. if (error != SA_AIS_OK) {
  694. goto error_exit;
  695. }
  696. pthread_mutex_unlock (&ckptCheckpointInstance->response_mutex);
  697. memcpy (checkpointStatus,
  698. &res_lib_ckpt_checkpointstatusget.checkpointDescriptor,
  699. sizeof (SaCkptCheckpointDescriptorT));
  700. error_exit:
  701. saHandleInstancePut (&checkpointHandleDatabase, checkpointHandle);
  702. return (error);
  703. }
  704. SaAisErrorT
  705. saCkptSectionCreate (
  706. SaCkptCheckpointHandleT checkpointHandle,
  707. SaCkptSectionCreationAttributesT *sectionCreationAttributes,
  708. const void *initialData,
  709. SaUint32T initialDataSize)
  710. {
  711. SaAisErrorT error;
  712. struct ckptCheckpointInstance *ckptCheckpointInstance;
  713. struct req_lib_ckpt_sectioncreate req_lib_ckpt_sectioncreate;
  714. struct res_lib_ckpt_sectioncreate res_lib_ckpt_sectioncreate;
  715. error = saHandleInstanceGet (&checkpointHandleDatabase, checkpointHandle,
  716. (void *)&ckptCheckpointInstance);
  717. if (error != SA_AIS_OK) {
  718. return (error);
  719. }
  720. if ((ckptCheckpointInstance->checkpointOpenFlags & SA_CKPT_CHECKPOINT_WRITE) == 0) {
  721. error = SA_AIS_ERR_ACCESS;
  722. goto error_exit;
  723. }
  724. req_lib_ckpt_sectioncreate.header.size =
  725. sizeof (struct req_lib_ckpt_sectioncreate) +
  726. sectionCreationAttributes->sectionId->idLen +
  727. initialDataSize;
  728. req_lib_ckpt_sectioncreate.header.id = MESSAGE_REQ_CKPT_CHECKPOINT_SECTIONCREATE;
  729. req_lib_ckpt_sectioncreate.idLen = sectionCreationAttributes->sectionId->idLen;
  730. req_lib_ckpt_sectioncreate.expirationTime = sectionCreationAttributes->expirationTime;
  731. req_lib_ckpt_sectioncreate.initialDataSize = initialDataSize;
  732. memcpy (&req_lib_ckpt_sectioncreate.checkpointName,
  733. &ckptCheckpointInstance->checkpointName, sizeof (SaNameT));
  734. pthread_mutex_lock (&ckptCheckpointInstance->response_mutex);
  735. error = saSendRetry (ckptCheckpointInstance->response_fd, &req_lib_ckpt_sectioncreate,
  736. sizeof (struct req_lib_ckpt_sectioncreate), MSG_NOSIGNAL);
  737. if (error != SA_AIS_OK) {
  738. goto error_exit;
  739. }
  740. /*
  741. * Write section identifier to server
  742. */
  743. error = saSendRetry (ckptCheckpointInstance->response_fd, sectionCreationAttributes->sectionId->id,
  744. sectionCreationAttributes->sectionId->idLen, MSG_NOSIGNAL);
  745. if (error != SA_AIS_OK) {
  746. goto error_exit;
  747. }
  748. error = saSendRetry (ckptCheckpointInstance->response_fd, initialData,
  749. initialDataSize, MSG_NOSIGNAL);
  750. if (error != SA_AIS_OK) {
  751. goto error_exit;
  752. }
  753. error = saRecvRetry (ckptCheckpointInstance->response_fd,
  754. &res_lib_ckpt_sectioncreate,
  755. sizeof (struct res_lib_ckpt_sectioncreate),
  756. MSG_WAITALL | MSG_NOSIGNAL);
  757. pthread_mutex_unlock (&ckptCheckpointInstance->response_mutex);
  758. error_exit:
  759. saHandleInstancePut (&checkpointHandleDatabase, checkpointHandle);
  760. return (error == SA_AIS_OK ? res_lib_ckpt_sectioncreate.header.error : error);
  761. }
  762. SaAisErrorT
  763. saCkptSectionDelete (
  764. SaCkptCheckpointHandleT checkpointHandle,
  765. const SaCkptSectionIdT *sectionId)
  766. {
  767. SaAisErrorT error;
  768. struct ckptCheckpointInstance *ckptCheckpointInstance;
  769. struct req_lib_ckpt_sectiondelete req_lib_ckpt_sectiondelete;
  770. struct res_lib_ckpt_sectiondelete res_lib_ckpt_sectiondelete;
  771. error = saHandleInstanceGet (&checkpointHandleDatabase, checkpointHandle,
  772. (void *)&ckptCheckpointInstance);
  773. if (error != SA_AIS_OK) {
  774. return (error);
  775. }
  776. pthread_mutex_lock (&ckptCheckpointInstance->response_mutex);
  777. req_lib_ckpt_sectiondelete.header.size = sizeof (struct req_lib_ckpt_sectiondelete) + sectionId->idLen;
  778. req_lib_ckpt_sectiondelete.header.id = MESSAGE_REQ_CKPT_CHECKPOINT_SECTIONDELETE;
  779. req_lib_ckpt_sectiondelete.idLen = sectionId->idLen;
  780. memcpy (&req_lib_ckpt_sectiondelete.checkpointName,
  781. &ckptCheckpointInstance->checkpointName, sizeof (SaNameT));
  782. error = saSendRetry (ckptCheckpointInstance->response_fd, &req_lib_ckpt_sectiondelete,
  783. sizeof (struct req_lib_ckpt_sectiondelete), MSG_NOSIGNAL);
  784. if (error != SA_AIS_OK) {
  785. goto error_exit;
  786. }
  787. /*
  788. * Write section identifier to server
  789. */
  790. error = saSendRetry (ckptCheckpointInstance->response_fd, sectionId->id,
  791. sectionId->idLen, MSG_NOSIGNAL);
  792. if (error != SA_AIS_OK) {
  793. goto error_exit;
  794. }
  795. error = saRecvRetry (ckptCheckpointInstance->response_fd,
  796. &res_lib_ckpt_sectiondelete,
  797. sizeof (struct res_lib_ckpt_sectiondelete),
  798. MSG_WAITALL | MSG_NOSIGNAL);
  799. pthread_mutex_unlock (&ckptCheckpointInstance->response_mutex);
  800. error_exit:
  801. saHandleInstancePut (&checkpointHandleDatabase, checkpointHandle);
  802. return (error == SA_AIS_OK ? res_lib_ckpt_sectiondelete.header.error : error);
  803. }
  804. SaAisErrorT
  805. saCkptSectionExpirationTimeSet (
  806. SaCkptCheckpointHandleT checkpointHandle,
  807. const SaCkptSectionIdT *sectionId,
  808. SaTimeT expirationTime)
  809. {
  810. SaAisErrorT error;
  811. struct ckptCheckpointInstance *ckptCheckpointInstance;
  812. struct req_lib_ckpt_sectionexpirationtimeset req_lib_ckpt_sectionexpirationtimeset;
  813. struct res_lib_ckpt_sectionexpirationtimeset res_lib_ckpt_sectionexpirationtimeset;
  814. error = saHandleInstanceGet (&checkpointHandleDatabase, checkpointHandle,
  815. (void *)&ckptCheckpointInstance);
  816. if (error != SA_AIS_OK) {
  817. goto error_exit_noput;
  818. }
  819. req_lib_ckpt_sectionexpirationtimeset.header.size = sizeof (struct req_lib_ckpt_sectionexpirationtimeset) + sectionId->idLen;
  820. req_lib_ckpt_sectionexpirationtimeset.header.id = MESSAGE_REQ_CKPT_CHECKPOINT_SECTIONEXPIRATIONTIMESET;
  821. req_lib_ckpt_sectionexpirationtimeset.idLen = sectionId->idLen;
  822. req_lib_ckpt_sectionexpirationtimeset.expirationTime = expirationTime;
  823. memcpy (&req_lib_ckpt_sectionexpirationtimeset.checkpointName,
  824. &ckptCheckpointInstance->checkpointName, sizeof (SaNameT));
  825. pthread_mutex_lock (&ckptCheckpointInstance->response_mutex);
  826. error = saSendRetry (ckptCheckpointInstance->response_fd, &req_lib_ckpt_sectionexpirationtimeset,
  827. sizeof (struct req_lib_ckpt_sectionexpirationtimeset), MSG_NOSIGNAL);
  828. if (error != SA_AIS_OK) {
  829. goto error_exit;
  830. }
  831. /*
  832. * Write section identifier to server
  833. */
  834. if (sectionId->idLen) {
  835. error = saSendRetry (ckptCheckpointInstance->response_fd, sectionId->id,
  836. sectionId->idLen, MSG_NOSIGNAL);
  837. if (error != SA_AIS_OK) {
  838. goto error_exit;
  839. }
  840. }
  841. error = saRecvRetry (ckptCheckpointInstance->response_fd,
  842. &res_lib_ckpt_sectionexpirationtimeset,
  843. sizeof (struct res_lib_ckpt_sectionexpirationtimeset),
  844. MSG_WAITALL | MSG_NOSIGNAL);
  845. pthread_mutex_unlock (&ckptCheckpointInstance->response_mutex);
  846. error_exit:
  847. saHandleInstancePut (&checkpointHandleDatabase, checkpointHandle);
  848. error_exit_noput:
  849. return (error == SA_AIS_OK ? res_lib_ckpt_sectionexpirationtimeset.header.error : error);
  850. }
  851. SaAisErrorT
  852. saCkptSectionIterationInitialize (
  853. SaCkptCheckpointHandleT checkpointHandle,
  854. SaCkptSectionsChosenT sectionsChosen,
  855. SaTimeT expirationTime,
  856. SaCkptSectionIterationHandleT *sectionIterationHandle)
  857. {
  858. SaAisErrorT error;
  859. struct ckptCheckpointInstance *ckptCheckpointInstance;
  860. struct ckptSectionIterationInstance *ckptSectionIterationInstance;
  861. struct req_lib_ckpt_sectioniteratorinitialize req_lib_ckpt_sectioniteratorinitialize;
  862. struct res_lib_ckpt_sectioniteratorinitialize res_lib_ckpt_sectioniteratorinitialize;
  863. error = saHandleInstanceGet (&checkpointHandleDatabase, checkpointHandle,
  864. (void *)&ckptCheckpointInstance);
  865. if (error != SA_AIS_OK) {
  866. goto error_no_destroy;
  867. }
  868. error = saHandleCreate (&ckptSectionIterationHandleDatabase,
  869. sizeof (struct ckptSectionIterationInstance), sectionIterationHandle);
  870. if (error != SA_AIS_OK) {
  871. goto error_put_checkpoint_db;
  872. }
  873. error = saHandleInstanceGet (&ckptSectionIterationHandleDatabase,
  874. *sectionIterationHandle, (void *)&ckptSectionIterationInstance);
  875. if (error != SA_AIS_OK) {
  876. goto error_destroy;
  877. }
  878. ckptSectionIterationInstance->response_fd = ckptCheckpointInstance->response_fd;
  879. ckptSectionIterationInstance->checkpointHandle = checkpointHandle;
  880. pthread_mutex_init (&ckptSectionIterationInstance->response_mutex, NULL);
  881. /*
  882. * Setup section id list for iterator next
  883. */
  884. list_init (&ckptSectionIterationInstance->sectionIdListHead);
  885. req_lib_ckpt_sectioniteratorinitialize.header.size = sizeof (struct req_lib_ckpt_sectioniteratorinitialize);
  886. req_lib_ckpt_sectioniteratorinitialize.header.id = MESSAGE_REQ_CKPT_SECTIONITERATOR_SECTIONITERATORINITIALIZE;
  887. req_lib_ckpt_sectioniteratorinitialize.sectionsChosen = sectionsChosen;
  888. req_lib_ckpt_sectioniteratorinitialize.expirationTime = expirationTime;
  889. memcpy (&req_lib_ckpt_sectioniteratorinitialize.checkpointName,
  890. &ckptCheckpointInstance->checkpointName, sizeof (SaNameT));
  891. pthread_mutex_lock (&ckptSectionIterationInstance->response_mutex);
  892. error = saSendRetry (ckptSectionIterationInstance->response_fd,
  893. &req_lib_ckpt_sectioniteratorinitialize,
  894. sizeof (struct req_lib_ckpt_sectioniteratorinitialize),
  895. MSG_NOSIGNAL);
  896. if (error != SA_AIS_OK) {
  897. goto error_put_destroy;
  898. }
  899. error = saRecvRetry (ckptSectionIterationInstance->response_fd,
  900. &res_lib_ckpt_sectioniteratorinitialize,
  901. sizeof (struct res_lib_ckpt_sectioniteratorinitialize),
  902. MSG_WAITALL | MSG_NOSIGNAL);
  903. pthread_mutex_unlock (&ckptSectionIterationInstance->response_mutex);
  904. saHandleInstancePut (&ckptSectionIterationHandleDatabase, *sectionIterationHandle);
  905. return (error == SA_AIS_OK ? res_lib_ckpt_sectioniteratorinitialize.header.error : error);
  906. error_put_destroy:
  907. saHandleInstancePut (&ckptSectionIterationHandleDatabase, *sectionIterationHandle);
  908. error_destroy:
  909. saHandleDestroy (&ckptSectionIterationHandleDatabase, *sectionIterationHandle);
  910. error_put_checkpoint_db:
  911. saHandleInstancePut (&checkpointHandleDatabase, checkpointHandle);
  912. error_no_destroy:
  913. return (error);
  914. }
  915. struct iteratorSectionIdListEntry {
  916. struct list_head list;
  917. char data[0];
  918. };
  919. SaAisErrorT
  920. saCkptSectionIterationNext (
  921. SaCkptSectionIterationHandleT sectionIterationHandle,
  922. SaCkptSectionDescriptorT *sectionDescriptor)
  923. {
  924. SaAisErrorT error;
  925. struct ckptSectionIterationInstance *ckptSectionIterationInstance;
  926. struct req_lib_ckpt_sectioniteratornext req_lib_ckpt_sectioniteratornext;
  927. struct res_lib_ckpt_sectioniteratornext res_lib_ckpt_sectioniteratornext;
  928. struct iteratorSectionIdListEntry *iteratorSectionIdListEntry;
  929. error = saHandleInstanceGet (&ckptSectionIterationHandleDatabase,
  930. sectionIterationHandle, (void *)&ckptSectionIterationInstance);
  931. if (error != SA_AIS_OK) {
  932. goto error_exit;
  933. }
  934. /*
  935. * Allocate section id storage area
  936. */
  937. /*
  938. * TODO max section id size is 500
  939. */
  940. iteratorSectionIdListEntry = malloc (sizeof (struct list_head) + 500);
  941. if (iteratorSectionIdListEntry == 0) {
  942. error = SA_AIS_ERR_NO_MEMORY;
  943. goto error_put_nounlock;
  944. }
  945. req_lib_ckpt_sectioniteratornext.header.size = sizeof (struct req_lib_ckpt_sectioniteratornext);
  946. req_lib_ckpt_sectioniteratornext.header.id = MESSAGE_REQ_CKPT_SECTIONITERATOR_SECTIONITERATORNEXT;
  947. pthread_mutex_lock (&ckptSectionIterationInstance->response_mutex);
  948. error = saSendRetry (ckptSectionIterationInstance->response_fd,
  949. &req_lib_ckpt_sectioniteratornext,
  950. sizeof (struct req_lib_ckpt_sectioniteratornext), MSG_NOSIGNAL);
  951. if (error != SA_AIS_OK) {
  952. goto error_put;
  953. }
  954. error = saRecvRetry (ckptSectionIterationInstance->response_fd, &res_lib_ckpt_sectioniteratornext,
  955. sizeof (struct res_lib_ckpt_sectioniteratornext), MSG_WAITALL | MSG_NOSIGNAL);
  956. if (error != SA_AIS_OK) {
  957. goto error_put;
  958. }
  959. memcpy (sectionDescriptor,
  960. &res_lib_ckpt_sectioniteratornext.sectionDescriptor,
  961. sizeof (SaCkptSectionDescriptorT));
  962. sectionDescriptor->sectionId.id = &iteratorSectionIdListEntry->data[0];
  963. if ((res_lib_ckpt_sectioniteratornext.header.size - sizeof (struct res_lib_ckpt_sectioniteratornext)) > 0) {
  964. error = saRecvRetry (ckptSectionIterationInstance->response_fd,
  965. sectionDescriptor->sectionId.id,
  966. res_lib_ckpt_sectioniteratornext.header.size -
  967. sizeof (struct res_lib_ckpt_sectioniteratornext),
  968. MSG_WAITALL | MSG_NOSIGNAL);
  969. }
  970. /*
  971. * Add to persistent memory list for this sectioniterator
  972. */
  973. if (error == SA_AIS_OK && res_lib_ckpt_sectioniteratornext.header.error == SA_AIS_OK) {
  974. list_init (&iteratorSectionIdListEntry->list);
  975. list_add (&iteratorSectionIdListEntry->list, &ckptSectionIterationInstance->sectionIdListHead);
  976. }
  977. error_put:
  978. pthread_mutex_unlock (&ckptSectionIterationInstance->response_mutex);
  979. error_put_nounlock:
  980. saHandleInstancePut (&ckptSectionIterationHandleDatabase, sectionIterationHandle);
  981. error_exit:
  982. return (error == SA_AIS_OK ? res_lib_ckpt_sectioniteratornext.header.error : error);
  983. }
  984. SaAisErrorT
  985. saCkptSectionIterationFinalize (
  986. SaCkptSectionIterationHandleT sectionIterationHandle)
  987. {
  988. SaAisErrorT error;
  989. struct ckptSectionIterationInstance *ckptSectionIterationInstance;
  990. struct iteratorSectionIdListEntry *iteratorSectionIdListEntry;
  991. struct list_head *sectionIdIterationList;
  992. struct list_head *sectionIdIterationListNext;
  993. error = saHandleInstanceGet (&ckptSectionIterationHandleDatabase,
  994. sectionIterationHandle, (void *)&ckptSectionIterationInstance);
  995. if (error != SA_AIS_OK) {
  996. goto error_noput;
  997. }
  998. /*
  999. * iterate list of section ids for this iterator to free the allocated memory
  1000. * be careful to cache next pointer because free removes memory from use
  1001. */
  1002. for (sectionIdIterationList = ckptSectionIterationInstance->sectionIdListHead.next,
  1003. sectionIdIterationListNext = sectionIdIterationList->next;
  1004. sectionIdIterationList != &ckptSectionIterationInstance->sectionIdListHead;
  1005. sectionIdIterationList = sectionIdIterationListNext,
  1006. sectionIdIterationListNext = sectionIdIterationList->next) {
  1007. iteratorSectionIdListEntry = list_entry (sectionIdIterationList,
  1008. struct iteratorSectionIdListEntry, list);
  1009. free (iteratorSectionIdListEntry);
  1010. }
  1011. saHandleInstancePut (&checkpointHandleDatabase,
  1012. ckptSectionIterationInstance->checkpointHandle);
  1013. saHandleInstancePut (&ckptSectionIterationHandleDatabase, sectionIterationHandle);
  1014. saHandleDestroy (&ckptSectionIterationHandleDatabase, sectionIterationHandle);
  1015. error_noput:
  1016. return (error);
  1017. }
  1018. SaAisErrorT
  1019. saCkptCheckpointWrite (
  1020. SaCkptCheckpointHandleT checkpointHandle,
  1021. const SaCkptIOVectorElementT *ioVector,
  1022. SaUint32T numberOfElements,
  1023. SaUint32T *erroneousVectorIndex)
  1024. {
  1025. SaAisErrorT error = SA_AIS_OK;
  1026. struct ckptCheckpointInstance *ckptCheckpointInstance;
  1027. struct req_lib_ckpt_sectionwrite req_lib_ckpt_sectionwrite;
  1028. struct res_lib_ckpt_sectionwrite res_lib_ckpt_sectionwrite;
  1029. int i;
  1030. struct iovec iov[3];
  1031. int iov_len = 0;
  1032. error = saHandleInstanceGet (&checkpointHandleDatabase, checkpointHandle,
  1033. (void *)&ckptCheckpointInstance);
  1034. if (error != SA_AIS_OK) {
  1035. return (error);
  1036. }
  1037. if ((ckptCheckpointInstance->checkpointOpenFlags & SA_CKPT_CHECKPOINT_WRITE) == 0) {
  1038. error = SA_AIS_ERR_ACCESS;
  1039. goto error_put;
  1040. }
  1041. req_lib_ckpt_sectionwrite.header.id = MESSAGE_REQ_CKPT_CHECKPOINT_SECTIONWRITE;
  1042. pthread_mutex_lock (&ckptCheckpointInstance->response_mutex);
  1043. for (i = 0; i < numberOfElements; i++) {
  1044. req_lib_ckpt_sectionwrite.header.size = sizeof (struct req_lib_ckpt_sectionwrite) + ioVector[i].sectionId.idLen + ioVector[i].dataSize;
  1045. req_lib_ckpt_sectionwrite.dataOffset = ioVector[i].dataOffset;
  1046. req_lib_ckpt_sectionwrite.dataSize = ioVector[i].dataSize;
  1047. req_lib_ckpt_sectionwrite.idLen = ioVector[i].sectionId.idLen;
  1048. memcpy (&req_lib_ckpt_sectionwrite.checkpointName,
  1049. &ckptCheckpointInstance->checkpointName, sizeof (SaNameT));
  1050. iov_len = 0;
  1051. /* TODO check for zero length stuff */
  1052. iov[0].iov_base = (char *)&req_lib_ckpt_sectionwrite;
  1053. iov[0].iov_len = sizeof (struct req_lib_ckpt_sectionwrite);
  1054. iov[1].iov_base = ioVector[i].sectionId.id;
  1055. iov[1].iov_len = ioVector[i].sectionId.idLen;
  1056. iov[2].iov_base = ioVector[i].dataBuffer;
  1057. iov[2].iov_len = ioVector[i].dataSize;
  1058. error = saSendMsgRetry (ckptCheckpointInstance->response_fd,
  1059. iov,
  1060. 3);
  1061. if (error != SA_AIS_OK) {
  1062. goto error_exit;
  1063. }
  1064. /*
  1065. * Receive response
  1066. */
  1067. error = saRecvRetry (ckptCheckpointInstance->response_fd, &res_lib_ckpt_sectionwrite,
  1068. sizeof (struct res_lib_ckpt_sectionwrite), MSG_WAITALL | MSG_NOSIGNAL);
  1069. if (error != SA_AIS_OK) {
  1070. goto error_exit;
  1071. }
  1072. if (res_lib_ckpt_sectionwrite.header.error == SA_AIS_ERR_TRY_AGAIN) {
  1073. error = SA_AIS_ERR_TRY_AGAIN;
  1074. goto error_exit;
  1075. }
  1076. /*
  1077. * If error, report back erroneous index
  1078. */
  1079. if (res_lib_ckpt_sectionwrite.header.error != SA_AIS_OK) {
  1080. if (erroneousVectorIndex) {
  1081. *erroneousVectorIndex = i;
  1082. }
  1083. goto error_exit;
  1084. }
  1085. }
  1086. error_exit:
  1087. pthread_mutex_unlock (&ckptCheckpointInstance->response_mutex);
  1088. error_put:
  1089. saHandleInstancePut (&checkpointHandleDatabase, checkpointHandle);
  1090. return (error == SA_AIS_OK ? res_lib_ckpt_sectionwrite.header.error : error);
  1091. }
  1092. SaAisErrorT
  1093. saCkptSectionOverwrite (
  1094. SaCkptCheckpointHandleT checkpointHandle,
  1095. const SaCkptSectionIdT *sectionId,
  1096. const void *dataBuffer,
  1097. SaSizeT dataSize)
  1098. {
  1099. SaAisErrorT error;
  1100. struct ckptCheckpointInstance *ckptCheckpointInstance;
  1101. struct req_lib_ckpt_sectionoverwrite req_lib_ckpt_sectionoverwrite;
  1102. struct res_lib_ckpt_sectionoverwrite res_lib_ckpt_sectionoverwrite;
  1103. error = saHandleInstanceGet (&checkpointHandleDatabase, checkpointHandle,
  1104. (void *)&ckptCheckpointInstance);
  1105. if (error != SA_AIS_OK) {
  1106. return (error);
  1107. }
  1108. if ((ckptCheckpointInstance->checkpointOpenFlags & SA_CKPT_CHECKPOINT_WRITE) == 0) {
  1109. return (SA_AIS_ERR_ACCESS);
  1110. }
  1111. req_lib_ckpt_sectionoverwrite.header.size = sizeof (struct req_lib_ckpt_sectionoverwrite) + sectionId->idLen + dataSize;
  1112. req_lib_ckpt_sectionoverwrite.header.id = MESSAGE_REQ_CKPT_CHECKPOINT_SECTIONOVERWRITE;
  1113. req_lib_ckpt_sectionoverwrite.idLen = sectionId->idLen;
  1114. req_lib_ckpt_sectionoverwrite.dataSize = dataSize;
  1115. memcpy (&req_lib_ckpt_sectionoverwrite.checkpointName,
  1116. &ckptCheckpointInstance->checkpointName, sizeof (SaNameT));
  1117. pthread_mutex_lock (&ckptCheckpointInstance->response_mutex);
  1118. error = saSendRetry (ckptCheckpointInstance->response_fd, &req_lib_ckpt_sectionoverwrite,
  1119. sizeof (struct req_lib_ckpt_sectionoverwrite), MSG_NOSIGNAL);
  1120. if (error != SA_AIS_OK) {
  1121. goto error_exit;
  1122. }
  1123. if (sectionId->idLen) {
  1124. error = saSendRetry (ckptCheckpointInstance->response_fd, sectionId->id,
  1125. sectionId->idLen, MSG_NOSIGNAL);
  1126. if (error != SA_AIS_OK) {
  1127. goto error_exit;
  1128. }
  1129. }
  1130. error = saSendRetry (ckptCheckpointInstance->response_fd, dataBuffer, dataSize, MSG_NOSIGNAL);
  1131. if (error != SA_AIS_OK) {
  1132. goto error_exit;
  1133. }
  1134. error = saRecvRetry (ckptCheckpointInstance->response_fd,
  1135. &res_lib_ckpt_sectionoverwrite,
  1136. sizeof (struct res_lib_ckpt_sectionoverwrite),
  1137. MSG_WAITALL | MSG_NOSIGNAL);
  1138. error_exit:
  1139. pthread_mutex_unlock (&ckptCheckpointInstance->response_mutex);
  1140. saHandleInstancePut (&checkpointHandleDatabase, checkpointHandle);
  1141. return (error == SA_AIS_OK ? res_lib_ckpt_sectionoverwrite.header.error : error);
  1142. }
  1143. SaAisErrorT
  1144. saCkptCheckpointRead (
  1145. SaCkptCheckpointHandleT checkpointHandle,
  1146. SaCkptIOVectorElementT *ioVector,
  1147. SaUint32T numberOfElements,
  1148. SaUint32T *erroneousVectorIndex)
  1149. {
  1150. SaAisErrorT error = SA_AIS_OK;
  1151. struct ckptCheckpointInstance *ckptCheckpointInstance;
  1152. struct req_lib_ckpt_sectionread req_lib_ckpt_sectionread;
  1153. struct res_lib_ckpt_sectionread res_lib_ckpt_sectionread;
  1154. int dataLength;
  1155. int i;
  1156. struct iovec iov[3];
  1157. error = saHandleInstanceGet (&checkpointHandleDatabase, checkpointHandle,
  1158. (void *)&ckptCheckpointInstance);
  1159. if (error != SA_AIS_OK) {
  1160. return (error);
  1161. }
  1162. if ((ckptCheckpointInstance->checkpointOpenFlags & SA_CKPT_CHECKPOINT_READ) == 0) {
  1163. return (SA_AIS_ERR_ACCESS);
  1164. }
  1165. req_lib_ckpt_sectionread.header.id = MESSAGE_REQ_CKPT_CHECKPOINT_SECTIONREAD;
  1166. pthread_mutex_lock (&ckptCheckpointInstance->response_mutex);
  1167. for (i = 0; i < numberOfElements; i++) {
  1168. req_lib_ckpt_sectionread.header.size = sizeof (struct req_lib_ckpt_sectionread) +
  1169. ioVector[i].sectionId.idLen;
  1170. req_lib_ckpt_sectionread.idLen = ioVector[i].sectionId.idLen;
  1171. req_lib_ckpt_sectionread.dataOffset = ioVector[i].dataOffset;
  1172. req_lib_ckpt_sectionread.dataSize = ioVector[i].dataSize;
  1173. memcpy (&req_lib_ckpt_sectionread.checkpointName,
  1174. &ckptCheckpointInstance->checkpointName, sizeof (SaNameT));
  1175. iov[0].iov_base = (char *)&req_lib_ckpt_sectionread;
  1176. iov[0].iov_len = sizeof (struct req_lib_ckpt_sectionread);
  1177. iov[1].iov_base = ioVector[i].sectionId.id;
  1178. iov[1].iov_len = ioVector[i].sectionId.idLen;
  1179. error = saSendMsgRetry (ckptCheckpointInstance->response_fd,
  1180. iov,
  1181. 2);
  1182. /*
  1183. * Receive response header
  1184. */
  1185. error = saRecvRetry (ckptCheckpointInstance->response_fd, &res_lib_ckpt_sectionread,
  1186. sizeof (struct res_lib_ckpt_sectionread), MSG_WAITALL | MSG_NOSIGNAL);
  1187. if (error != SA_AIS_OK) {
  1188. goto error_exit;
  1189. }
  1190. dataLength = res_lib_ckpt_sectionread.header.size - sizeof (struct res_lib_ckpt_sectionread);
  1191. /*
  1192. * Receive checkpoint section data
  1193. */
  1194. if (dataLength > 0) {
  1195. error = saRecvRetry (ckptCheckpointInstance->response_fd, ioVector[i].dataBuffer,
  1196. dataLength, MSG_WAITALL | MSG_NOSIGNAL);
  1197. if (error != SA_AIS_OK) {
  1198. goto error_exit;
  1199. }
  1200. }
  1201. if (res_lib_ckpt_sectionread.header.error != SA_AIS_OK) {
  1202. if (erroneousVectorIndex) {
  1203. *erroneousVectorIndex = i;
  1204. }
  1205. goto error_exit;
  1206. }
  1207. /*
  1208. * Report back bytes of data read
  1209. */
  1210. ioVector[i].readSize = res_lib_ckpt_sectionread.dataRead;
  1211. }
  1212. error_exit:
  1213. pthread_mutex_unlock (&ckptCheckpointInstance->response_mutex);
  1214. saHandleInstancePut (&checkpointHandleDatabase, checkpointHandle);
  1215. return (error == SA_AIS_OK ? res_lib_ckpt_sectionread.header.error : error);
  1216. }
  1217. SaAisErrorT
  1218. saCkptCheckpointSynchronize (
  1219. SaCkptCheckpointHandleT checkpointHandle,
  1220. SaTimeT timeout)
  1221. {
  1222. SaAisErrorT error;
  1223. struct ckptCheckpointInstance *ckptCheckpointInstance;
  1224. struct req_lib_ckpt_checkpointsynchronize req_lib_ckpt_checkpointsynchronize;
  1225. struct res_lib_ckpt_checkpointsynchronize res_lib_ckpt_checkpointsynchronize;
  1226. error = saHandleInstanceGet (&checkpointHandleDatabase, checkpointHandle,
  1227. (void *)&ckptCheckpointInstance);
  1228. if (error != SA_AIS_OK) {
  1229. return (error);
  1230. }
  1231. req_lib_ckpt_checkpointsynchronize.header.size = sizeof (struct req_lib_ckpt_checkpointsynchronize);
  1232. req_lib_ckpt_checkpointsynchronize.header.id = MESSAGE_REQ_CKPT_CHECKPOINT_CHECKPOINTSYNCHRONIZE;
  1233. pthread_mutex_lock (&ckptCheckpointInstance->response_mutex);
  1234. error = saSendRetry (ckptCheckpointInstance->response_fd, &req_lib_ckpt_checkpointsynchronize,
  1235. sizeof (struct req_lib_ckpt_checkpointsynchronize), MSG_NOSIGNAL);
  1236. if (error != SA_AIS_OK) {
  1237. goto error_exit;
  1238. }
  1239. error = saRecvRetry (ckptCheckpointInstance->response_fd,
  1240. &res_lib_ckpt_checkpointsynchronize,
  1241. sizeof (struct res_lib_ckpt_checkpointsynchronize),
  1242. MSG_WAITALL | MSG_NOSIGNAL);
  1243. error_exit:
  1244. pthread_mutex_unlock (&ckptCheckpointInstance->response_mutex);
  1245. saHandleInstancePut (&checkpointHandleDatabase, checkpointHandle);
  1246. return (error == SA_AIS_OK ? res_lib_ckpt_checkpointsynchronize.header.error : error);
  1247. }
  1248. SaAisErrorT
  1249. saCkptCheckpointSynchronizeAsync (
  1250. SaCkptHandleT ckptHandle,
  1251. SaCkptCheckpointHandleT checkpointHandle,
  1252. SaInvocationT invocation)
  1253. {
  1254. return (SA_AIS_OK);
  1255. /* TODO not implemented in executive
  1256. struct ckptInstance *ckptInstance;
  1257. struct ckptCheckpointInstance *ckptCheckpointInstance;
  1258. SaAisErrorT error;
  1259. struct req_lib_ckpt_checkpointsynchronizeasync req_lib_ckpt_checkpointsynchronizeasync;
  1260. error = saHandleInstanceGet (&checkpointHandleDatabase, checkpointHandle,
  1261. (void *)&ckptCheckpointInstance);
  1262. if (error != SA_AIS_OK) {
  1263. return (error);
  1264. }
  1265. req_lib_ckpt_checkpointsynchronizeasync.header.size = sizeof (struct req_lib_ckpt_checkpointsynchronizeasync);
  1266. req_lib_ckpt_checkpointsynchronizeasync.header.id = MESSAGE_REQ_CKPT_CHECKPOINT_CHECKPOINTSYNCHRONIZEASYNC;
  1267. req_lib_ckpt_checkpointsynchronizeasync.invocation = invocation;
  1268. pthread_mutex_lock (&ckptCheckpointInstance->response_mutex);
  1269. pthread_mutex_lock (&ckptInstance->response_mutex);
  1270. error = saSendRetry (ckptInstance->response_fd, &req_lib_ckpt_checkpointsynchronizeasync,
  1271. sizeof (struct req_lib_ckpt_checkpointsynchronizeasync), MSG_NOSIGNAL);
  1272. pthread_mutex_unlock (&ckptInstance->response_mutex);
  1273. pthread_mutex_unlock (&ckptCheckpointInstance->response_mutex);
  1274. saHandleInstancePut (&checkpointHandleDatabase, *checkpointHandle);
  1275. return (error);
  1276. */
  1277. }