ckpt.c 49 KB

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