ckpt.c 50 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605
  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. if (checkpointName == NULL) {
  604. return (SA_AIS_ERR_INVALID_PARAM);
  605. }
  606. error = saHandleInstanceGet (&ckptHandleDatabase, ckptHandle, (void *)&ckptInstance);
  607. if (error != SA_AIS_OK) {
  608. goto exit_noclose;
  609. }
  610. req_lib_ckpt_checkpointunlink.header.size = sizeof (struct req_lib_ckpt_checkpointunlink);
  611. req_lib_ckpt_checkpointunlink.header.id = MESSAGE_REQ_CKPT_CHECKPOINT_CHECKPOINTUNLINK;
  612. memcpy (&req_lib_ckpt_checkpointunlink.checkpointName, checkpointName, sizeof (SaNameT));
  613. error = saSendRetry (ckptInstance->response_fd, &req_lib_ckpt_checkpointunlink,
  614. sizeof (struct req_lib_ckpt_checkpointunlink), MSG_NOSIGNAL);
  615. if (error != SA_AIS_OK) {
  616. goto exit_put;
  617. }
  618. error = saRecvRetry (ckptInstance->response_fd, &res_lib_ckpt_checkpointunlink,
  619. sizeof (struct res_lib_ckpt_checkpointunlink), MSG_WAITALL | MSG_NOSIGNAL);
  620. exit_put:
  621. saHandleInstancePut (&ckptHandleDatabase, ckptHandle);
  622. return (error == SA_AIS_OK ? res_lib_ckpt_checkpointunlink.header.error : error);
  623. exit_noclose:
  624. return (error);
  625. }
  626. SaAisErrorT
  627. saCkptCheckpointRetentionDurationSet (
  628. SaCkptCheckpointHandleT checkpointHandle,
  629. SaTimeT retentionDuration)
  630. {
  631. SaAisErrorT error;
  632. struct ckptCheckpointInstance *ckptCheckpointInstance;
  633. struct req_lib_ckpt_checkpointretentiondurationset req_lib_ckpt_checkpointretentiondurationset;
  634. struct res_lib_ckpt_checkpointretentiondurationset res_lib_ckpt_checkpointretentiondurationset;
  635. error = saHandleInstanceGet (&checkpointHandleDatabase, checkpointHandle,
  636. (void *)&ckptCheckpointInstance);
  637. if (error != SA_AIS_OK) {
  638. goto error_exit_noput;
  639. }
  640. req_lib_ckpt_checkpointretentiondurationset.header.size = sizeof (struct req_lib_ckpt_checkpointretentiondurationset);
  641. req_lib_ckpt_checkpointretentiondurationset.header.id = MESSAGE_REQ_CKPT_CHECKPOINT_CHECKPOINTRETENTIONDURATIONSET;
  642. req_lib_ckpt_checkpointretentiondurationset.retentionDuration = retentionDuration;
  643. memcpy (&req_lib_ckpt_checkpointretentiondurationset.checkpointName,
  644. &ckptCheckpointInstance->checkpointName, sizeof (SaNameT));
  645. pthread_mutex_lock (&ckptCheckpointInstance->response_mutex);
  646. error = saSendRetry (ckptCheckpointInstance->response_fd, &req_lib_ckpt_checkpointretentiondurationset, sizeof (struct req_lib_ckpt_checkpointretentiondurationset), MSG_NOSIGNAL);
  647. if (error != SA_AIS_OK) {
  648. goto error_exit;
  649. }
  650. error = saRecvRetry (ckptCheckpointInstance->response_fd,
  651. &res_lib_ckpt_checkpointretentiondurationset,
  652. sizeof (struct res_lib_ckpt_checkpointretentiondurationset),
  653. MSG_WAITALL | MSG_NOSIGNAL);
  654. pthread_mutex_unlock (&ckptCheckpointInstance->response_mutex);
  655. error_exit:
  656. saHandleInstancePut (&checkpointHandleDatabase, checkpointHandle);
  657. error_exit_noput:
  658. return (error == SA_AIS_OK ? res_lib_ckpt_checkpointretentiondurationset.header.error : error);
  659. }
  660. SaAisErrorT
  661. saCkptActiveReplicaSet (
  662. SaCkptCheckpointHandleT checkpointHandle)
  663. {
  664. SaAisErrorT error;
  665. struct ckptCheckpointInstance *ckptCheckpointInstance;
  666. struct req_lib_ckpt_activereplicaset req_lib_ckpt_activereplicaset;
  667. struct res_lib_ckpt_activereplicaset res_lib_ckpt_activereplicaset;
  668. error = saHandleInstanceGet (&checkpointHandleDatabase, checkpointHandle,
  669. (void *)&ckptCheckpointInstance);
  670. if (error != SA_AIS_OK) {
  671. goto error_noput;
  672. }
  673. if ((ckptCheckpointInstance->checkpointOpenFlags & SA_CKPT_CHECKPOINT_WRITE) == 0) {
  674. error = SA_AIS_ERR_ACCESS;
  675. goto error_put;
  676. }
  677. req_lib_ckpt_activereplicaset.header.size = sizeof (struct req_lib_ckpt_activereplicaset);
  678. req_lib_ckpt_activereplicaset.header.id = MESSAGE_REQ_CKPT_ACTIVEREPLICASET;
  679. memcpy (&req_lib_ckpt_activereplicaset.checkpointName,
  680. &ckptCheckpointInstance->checkpointName, sizeof (SaNameT));
  681. pthread_mutex_lock (&ckptCheckpointInstance->response_mutex);
  682. error = saSendRetry (ckptCheckpointInstance->response_fd, &req_lib_ckpt_activereplicaset,
  683. sizeof (struct req_lib_ckpt_activereplicaset), MSG_NOSIGNAL);
  684. if (error != SA_AIS_OK) {
  685. goto error_put;
  686. }
  687. error = saRecvRetry (ckptCheckpointInstance->response_fd,
  688. &res_lib_ckpt_activereplicaset,
  689. sizeof (struct res_lib_ckpt_activereplicaset),
  690. MSG_WAITALL | MSG_NOSIGNAL);
  691. pthread_mutex_unlock (&ckptCheckpointInstance->response_mutex);
  692. error_put:
  693. saHandleInstancePut (&checkpointHandleDatabase, checkpointHandle);
  694. error_noput:
  695. return (error == SA_AIS_OK ? res_lib_ckpt_activereplicaset.header.error : error);
  696. }
  697. SaAisErrorT
  698. saCkptCheckpointStatusGet (
  699. SaCkptCheckpointHandleT checkpointHandle,
  700. SaCkptCheckpointDescriptorT *checkpointStatus)
  701. {
  702. SaAisErrorT error;
  703. struct ckptCheckpointInstance *ckptCheckpointInstance;
  704. struct req_lib_ckpt_checkpointstatusget req_lib_ckpt_checkpointstatusget;
  705. struct res_lib_ckpt_checkpointstatusget res_lib_ckpt_checkpointstatusget;
  706. if (checkpointStatus == NULL) {
  707. return (SA_AIS_ERR_INVALID_PARAM);
  708. }
  709. error = saHandleInstanceGet (&checkpointHandleDatabase, checkpointHandle,
  710. (void *)&ckptCheckpointInstance);
  711. if (error != SA_AIS_OK) {
  712. return (error);
  713. }
  714. req_lib_ckpt_checkpointstatusget.header.size = sizeof (struct req_lib_ckpt_checkpointstatusget);
  715. req_lib_ckpt_checkpointstatusget.header.id = MESSAGE_REQ_CKPT_CHECKPOINT_CHECKPOINTSTATUSGET;
  716. memcpy (&req_lib_ckpt_checkpointstatusget.checkpointName,
  717. &ckptCheckpointInstance->checkpointName, sizeof (SaNameT));
  718. pthread_mutex_lock (&ckptCheckpointInstance->response_mutex);
  719. error = saSendRetry (ckptCheckpointInstance->response_fd, &req_lib_ckpt_checkpointstatusget,
  720. sizeof (struct req_lib_ckpt_checkpointstatusget), MSG_NOSIGNAL);
  721. if (error != SA_AIS_OK) {
  722. goto error_exit;
  723. }
  724. error = saRecvRetry (ckptCheckpointInstance->response_fd,
  725. &res_lib_ckpt_checkpointstatusget,
  726. sizeof (struct res_lib_ckpt_checkpointstatusget),
  727. MSG_WAITALL | MSG_NOSIGNAL);
  728. if (error != SA_AIS_OK) {
  729. goto error_exit;
  730. }
  731. pthread_mutex_unlock (&ckptCheckpointInstance->response_mutex);
  732. memcpy (checkpointStatus,
  733. &res_lib_ckpt_checkpointstatusget.checkpointDescriptor,
  734. sizeof (SaCkptCheckpointDescriptorT));
  735. error_exit:
  736. saHandleInstancePut (&checkpointHandleDatabase, checkpointHandle);
  737. return (error == SA_AIS_OK ? res_lib_ckpt_checkpointstatusget.header.error : error);
  738. }
  739. SaAisErrorT
  740. saCkptSectionCreate (
  741. SaCkptCheckpointHandleT checkpointHandle,
  742. SaCkptSectionCreationAttributesT *sectionCreationAttributes,
  743. const void *initialData,
  744. SaUint32T initialDataSize)
  745. {
  746. SaAisErrorT error;
  747. struct ckptCheckpointInstance *ckptCheckpointInstance;
  748. struct req_lib_ckpt_sectioncreate req_lib_ckpt_sectioncreate;
  749. struct res_lib_ckpt_sectioncreate res_lib_ckpt_sectioncreate;
  750. error = saHandleInstanceGet (&checkpointHandleDatabase, checkpointHandle,
  751. (void *)&ckptCheckpointInstance);
  752. if (error != SA_AIS_OK) {
  753. return (error);
  754. }
  755. if ((ckptCheckpointInstance->checkpointOpenFlags & SA_CKPT_CHECKPOINT_WRITE) == 0) {
  756. error = SA_AIS_ERR_ACCESS;
  757. goto error_exit;
  758. }
  759. req_lib_ckpt_sectioncreate.header.size =
  760. sizeof (struct req_lib_ckpt_sectioncreate) +
  761. sectionCreationAttributes->sectionId->idLen +
  762. initialDataSize;
  763. req_lib_ckpt_sectioncreate.header.id = MESSAGE_REQ_CKPT_CHECKPOINT_SECTIONCREATE;
  764. req_lib_ckpt_sectioncreate.idLen = sectionCreationAttributes->sectionId->idLen;
  765. req_lib_ckpt_sectioncreate.expirationTime = sectionCreationAttributes->expirationTime;
  766. req_lib_ckpt_sectioncreate.initialDataSize = initialDataSize;
  767. memcpy (&req_lib_ckpt_sectioncreate.checkpointName,
  768. &ckptCheckpointInstance->checkpointName, sizeof (SaNameT));
  769. pthread_mutex_lock (&ckptCheckpointInstance->response_mutex);
  770. error = saSendRetry (ckptCheckpointInstance->response_fd, &req_lib_ckpt_sectioncreate,
  771. sizeof (struct req_lib_ckpt_sectioncreate), MSG_NOSIGNAL);
  772. if (error != SA_AIS_OK) {
  773. goto error_exit;
  774. }
  775. /*
  776. * Write section identifier to server
  777. */
  778. error = saSendRetry (ckptCheckpointInstance->response_fd, sectionCreationAttributes->sectionId->id,
  779. sectionCreationAttributes->sectionId->idLen, MSG_NOSIGNAL);
  780. if (error != SA_AIS_OK) {
  781. goto error_exit;
  782. }
  783. error = saSendRetry (ckptCheckpointInstance->response_fd, initialData,
  784. initialDataSize, MSG_NOSIGNAL);
  785. if (error != SA_AIS_OK) {
  786. goto error_exit;
  787. }
  788. error = saRecvRetry (ckptCheckpointInstance->response_fd,
  789. &res_lib_ckpt_sectioncreate,
  790. sizeof (struct res_lib_ckpt_sectioncreate),
  791. MSG_WAITALL | MSG_NOSIGNAL);
  792. pthread_mutex_unlock (&ckptCheckpointInstance->response_mutex);
  793. error_exit:
  794. saHandleInstancePut (&checkpointHandleDatabase, checkpointHandle);
  795. return (error == SA_AIS_OK ? res_lib_ckpt_sectioncreate.header.error : error);
  796. }
  797. SaAisErrorT
  798. saCkptSectionDelete (
  799. SaCkptCheckpointHandleT checkpointHandle,
  800. const SaCkptSectionIdT *sectionId)
  801. {
  802. SaAisErrorT error;
  803. struct ckptCheckpointInstance *ckptCheckpointInstance;
  804. struct req_lib_ckpt_sectiondelete req_lib_ckpt_sectiondelete;
  805. struct res_lib_ckpt_sectiondelete res_lib_ckpt_sectiondelete;
  806. error = saHandleInstanceGet (&checkpointHandleDatabase, checkpointHandle,
  807. (void *)&ckptCheckpointInstance);
  808. if (error != SA_AIS_OK) {
  809. return (error);
  810. }
  811. pthread_mutex_lock (&ckptCheckpointInstance->response_mutex);
  812. req_lib_ckpt_sectiondelete.header.size = sizeof (struct req_lib_ckpt_sectiondelete) + sectionId->idLen;
  813. req_lib_ckpt_sectiondelete.header.id = MESSAGE_REQ_CKPT_CHECKPOINT_SECTIONDELETE;
  814. req_lib_ckpt_sectiondelete.idLen = sectionId->idLen;
  815. memcpy (&req_lib_ckpt_sectiondelete.checkpointName,
  816. &ckptCheckpointInstance->checkpointName, sizeof (SaNameT));
  817. error = saSendRetry (ckptCheckpointInstance->response_fd, &req_lib_ckpt_sectiondelete,
  818. sizeof (struct req_lib_ckpt_sectiondelete), MSG_NOSIGNAL);
  819. if (error != SA_AIS_OK) {
  820. goto error_exit;
  821. }
  822. /*
  823. * Write section identifier to server
  824. */
  825. error = saSendRetry (ckptCheckpointInstance->response_fd, sectionId->id,
  826. sectionId->idLen, MSG_NOSIGNAL);
  827. if (error != SA_AIS_OK) {
  828. goto error_exit;
  829. }
  830. error = saRecvRetry (ckptCheckpointInstance->response_fd,
  831. &res_lib_ckpt_sectiondelete,
  832. sizeof (struct res_lib_ckpt_sectiondelete),
  833. MSG_WAITALL | MSG_NOSIGNAL);
  834. pthread_mutex_unlock (&ckptCheckpointInstance->response_mutex);
  835. error_exit:
  836. saHandleInstancePut (&checkpointHandleDatabase, checkpointHandle);
  837. return (error == SA_AIS_OK ? res_lib_ckpt_sectiondelete.header.error : error);
  838. }
  839. SaAisErrorT
  840. saCkptSectionExpirationTimeSet (
  841. SaCkptCheckpointHandleT checkpointHandle,
  842. const SaCkptSectionIdT *sectionId,
  843. SaTimeT expirationTime)
  844. {
  845. SaAisErrorT error;
  846. struct ckptCheckpointInstance *ckptCheckpointInstance;
  847. struct req_lib_ckpt_sectionexpirationtimeset req_lib_ckpt_sectionexpirationtimeset;
  848. struct res_lib_ckpt_sectionexpirationtimeset res_lib_ckpt_sectionexpirationtimeset;
  849. error = saHandleInstanceGet (&checkpointHandleDatabase, checkpointHandle,
  850. (void *)&ckptCheckpointInstance);
  851. if (error != SA_AIS_OK) {
  852. goto error_exit_noput;
  853. }
  854. req_lib_ckpt_sectionexpirationtimeset.header.size = sizeof (struct req_lib_ckpt_sectionexpirationtimeset) + sectionId->idLen;
  855. req_lib_ckpt_sectionexpirationtimeset.header.id = MESSAGE_REQ_CKPT_CHECKPOINT_SECTIONEXPIRATIONTIMESET;
  856. req_lib_ckpt_sectionexpirationtimeset.idLen = sectionId->idLen;
  857. req_lib_ckpt_sectionexpirationtimeset.expirationTime = expirationTime;
  858. memcpy (&req_lib_ckpt_sectionexpirationtimeset.checkpointName,
  859. &ckptCheckpointInstance->checkpointName, sizeof (SaNameT));
  860. pthread_mutex_lock (&ckptCheckpointInstance->response_mutex);
  861. error = saSendRetry (ckptCheckpointInstance->response_fd, &req_lib_ckpt_sectionexpirationtimeset,
  862. sizeof (struct req_lib_ckpt_sectionexpirationtimeset), MSG_NOSIGNAL);
  863. if (error != SA_AIS_OK) {
  864. goto error_exit;
  865. }
  866. /*
  867. * Write section identifier to server
  868. */
  869. if (sectionId->idLen) {
  870. error = saSendRetry (ckptCheckpointInstance->response_fd, sectionId->id,
  871. sectionId->idLen, MSG_NOSIGNAL);
  872. if (error != SA_AIS_OK) {
  873. goto error_exit;
  874. }
  875. }
  876. error = saRecvRetry (ckptCheckpointInstance->response_fd,
  877. &res_lib_ckpt_sectionexpirationtimeset,
  878. sizeof (struct res_lib_ckpt_sectionexpirationtimeset),
  879. MSG_WAITALL | MSG_NOSIGNAL);
  880. pthread_mutex_unlock (&ckptCheckpointInstance->response_mutex);
  881. error_exit:
  882. saHandleInstancePut (&checkpointHandleDatabase, checkpointHandle);
  883. error_exit_noput:
  884. return (error == SA_AIS_OK ? res_lib_ckpt_sectionexpirationtimeset.header.error : error);
  885. }
  886. SaAisErrorT
  887. saCkptSectionIterationInitialize (
  888. SaCkptCheckpointHandleT checkpointHandle,
  889. SaCkptSectionsChosenT sectionsChosen,
  890. SaTimeT expirationTime,
  891. SaCkptSectionIterationHandleT *sectionIterationHandle)
  892. {
  893. SaAisErrorT error;
  894. struct ckptCheckpointInstance *ckptCheckpointInstance;
  895. struct ckptSectionIterationInstance *ckptSectionIterationInstance;
  896. struct req_lib_ckpt_sectioniteratorinitialize req_lib_ckpt_sectioniteratorinitialize;
  897. struct res_lib_ckpt_sectioniteratorinitialize res_lib_ckpt_sectioniteratorinitialize;
  898. error = saHandleInstanceGet (&checkpointHandleDatabase, checkpointHandle,
  899. (void *)&ckptCheckpointInstance);
  900. if (error != SA_AIS_OK) {
  901. goto error_no_destroy;
  902. }
  903. error = saHandleCreate (&ckptSectionIterationHandleDatabase,
  904. sizeof (struct ckptSectionIterationInstance), sectionIterationHandle);
  905. if (error != SA_AIS_OK) {
  906. goto error_put_checkpoint_db;
  907. }
  908. error = saHandleInstanceGet (&ckptSectionIterationHandleDatabase,
  909. *sectionIterationHandle, (void *)&ckptSectionIterationInstance);
  910. if (error != SA_AIS_OK) {
  911. goto error_destroy;
  912. }
  913. ckptSectionIterationInstance->response_fd = ckptCheckpointInstance->response_fd;
  914. ckptSectionIterationInstance->checkpointHandle = checkpointHandle;
  915. pthread_mutex_init (&ckptSectionIterationInstance->response_mutex, NULL);
  916. /*
  917. * Setup section id list for iterator next
  918. */
  919. list_init (&ckptSectionIterationInstance->sectionIdListHead);
  920. req_lib_ckpt_sectioniteratorinitialize.header.size = sizeof (struct req_lib_ckpt_sectioniteratorinitialize);
  921. req_lib_ckpt_sectioniteratorinitialize.header.id = MESSAGE_REQ_CKPT_SECTIONITERATOR_SECTIONITERATORINITIALIZE;
  922. req_lib_ckpt_sectioniteratorinitialize.sectionsChosen = sectionsChosen;
  923. req_lib_ckpt_sectioniteratorinitialize.expirationTime = expirationTime;
  924. memcpy (&req_lib_ckpt_sectioniteratorinitialize.checkpointName,
  925. &ckptCheckpointInstance->checkpointName, sizeof (SaNameT));
  926. pthread_mutex_lock (&ckptSectionIterationInstance->response_mutex);
  927. error = saSendRetry (ckptSectionIterationInstance->response_fd,
  928. &req_lib_ckpt_sectioniteratorinitialize,
  929. sizeof (struct req_lib_ckpt_sectioniteratorinitialize),
  930. MSG_NOSIGNAL);
  931. if (error != SA_AIS_OK) {
  932. goto error_put_destroy;
  933. }
  934. error = saRecvRetry (ckptSectionIterationInstance->response_fd,
  935. &res_lib_ckpt_sectioniteratorinitialize,
  936. sizeof (struct res_lib_ckpt_sectioniteratorinitialize),
  937. MSG_WAITALL | MSG_NOSIGNAL);
  938. pthread_mutex_unlock (&ckptSectionIterationInstance->response_mutex);
  939. saHandleInstancePut (&ckptSectionIterationHandleDatabase, *sectionIterationHandle);
  940. return (error == SA_AIS_OK ? res_lib_ckpt_sectioniteratorinitialize.header.error : error);
  941. error_put_destroy:
  942. saHandleInstancePut (&ckptSectionIterationHandleDatabase, *sectionIterationHandle);
  943. error_destroy:
  944. saHandleDestroy (&ckptSectionIterationHandleDatabase, *sectionIterationHandle);
  945. error_put_checkpoint_db:
  946. saHandleInstancePut (&checkpointHandleDatabase, checkpointHandle);
  947. error_no_destroy:
  948. return (error);
  949. }
  950. struct iteratorSectionIdListEntry {
  951. struct list_head list;
  952. char data[0];
  953. };
  954. SaAisErrorT
  955. saCkptSectionIterationNext (
  956. SaCkptSectionIterationHandleT sectionIterationHandle,
  957. SaCkptSectionDescriptorT *sectionDescriptor)
  958. {
  959. SaAisErrorT error;
  960. struct ckptSectionIterationInstance *ckptSectionIterationInstance;
  961. struct req_lib_ckpt_sectioniteratornext req_lib_ckpt_sectioniteratornext;
  962. struct res_lib_ckpt_sectioniteratornext res_lib_ckpt_sectioniteratornext;
  963. struct iteratorSectionIdListEntry *iteratorSectionIdListEntry;
  964. error = saHandleInstanceGet (&ckptSectionIterationHandleDatabase,
  965. sectionIterationHandle, (void *)&ckptSectionIterationInstance);
  966. if (error != SA_AIS_OK) {
  967. goto error_exit;
  968. }
  969. /*
  970. * Allocate section id storage area
  971. */
  972. /*
  973. * TODO max section id size is 500
  974. */
  975. iteratorSectionIdListEntry = malloc (sizeof (struct list_head) + 500);
  976. if (iteratorSectionIdListEntry == 0) {
  977. error = SA_AIS_ERR_NO_MEMORY;
  978. goto error_put_nounlock;
  979. }
  980. req_lib_ckpt_sectioniteratornext.header.size = sizeof (struct req_lib_ckpt_sectioniteratornext);
  981. req_lib_ckpt_sectioniteratornext.header.id = MESSAGE_REQ_CKPT_SECTIONITERATOR_SECTIONITERATORNEXT;
  982. pthread_mutex_lock (&ckptSectionIterationInstance->response_mutex);
  983. error = saSendRetry (ckptSectionIterationInstance->response_fd,
  984. &req_lib_ckpt_sectioniteratornext,
  985. sizeof (struct req_lib_ckpt_sectioniteratornext), MSG_NOSIGNAL);
  986. if (error != SA_AIS_OK) {
  987. goto error_put;
  988. }
  989. error = saRecvRetry (ckptSectionIterationInstance->response_fd, &res_lib_ckpt_sectioniteratornext,
  990. sizeof (struct res_lib_ckpt_sectioniteratornext), MSG_WAITALL | MSG_NOSIGNAL);
  991. if (error != SA_AIS_OK) {
  992. goto error_put;
  993. }
  994. memcpy (sectionDescriptor,
  995. &res_lib_ckpt_sectioniteratornext.sectionDescriptor,
  996. sizeof (SaCkptSectionDescriptorT));
  997. sectionDescriptor->sectionId.id = &iteratorSectionIdListEntry->data[0];
  998. if ((res_lib_ckpt_sectioniteratornext.header.size - sizeof (struct res_lib_ckpt_sectioniteratornext)) > 0) {
  999. error = saRecvRetry (ckptSectionIterationInstance->response_fd,
  1000. sectionDescriptor->sectionId.id,
  1001. res_lib_ckpt_sectioniteratornext.header.size -
  1002. sizeof (struct res_lib_ckpt_sectioniteratornext),
  1003. MSG_WAITALL | MSG_NOSIGNAL);
  1004. }
  1005. /*
  1006. * Add to persistent memory list for this sectioniterator
  1007. */
  1008. if (error == SA_AIS_OK && res_lib_ckpt_sectioniteratornext.header.error == SA_AIS_OK) {
  1009. list_init (&iteratorSectionIdListEntry->list);
  1010. list_add (&iteratorSectionIdListEntry->list, &ckptSectionIterationInstance->sectionIdListHead);
  1011. }
  1012. error_put:
  1013. pthread_mutex_unlock (&ckptSectionIterationInstance->response_mutex);
  1014. error_put_nounlock:
  1015. saHandleInstancePut (&ckptSectionIterationHandleDatabase, sectionIterationHandle);
  1016. error_exit:
  1017. return (error == SA_AIS_OK ? res_lib_ckpt_sectioniteratornext.header.error : error);
  1018. }
  1019. SaAisErrorT
  1020. saCkptSectionIterationFinalize (
  1021. SaCkptSectionIterationHandleT sectionIterationHandle)
  1022. {
  1023. SaAisErrorT error;
  1024. struct ckptSectionIterationInstance *ckptSectionIterationInstance;
  1025. struct iteratorSectionIdListEntry *iteratorSectionIdListEntry;
  1026. struct list_head *sectionIdIterationList;
  1027. struct list_head *sectionIdIterationListNext;
  1028. error = saHandleInstanceGet (&ckptSectionIterationHandleDatabase,
  1029. sectionIterationHandle, (void *)&ckptSectionIterationInstance);
  1030. if (error != SA_AIS_OK) {
  1031. goto error_noput;
  1032. }
  1033. /*
  1034. * iterate list of section ids for this iterator to free the allocated memory
  1035. * be careful to cache next pointer because free removes memory from use
  1036. */
  1037. for (sectionIdIterationList = ckptSectionIterationInstance->sectionIdListHead.next,
  1038. sectionIdIterationListNext = sectionIdIterationList->next;
  1039. sectionIdIterationList != &ckptSectionIterationInstance->sectionIdListHead;
  1040. sectionIdIterationList = sectionIdIterationListNext,
  1041. sectionIdIterationListNext = sectionIdIterationList->next) {
  1042. iteratorSectionIdListEntry = list_entry (sectionIdIterationList,
  1043. struct iteratorSectionIdListEntry, list);
  1044. free (iteratorSectionIdListEntry);
  1045. }
  1046. saHandleInstancePut (&checkpointHandleDatabase,
  1047. ckptSectionIterationInstance->checkpointHandle);
  1048. saHandleInstancePut (&ckptSectionIterationHandleDatabase, sectionIterationHandle);
  1049. saHandleDestroy (&ckptSectionIterationHandleDatabase, sectionIterationHandle);
  1050. error_noput:
  1051. return (error);
  1052. }
  1053. SaAisErrorT
  1054. saCkptCheckpointWrite (
  1055. SaCkptCheckpointHandleT checkpointHandle,
  1056. const SaCkptIOVectorElementT *ioVector,
  1057. SaUint32T numberOfElements,
  1058. SaUint32T *erroneousVectorIndex)
  1059. {
  1060. SaAisErrorT error = SA_AIS_OK;
  1061. struct ckptCheckpointInstance *ckptCheckpointInstance;
  1062. struct req_lib_ckpt_sectionwrite req_lib_ckpt_sectionwrite;
  1063. struct res_lib_ckpt_sectionwrite res_lib_ckpt_sectionwrite;
  1064. int i;
  1065. struct iovec iov[3];
  1066. int iov_len = 0;
  1067. error = saHandleInstanceGet (&checkpointHandleDatabase, checkpointHandle,
  1068. (void *)&ckptCheckpointInstance);
  1069. if (error != SA_AIS_OK) {
  1070. return (error);
  1071. }
  1072. if ((ckptCheckpointInstance->checkpointOpenFlags & SA_CKPT_CHECKPOINT_WRITE) == 0) {
  1073. error = SA_AIS_ERR_ACCESS;
  1074. goto error_put;
  1075. }
  1076. req_lib_ckpt_sectionwrite.header.id = MESSAGE_REQ_CKPT_CHECKPOINT_SECTIONWRITE;
  1077. pthread_mutex_lock (&ckptCheckpointInstance->response_mutex);
  1078. for (i = 0; i < numberOfElements; i++) {
  1079. req_lib_ckpt_sectionwrite.header.size = sizeof (struct req_lib_ckpt_sectionwrite) + ioVector[i].sectionId.idLen + ioVector[i].dataSize;
  1080. req_lib_ckpt_sectionwrite.dataOffset = ioVector[i].dataOffset;
  1081. req_lib_ckpt_sectionwrite.dataSize = ioVector[i].dataSize;
  1082. req_lib_ckpt_sectionwrite.idLen = ioVector[i].sectionId.idLen;
  1083. memcpy (&req_lib_ckpt_sectionwrite.checkpointName,
  1084. &ckptCheckpointInstance->checkpointName, sizeof (SaNameT));
  1085. iov_len = 0;
  1086. /* TODO check for zero length stuff */
  1087. iov[0].iov_base = (char *)&req_lib_ckpt_sectionwrite;
  1088. iov[0].iov_len = sizeof (struct req_lib_ckpt_sectionwrite);
  1089. iov[1].iov_base = ioVector[i].sectionId.id;
  1090. iov[1].iov_len = ioVector[i].sectionId.idLen;
  1091. iov[2].iov_base = ioVector[i].dataBuffer;
  1092. iov[2].iov_len = ioVector[i].dataSize;
  1093. error = saSendMsgRetry (ckptCheckpointInstance->response_fd,
  1094. iov,
  1095. 3);
  1096. if (error != SA_AIS_OK) {
  1097. goto error_exit;
  1098. }
  1099. /*
  1100. * Receive response
  1101. */
  1102. error = saRecvRetry (ckptCheckpointInstance->response_fd, &res_lib_ckpt_sectionwrite,
  1103. sizeof (struct res_lib_ckpt_sectionwrite), MSG_WAITALL | MSG_NOSIGNAL);
  1104. if (error != SA_AIS_OK) {
  1105. goto error_exit;
  1106. }
  1107. if (res_lib_ckpt_sectionwrite.header.error == SA_AIS_ERR_TRY_AGAIN) {
  1108. error = SA_AIS_ERR_TRY_AGAIN;
  1109. goto error_exit;
  1110. }
  1111. /*
  1112. * If error, report back erroneous index
  1113. */
  1114. if (res_lib_ckpt_sectionwrite.header.error != SA_AIS_OK) {
  1115. if (erroneousVectorIndex) {
  1116. *erroneousVectorIndex = i;
  1117. }
  1118. goto error_exit;
  1119. }
  1120. }
  1121. error_exit:
  1122. pthread_mutex_unlock (&ckptCheckpointInstance->response_mutex);
  1123. error_put:
  1124. saHandleInstancePut (&checkpointHandleDatabase, checkpointHandle);
  1125. return (error == SA_AIS_OK ? res_lib_ckpt_sectionwrite.header.error : error);
  1126. }
  1127. SaAisErrorT
  1128. saCkptSectionOverwrite (
  1129. SaCkptCheckpointHandleT checkpointHandle,
  1130. const SaCkptSectionIdT *sectionId,
  1131. const void *dataBuffer,
  1132. SaSizeT dataSize)
  1133. {
  1134. SaAisErrorT error;
  1135. struct ckptCheckpointInstance *ckptCheckpointInstance;
  1136. struct req_lib_ckpt_sectionoverwrite req_lib_ckpt_sectionoverwrite;
  1137. struct res_lib_ckpt_sectionoverwrite res_lib_ckpt_sectionoverwrite;
  1138. error = saHandleInstanceGet (&checkpointHandleDatabase, checkpointHandle,
  1139. (void *)&ckptCheckpointInstance);
  1140. if (error != SA_AIS_OK) {
  1141. return (error);
  1142. }
  1143. if ((ckptCheckpointInstance->checkpointOpenFlags & SA_CKPT_CHECKPOINT_WRITE) == 0) {
  1144. return (SA_AIS_ERR_ACCESS);
  1145. }
  1146. req_lib_ckpt_sectionoverwrite.header.size = sizeof (struct req_lib_ckpt_sectionoverwrite) + sectionId->idLen + dataSize;
  1147. req_lib_ckpt_sectionoverwrite.header.id = MESSAGE_REQ_CKPT_CHECKPOINT_SECTIONOVERWRITE;
  1148. req_lib_ckpt_sectionoverwrite.idLen = sectionId->idLen;
  1149. req_lib_ckpt_sectionoverwrite.dataSize = dataSize;
  1150. memcpy (&req_lib_ckpt_sectionoverwrite.checkpointName,
  1151. &ckptCheckpointInstance->checkpointName, sizeof (SaNameT));
  1152. pthread_mutex_lock (&ckptCheckpointInstance->response_mutex);
  1153. error = saSendRetry (ckptCheckpointInstance->response_fd, &req_lib_ckpt_sectionoverwrite,
  1154. sizeof (struct req_lib_ckpt_sectionoverwrite), MSG_NOSIGNAL);
  1155. if (error != SA_AIS_OK) {
  1156. goto error_exit;
  1157. }
  1158. if (sectionId->idLen) {
  1159. error = saSendRetry (ckptCheckpointInstance->response_fd, sectionId->id,
  1160. sectionId->idLen, MSG_NOSIGNAL);
  1161. if (error != SA_AIS_OK) {
  1162. goto error_exit;
  1163. }
  1164. }
  1165. error = saSendRetry (ckptCheckpointInstance->response_fd, dataBuffer, dataSize, MSG_NOSIGNAL);
  1166. if (error != SA_AIS_OK) {
  1167. goto error_exit;
  1168. }
  1169. error = saRecvRetry (ckptCheckpointInstance->response_fd,
  1170. &res_lib_ckpt_sectionoverwrite,
  1171. sizeof (struct res_lib_ckpt_sectionoverwrite),
  1172. MSG_WAITALL | MSG_NOSIGNAL);
  1173. error_exit:
  1174. pthread_mutex_unlock (&ckptCheckpointInstance->response_mutex);
  1175. saHandleInstancePut (&checkpointHandleDatabase, checkpointHandle);
  1176. return (error == SA_AIS_OK ? res_lib_ckpt_sectionoverwrite.header.error : error);
  1177. }
  1178. SaAisErrorT
  1179. saCkptCheckpointRead (
  1180. SaCkptCheckpointHandleT checkpointHandle,
  1181. SaCkptIOVectorElementT *ioVector,
  1182. SaUint32T numberOfElements,
  1183. SaUint32T *erroneousVectorIndex)
  1184. {
  1185. SaAisErrorT error = SA_AIS_OK;
  1186. struct ckptCheckpointInstance *ckptCheckpointInstance;
  1187. struct req_lib_ckpt_sectionread req_lib_ckpt_sectionread;
  1188. struct res_lib_ckpt_sectionread res_lib_ckpt_sectionread;
  1189. int dataLength;
  1190. int i;
  1191. struct iovec iov[3];
  1192. error = saHandleInstanceGet (&checkpointHandleDatabase, checkpointHandle,
  1193. (void *)&ckptCheckpointInstance);
  1194. if (error != SA_AIS_OK) {
  1195. return (error);
  1196. }
  1197. if ((ckptCheckpointInstance->checkpointOpenFlags & SA_CKPT_CHECKPOINT_READ) == 0) {
  1198. return (SA_AIS_ERR_ACCESS);
  1199. }
  1200. req_lib_ckpt_sectionread.header.id = MESSAGE_REQ_CKPT_CHECKPOINT_SECTIONREAD;
  1201. pthread_mutex_lock (&ckptCheckpointInstance->response_mutex);
  1202. for (i = 0; i < numberOfElements; i++) {
  1203. req_lib_ckpt_sectionread.header.size = sizeof (struct req_lib_ckpt_sectionread) +
  1204. ioVector[i].sectionId.idLen;
  1205. req_lib_ckpt_sectionread.idLen = ioVector[i].sectionId.idLen;
  1206. req_lib_ckpt_sectionread.dataOffset = ioVector[i].dataOffset;
  1207. req_lib_ckpt_sectionread.dataSize = ioVector[i].dataSize;
  1208. memcpy (&req_lib_ckpt_sectionread.checkpointName,
  1209. &ckptCheckpointInstance->checkpointName, sizeof (SaNameT));
  1210. iov[0].iov_base = (char *)&req_lib_ckpt_sectionread;
  1211. iov[0].iov_len = sizeof (struct req_lib_ckpt_sectionread);
  1212. iov[1].iov_base = ioVector[i].sectionId.id;
  1213. iov[1].iov_len = ioVector[i].sectionId.idLen;
  1214. error = saSendMsgRetry (ckptCheckpointInstance->response_fd,
  1215. iov,
  1216. 2);
  1217. /*
  1218. * Receive response header
  1219. */
  1220. error = saRecvRetry (ckptCheckpointInstance->response_fd, &res_lib_ckpt_sectionread,
  1221. sizeof (struct res_lib_ckpt_sectionread), MSG_WAITALL | MSG_NOSIGNAL);
  1222. if (error != SA_AIS_OK) {
  1223. goto error_exit;
  1224. }
  1225. dataLength = res_lib_ckpt_sectionread.header.size - sizeof (struct res_lib_ckpt_sectionread);
  1226. /*
  1227. * Receive checkpoint section data
  1228. */
  1229. if (dataLength > 0) {
  1230. error = saRecvRetry (ckptCheckpointInstance->response_fd, ioVector[i].dataBuffer,
  1231. dataLength, MSG_WAITALL | MSG_NOSIGNAL);
  1232. if (error != SA_AIS_OK) {
  1233. goto error_exit;
  1234. }
  1235. }
  1236. if (res_lib_ckpt_sectionread.header.error != SA_AIS_OK) {
  1237. if (erroneousVectorIndex) {
  1238. *erroneousVectorIndex = i;
  1239. }
  1240. goto error_exit;
  1241. }
  1242. /*
  1243. * Report back bytes of data read
  1244. */
  1245. ioVector[i].readSize = res_lib_ckpt_sectionread.dataRead;
  1246. }
  1247. error_exit:
  1248. pthread_mutex_unlock (&ckptCheckpointInstance->response_mutex);
  1249. saHandleInstancePut (&checkpointHandleDatabase, checkpointHandle);
  1250. return (error == SA_AIS_OK ? res_lib_ckpt_sectionread.header.error : error);
  1251. }
  1252. SaAisErrorT
  1253. saCkptCheckpointSynchronize (
  1254. SaCkptCheckpointHandleT checkpointHandle,
  1255. SaTimeT timeout)
  1256. {
  1257. SaAisErrorT error;
  1258. struct ckptCheckpointInstance *ckptCheckpointInstance;
  1259. struct req_lib_ckpt_checkpointsynchronize req_lib_ckpt_checkpointsynchronize;
  1260. struct res_lib_ckpt_checkpointsynchronize res_lib_ckpt_checkpointsynchronize;
  1261. error = saHandleInstanceGet (&checkpointHandleDatabase, checkpointHandle,
  1262. (void *)&ckptCheckpointInstance);
  1263. if (error != SA_AIS_OK) {
  1264. return (error);
  1265. }
  1266. req_lib_ckpt_checkpointsynchronize.header.size = sizeof (struct req_lib_ckpt_checkpointsynchronize);
  1267. req_lib_ckpt_checkpointsynchronize.header.id = MESSAGE_REQ_CKPT_CHECKPOINT_CHECKPOINTSYNCHRONIZE;
  1268. pthread_mutex_lock (&ckptCheckpointInstance->response_mutex);
  1269. error = saSendRetry (ckptCheckpointInstance->response_fd, &req_lib_ckpt_checkpointsynchronize,
  1270. sizeof (struct req_lib_ckpt_checkpointsynchronize), MSG_NOSIGNAL);
  1271. if (error != SA_AIS_OK) {
  1272. goto error_exit;
  1273. }
  1274. error = saRecvRetry (ckptCheckpointInstance->response_fd,
  1275. &res_lib_ckpt_checkpointsynchronize,
  1276. sizeof (struct res_lib_ckpt_checkpointsynchronize),
  1277. MSG_WAITALL | MSG_NOSIGNAL);
  1278. error_exit:
  1279. pthread_mutex_unlock (&ckptCheckpointInstance->response_mutex);
  1280. saHandleInstancePut (&checkpointHandleDatabase, checkpointHandle);
  1281. return (error == SA_AIS_OK ? res_lib_ckpt_checkpointsynchronize.header.error : error);
  1282. }
  1283. SaAisErrorT
  1284. saCkptCheckpointSynchronizeAsync (
  1285. SaCkptHandleT ckptHandle,
  1286. SaCkptCheckpointHandleT checkpointHandle,
  1287. SaInvocationT invocation)
  1288. {
  1289. return (SA_AIS_OK);
  1290. /* TODO not implemented in executive
  1291. struct ckptInstance *ckptInstance;
  1292. struct ckptCheckpointInstance *ckptCheckpointInstance;
  1293. SaAisErrorT error;
  1294. struct req_lib_ckpt_checkpointsynchronizeasync req_lib_ckpt_checkpointsynchronizeasync;
  1295. error = saHandleInstanceGet (&checkpointHandleDatabase, checkpointHandle,
  1296. (void *)&ckptCheckpointInstance);
  1297. if (error != SA_AIS_OK) {
  1298. return (error);
  1299. }
  1300. req_lib_ckpt_checkpointsynchronizeasync.header.size = sizeof (struct req_lib_ckpt_checkpointsynchronizeasync);
  1301. req_lib_ckpt_checkpointsynchronizeasync.header.id = MESSAGE_REQ_CKPT_CHECKPOINT_CHECKPOINTSYNCHRONIZEASYNC;
  1302. req_lib_ckpt_checkpointsynchronizeasync.invocation = invocation;
  1303. pthread_mutex_lock (&ckptCheckpointInstance->response_mutex);
  1304. pthread_mutex_lock (&ckptInstance->response_mutex);
  1305. error = saSendRetry (ckptInstance->response_fd, &req_lib_ckpt_checkpointsynchronizeasync,
  1306. sizeof (struct req_lib_ckpt_checkpointsynchronizeasync), MSG_NOSIGNAL);
  1307. pthread_mutex_unlock (&ckptInstance->response_mutex);
  1308. pthread_mutex_unlock (&ckptCheckpointInstance->response_mutex);
  1309. saHandleInstancePut (&checkpointHandleDatabase, *checkpointHandle);
  1310. return (error);
  1311. */
  1312. }