ckpt.c 50 KB

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