ckpt.c 50 KB

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