ckpt.c 49 KB

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