ckpt.c 67 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816
  1. /*
  2. * Copyright (c) 2003-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 <sys/types.h>
  35. #include <sys/uio.h>
  36. #include <sys/socket.h>
  37. #include <sys/un.h>
  38. #include <netinet/in.h>
  39. #include <unistd.h>
  40. #include <fcntl.h>
  41. #include <stdlib.h>
  42. #include <stdio.h>
  43. #include <errno.h>
  44. #include <signal.h>
  45. #include "../include/ais_types.h"
  46. #include "../include/ais_msg.h"
  47. #include "../include/list.h"
  48. #include "../include/queue.h"
  49. #include "aispoll.h"
  50. #include "mempool.h"
  51. #include "parse.h"
  52. #include "main.h"
  53. #include "print.h"
  54. #include "gmi.h"
  55. DECLARE_LIST_INIT(checkpointListHead);
  56. DECLARE_LIST_INIT(checkpointIteratorListHead);
  57. static gmi_recovery_plug_handle ckpt_checkpoint_recovery_plug_handle;
  58. static int ckpt_checkpoint_exec_init_fn (void);
  59. static int ckpt_checkpoint_exit_fn (struct conn_info *conn_info);
  60. static int ckptSectionIteratorApiFinalize (struct conn_info *conn_info);
  61. static int message_handler_req_lib_activatepoll (struct conn_info *, void *message);
  62. static int message_handler_req_exec_ckpt_checkpointopen (void *message, struct in_addr source_addr);
  63. static int message_handler_req_exec_ckpt_checkpointclose (void *message, struct in_addr source_addr);
  64. static int message_handler_req_exec_ckpt_checkpointunlink (void *message, struct in_addr source_addr);
  65. static int message_handler_req_exec_ckpt_checkpointretentiondurationset (void *message, struct in_addr source_addr);
  66. static int message_handler_req_exec_ckpt_sectioncreate (void *message, struct in_addr source_addr);
  67. static int message_handler_req_exec_ckpt_sectiondelete (void *message, struct in_addr source_addr);
  68. static int message_handler_req_exec_ckpt_sectionexpirationtimeset (void *message, struct in_addr source_addr);
  69. static int message_handler_req_exec_ckpt_sectionwrite (void *message, struct in_addr source_addr);
  70. static int message_handler_req_exec_ckpt_sectionoverwrite (void *message, struct in_addr source_addr);
  71. static int message_handler_req_exec_ckpt_sectionread (void *message, struct in_addr source_addr);
  72. static int message_handler_req_lib_ckpt_init (struct conn_info *conn_info, void *message);
  73. static int message_handler_req_lib_ckpt_checkpoint_init (struct conn_info *conn_info, void *message);
  74. static int message_handler_req_lib_ckpt_sectioniterator_init (struct conn_info *conn_info, void *message);
  75. static int message_handler_req_lib_ckpt_checkpointopen (struct conn_info *conn_info, void *message);
  76. static int message_handler_req_lib_ckpt_checkpointopenasync (struct conn_info *conn_info, void *message);
  77. static int message_handler_req_lib_ckpt_checkpointunlink (struct conn_info *conn_info, void *message);
  78. static int message_handler_req_lib_ckpt_checkpointretentiondurationset (struct conn_info *conn_info, void *message);
  79. static int message_handler_req_lib_ckpt_activecheckpointset (struct conn_info *conn_info, void *message);
  80. static int message_handler_req_lib_ckpt_checkpointstatusget (struct conn_info *conn_info, void *message);
  81. static int message_handler_req_lib_ckpt_sectioncreate (struct conn_info *conn_info, void *message);
  82. static int message_handler_req_lib_ckpt_sectiondelete (struct conn_info *conn_info, void *message);
  83. static int message_handler_req_lib_ckpt_sectionexpirationtimeset (struct conn_info *conn_info, void *message);
  84. static int message_handler_req_lib_ckpt_sectionwrite (struct conn_info *conn_info, void *message);
  85. static int message_handler_req_lib_ckpt_sectionoverwrite (struct conn_info *conn_info, void *message);
  86. static int message_handler_req_lib_ckpt_sectionread (struct conn_info *conn_info, void *message);
  87. static int message_handler_req_lib_ckpt_checkpointsynchronize (struct conn_info *conn_info, void *message);
  88. static int message_handler_req_lib_ckpt_checkpointsynchronizeasync (struct conn_info *conn_info, void *message);
  89. static int message_handler_req_lib_ckpt_sectioniteratorinitialize (struct conn_info *conn_info, void *message);
  90. static int message_handler_req_lib_ckpt_sectioniteratornext (struct conn_info *conn_info, void *message);
  91. static int ckpt_checkpoint_confchg_fn (
  92. enum gmi_configuration_type configuration_type,
  93. struct sockaddr_in *member_list, int member_list_entries,
  94. struct sockaddr_in *left_list, int left_list_entries,
  95. struct sockaddr_in *joined_list, int joined_list_entries) {
  96. if (configuration_type == GMI_CONFIGURATION_REGULAR) {
  97. gmi_recovery_plug_unplug (ckpt_checkpoint_recovery_plug_handle);
  98. }
  99. return (0);
  100. }
  101. struct libais_handler ckpt_libais_handlers[] =
  102. {
  103. { /* 0 */
  104. .libais_handler_fn = message_handler_req_lib_activatepoll,
  105. .response_size = sizeof (struct res_lib_activatepoll),
  106. .response_id = MESSAGE_RES_LIB_ACTIVATEPOLL,
  107. .gmi_prio = GMI_PRIO_RECOVERY
  108. }
  109. };
  110. /*
  111. * TODO
  112. */
  113. int (*ckpt_aisexec_handler_fns[]) (void *, struct in_addr source_addr) = {
  114. };
  115. /*
  116. * exported service
  117. */
  118. struct service_handler ckpt_service_handler = {
  119. .libais_handlers = ckpt_libais_handlers,
  120. .libais_handlers_count = sizeof (ckpt_libais_handlers) / sizeof (struct libais_handler),
  121. .aisexec_handler_fns = ckpt_aisexec_handler_fns,
  122. .aisexec_handler_fns_count = sizeof (ckpt_aisexec_handler_fns) / sizeof (int (*)),
  123. .confchg_fn = 0, /* ckpt service handler is not distributed */
  124. .libais_init_fn = message_handler_req_lib_ckpt_init,
  125. .libais_exit_fn = 0,
  126. .exec_init_fn = 0
  127. };
  128. struct libais_handler ckpt_checkpoint_libais_handlers[] =
  129. {
  130. { /* 0 */
  131. .libais_handler_fn = message_handler_req_lib_activatepoll,
  132. .response_size = sizeof (struct res_lib_activatepoll),
  133. .response_id = MESSAGE_RES_LIB_ACTIVATEPOLL,
  134. .gmi_prio = GMI_PRIO_RECOVERY
  135. },
  136. { /* 1 */
  137. .libais_handler_fn = message_handler_req_lib_ckpt_checkpointopen,
  138. .response_size = sizeof (struct res_lib_ckpt_checkpointopen),
  139. .response_id = MESSAGE_RES_CKPT_CHECKPOINT_CHECKPOINTOPEN,
  140. .gmi_prio = GMI_PRIO_MED
  141. },
  142. { /* 2 */
  143. .libais_handler_fn = message_handler_req_lib_ckpt_checkpointopenasync,
  144. .response_size = sizeof (struct res_lib_ckpt_checkpointopenasync),
  145. .response_id = MESSAGE_RES_CKPT_CHECKPOINT_CHECKPOINTOPENASYNC,
  146. .gmi_prio = GMI_PRIO_MED
  147. },
  148. { /* 3 */
  149. .libais_handler_fn = message_handler_req_lib_ckpt_checkpointunlink,
  150. .response_size = sizeof (struct res_lib_ckpt_checkpointunlink),
  151. .response_id = MESSAGE_RES_CKPT_CHECKPOINT_CHECKPOINTUNLINK,
  152. .gmi_prio = GMI_PRIO_MED
  153. },
  154. { /* 4 */
  155. .libais_handler_fn = message_handler_req_lib_ckpt_checkpointretentiondurationset,
  156. .response_size = sizeof (struct res_lib_ckpt_checkpointretentiondurationset),
  157. .response_id = MESSAGE_RES_CKPT_CHECKPOINT_CHECKPOINTRETENTIONDURATIONSET,
  158. .gmi_prio = GMI_PRIO_LOW
  159. },
  160. { /* 5 */
  161. .libais_handler_fn = message_handler_req_lib_ckpt_activecheckpointset,
  162. .response_size = sizeof (struct res_lib_ckpt_activecheckpointset),
  163. .response_id = MESSAGE_RES_CKPT_CHECKPOINT_ACTIVECHECKPOINTSET,
  164. .gmi_prio = GMI_PRIO_MED
  165. },
  166. { /* 6 */
  167. .libais_handler_fn = message_handler_req_lib_ckpt_checkpointstatusget,
  168. .response_size = sizeof (struct res_lib_ckpt_checkpointstatusget),
  169. .response_id = MESSAGE_RES_CKPT_CHECKPOINT_CHECKPOINTSTATUSGET,
  170. .gmi_prio = GMI_PRIO_MED
  171. },
  172. { /* 7 */
  173. .libais_handler_fn = message_handler_req_lib_ckpt_sectioncreate,
  174. .response_size = sizeof (struct res_lib_ckpt_sectioncreate),
  175. .response_id = MESSAGE_RES_CKPT_CHECKPOINT_SECTIONCREATE,
  176. .gmi_prio = GMI_PRIO_MED
  177. },
  178. { /* 8 */
  179. .libais_handler_fn = message_handler_req_lib_ckpt_sectiondelete,
  180. .response_size = sizeof (struct res_lib_ckpt_sectiondelete),
  181. .response_id = MESSAGE_RES_CKPT_CHECKPOINT_SECTIONDELETE,
  182. .gmi_prio = GMI_PRIO_MED
  183. },
  184. { /* 9 */
  185. .libais_handler_fn = message_handler_req_lib_ckpt_sectionexpirationtimeset,
  186. .response_size = sizeof (struct res_lib_ckpt_sectionexpirationtimeset),
  187. .response_id = MESSAGE_RES_CKPT_CHECKPOINT_SECTIONEXPIRATIONTIMESET,
  188. .gmi_prio = GMI_PRIO_LOW
  189. },
  190. { /* 10 */
  191. .libais_handler_fn = message_handler_req_lib_ckpt_sectionwrite,
  192. .response_size = sizeof (struct res_lib_ckpt_sectionwrite),
  193. .response_id = MESSAGE_RES_CKPT_CHECKPOINT_SECTIONWRITE,
  194. .gmi_prio = GMI_PRIO_LOW
  195. },
  196. { /* 11 */
  197. .libais_handler_fn = message_handler_req_lib_ckpt_sectionoverwrite,
  198. .response_size = sizeof (struct res_lib_ckpt_sectionoverwrite),
  199. .response_id = MESSAGE_RES_CKPT_CHECKPOINT_SECTIONOVERWRITE,
  200. .gmi_prio = GMI_PRIO_LOW
  201. },
  202. { /* 12 */
  203. .libais_handler_fn = message_handler_req_lib_ckpt_sectionread,
  204. .response_size = sizeof (struct res_lib_ckpt_sectionread),
  205. .response_id = MESSAGE_RES_CKPT_CHECKPOINT_SECTIONREAD,
  206. .gmi_prio = GMI_PRIO_LOW
  207. },
  208. { /* 13 */
  209. .libais_handler_fn = message_handler_req_lib_ckpt_checkpointsynchronize,
  210. .response_size = sizeof (struct res_lib_ckpt_checkpointsynchronize),
  211. .response_id = MESSAGE_RES_CKPT_CHECKPOINT_CHECKPOINTSYNCHRONIZE,
  212. .gmi_prio = GMI_PRIO_MED
  213. },
  214. { /* 14 */
  215. .libais_handler_fn = message_handler_req_lib_ckpt_checkpointsynchronizeasync,
  216. .response_size = sizeof (struct res_lib_ckpt_checkpointsynchronizeasync), // TODO RESPONSE
  217. .response_id = MESSAGE_RES_CKPT_CHECKPOINT_CHECKPOINTSYNCHRONIZEASYNC,
  218. .gmi_prio = GMI_PRIO_MED
  219. },
  220. };
  221. static int (*ckpt_checkpoint_aisexec_handler_fns[]) (void *msg, struct in_addr source_addr) = {
  222. message_handler_req_exec_ckpt_checkpointopen,
  223. message_handler_req_exec_ckpt_checkpointclose,
  224. message_handler_req_exec_ckpt_checkpointunlink,
  225. message_handler_req_exec_ckpt_checkpointretentiondurationset,
  226. message_handler_req_exec_ckpt_sectioncreate,
  227. message_handler_req_exec_ckpt_sectiondelete,
  228. message_handler_req_exec_ckpt_sectionexpirationtimeset,
  229. message_handler_req_exec_ckpt_sectionwrite,
  230. message_handler_req_exec_ckpt_sectionoverwrite,
  231. message_handler_req_exec_ckpt_sectionread
  232. };
  233. struct service_handler ckpt_checkpoint_service_handler = {
  234. .libais_handlers = ckpt_checkpoint_libais_handlers,
  235. .libais_handlers_count = sizeof (ckpt_checkpoint_libais_handlers) / sizeof (struct libais_handler),
  236. .aisexec_handler_fns = ckpt_checkpoint_aisexec_handler_fns,
  237. .aisexec_handler_fns_count = sizeof (ckpt_checkpoint_aisexec_handler_fns) / sizeof (int (*)),
  238. .confchg_fn = ckpt_checkpoint_confchg_fn,
  239. .libais_init_fn = message_handler_req_lib_ckpt_checkpoint_init,
  240. .libais_exit_fn = ckpt_checkpoint_exit_fn,
  241. .exec_init_fn = ckpt_checkpoint_exec_init_fn
  242. };
  243. struct libais_handler ckpt_sectioniterator_libais_handlers[] =
  244. {
  245. { /* 0 */
  246. .libais_handler_fn = message_handler_req_lib_activatepoll,
  247. .response_size = sizeof (struct res_lib_activatepoll),
  248. .response_id = MESSAGE_RES_LIB_ACTIVATEPOLL,
  249. .gmi_prio = GMI_PRIO_RECOVERY
  250. },
  251. { /* 1 */
  252. .libais_handler_fn = message_handler_req_lib_ckpt_sectioniteratorinitialize,
  253. .response_size = sizeof (struct res_lib_ckpt_sectioniteratorinitialize),
  254. .response_id = MESSAGE_RES_CKPT_SECTIONITERATOR_SECTIONITERATORINITIALIZE,
  255. .gmi_prio = GMI_PRIO_RECOVERY
  256. },
  257. { /* 2 */
  258. .libais_handler_fn = message_handler_req_lib_ckpt_sectioniteratornext,
  259. .response_size = sizeof (struct res_lib_ckpt_sectioniteratornext),
  260. .response_id = MESSAGE_RES_CKPT_SECTIONITERATOR_SECTIONITERATORNEXT,
  261. .gmi_prio = GMI_PRIO_RECOVERY
  262. }
  263. };
  264. static int (*ckpt_sectioniterator_aisexec_handler_fns[]) (void *msg, struct in_addr source_addr) = {
  265. };
  266. struct service_handler ckpt_sectioniterator_service_handler = {
  267. .libais_handlers = ckpt_sectioniterator_libais_handlers,
  268. .libais_handlers_count = sizeof (ckpt_sectioniterator_libais_handlers) / sizeof (struct libais_handler),
  269. .aisexec_handler_fns = ckpt_sectioniterator_aisexec_handler_fns ,
  270. .aisexec_handler_fns_count = sizeof (ckpt_sectioniterator_aisexec_handler_fns) / sizeof (int (*)),
  271. .confchg_fn = 0, /* Section Iterators are not distributed */
  272. .libais_init_fn = message_handler_req_lib_ckpt_sectioniterator_init,
  273. .libais_exit_fn = ckptSectionIteratorApiFinalize,
  274. .exec_init_fn = 0
  275. };
  276. static struct saCkptCheckpoint *findCheckpoint (SaNameT *name)
  277. {
  278. struct list_head *checkpointList;
  279. struct saCkptCheckpoint *checkpoint;
  280. for (checkpointList = checkpointListHead.next;
  281. checkpointList != &checkpointListHead;
  282. checkpointList = checkpointList->next) {
  283. checkpoint = list_entry (checkpointList,
  284. struct saCkptCheckpoint, list);
  285. if (SaNameTisNameT (name, &checkpoint->name)) {
  286. return (checkpoint);
  287. }
  288. }
  289. return (0);
  290. }
  291. static struct saCkptCheckpointSection *findCheckpointSection (
  292. struct saCkptCheckpoint *ckptCheckpoint,
  293. char *id,
  294. int idLen)
  295. {
  296. struct list_head *checkpointSectionList;
  297. struct saCkptCheckpointSection *ckptCheckpointSection;
  298. log_printf (LOG_LEVEL_DEBUG, "Finding checkpoint section id %s %d\n", id, idLen);
  299. for (checkpointSectionList = ckptCheckpoint->checkpointSectionsListHead.next;
  300. checkpointSectionList != &ckptCheckpoint->checkpointSectionsListHead;
  301. checkpointSectionList = checkpointSectionList->next) {
  302. ckptCheckpointSection = list_entry (checkpointSectionList,
  303. struct saCkptCheckpointSection, list);
  304. log_printf (LOG_LEVEL_DEBUG, "Checking section id %s %d\n",
  305. ckptCheckpointSection->sectionDescriptor.sectionId.id,
  306. ckptCheckpointSection->sectionDescriptor.sectionId.idLen);
  307. if (ckptCheckpointSection->sectionDescriptor.sectionId.idLen == idLen &&
  308. (memcmp (ckptCheckpointSection->sectionDescriptor.sectionId.id,
  309. id, idLen) == 0)) {
  310. return (ckptCheckpointSection);
  311. }
  312. }
  313. return 0;
  314. }
  315. void checkpoint_release (struct saCkptCheckpoint *checkpoint)
  316. {
  317. struct list_head *list;
  318. struct saCkptCheckpointSection *section;
  319. int *buf = (struct saCkptCheckpoint *)checkpoint;
  320. poll_timer_delete (*gmi_poll_handle, checkpoint->retention_timer);
  321. assert (*buf != 0xdeadbeef);
  322. /*
  323. * Release all checkpoint sections for this checkpoint
  324. */
  325. for (list = checkpoint->checkpointSectionsListHead.next;
  326. list != &checkpoint->checkpointSectionsListHead;) {
  327. section = list_entry (list,
  328. struct saCkptCheckpointSection, list);
  329. free (section->sectionDescriptor.sectionId.id);
  330. free (section->sectionData);
  331. list = list->next;
  332. free (section);
  333. }
  334. list_del (&checkpoint->list);
  335. *buf = 0xdeadbeef;
  336. free (checkpoint);
  337. }
  338. int sendCkptCheckpointClose (struct saCkptCheckpoint *checkpoint) {
  339. struct req_exec_ckpt_checkpointclose req_exec_ckpt_checkpointclose;
  340. struct iovec iovecs[2];
  341. req_exec_ckpt_checkpointclose.header.size =
  342. sizeof (struct req_exec_ckpt_checkpointclose);
  343. req_exec_ckpt_checkpointclose.header.id = MESSAGE_REQ_EXEC_CKPT_CHECKPOINTCLOSE;
  344. memcpy (&req_exec_ckpt_checkpointclose.checkpointName,
  345. &checkpoint->name,
  346. sizeof (SaNameT));
  347. iovecs[0].iov_base = (char *)&req_exec_ckpt_checkpointclose;
  348. iovecs[0].iov_len = sizeof (req_exec_ckpt_checkpointclose);
  349. if (gmi_send_ok (GMI_PRIO_HIGH, sizeof (struct req_exec_ckpt_checkpointclose))) {
  350. gmi_mcast (&aisexec_groupname, iovecs, 1, GMI_PRIO_HIGH);
  351. return (0);
  352. }
  353. return (-1);
  354. }
  355. static int ckpt_checkpoint_exec_init_fn (void)
  356. {
  357. int res;
  358. res = gmi_recovery_plug_create (&ckpt_checkpoint_recovery_plug_handle);
  359. if (res != 0) {
  360. log_printf(LOG_LEVEL_ERROR,
  361. "Could not create recovery plug for clm service.\n");
  362. return (-1);
  363. }
  364. return (0);
  365. }
  366. static int ckpt_checkpoint_exit_fn (struct conn_info *conn_info)
  367. {
  368. /*
  369. * close checkpoint opened from this fd
  370. */
  371. if (conn_info->service == SOCKET_SERVICE_CKPT_CHECKPOINT &&
  372. conn_info->ais_ci.u.libckpt_ci.checkpoint) {
  373. log_printf (LOG_LEVEL_DEBUG, "Trying to finalize %d %s\n", conn_info,
  374. getSaNameT (&conn_info->ais_ci.u.libckpt_ci.checkpoint->name));
  375. sendCkptCheckpointClose (conn_info->ais_ci.u.libckpt_ci.checkpoint);
  376. }
  377. return (0);
  378. }
  379. static int ckptSectionIteratorApiFinalize (struct conn_info *conn_info) {
  380. /*
  381. * If section iterator connection, unlink from list and free section iterator data
  382. */
  383. if (conn_info->service == SOCKET_SERVICE_CKPT_SECTIONITERATOR) {
  384. log_printf (LOG_LEVEL_DEBUG, "freeing section iterator\n");
  385. if (conn_info->ais_ci.u.libckpt_ci.sectionIterator.sectionIteratorEntries) {
  386. free (conn_info->ais_ci.u.libckpt_ci.sectionIterator.sectionIteratorEntries);
  387. }
  388. list_del (&conn_info->ais_ci.u.libckpt_ci.sectionIterator.list);
  389. }
  390. return (0);
  391. }
  392. static int message_handler_req_lib_activatepoll (struct conn_info *conn_info, void *message)
  393. {
  394. struct res_lib_activatepoll res_lib_activatepoll;
  395. res_lib_activatepoll.header.size = sizeof (struct res_lib_activatepoll);
  396. res_lib_activatepoll.header.id = MESSAGE_RES_LIB_ACTIVATEPOLL;
  397. res_lib_activatepoll.header.error = SA_OK;
  398. libais_send_response (conn_info, &res_lib_activatepoll,
  399. sizeof (struct res_lib_activatepoll));
  400. return (0);
  401. }
  402. static int message_handler_req_exec_ckpt_checkpointopen (void *message, struct in_addr source_addr)
  403. {
  404. struct req_exec_ckpt_checkpointopen *req_exec_ckpt_checkpointopen = (struct req_exec_ckpt_checkpointopen *)message;
  405. struct req_lib_ckpt_checkpointopen *req_lib_ckpt_checkpointopen = (struct req_lib_ckpt_checkpointopen *)&req_exec_ckpt_checkpointopen->req_lib_ckpt_checkpointopen;
  406. struct res_lib_ckpt_checkpointopen res_lib_ckpt_checkpointopen;
  407. struct saCkptCheckpoint *ckptCheckpoint = 0;
  408. struct saCkptCheckpointSection *ckptCheckpointSection = 0;
  409. SaErrorT error = SA_OK;
  410. log_printf (LOG_LEVEL_DEBUG, "Executive request to open checkpoint %p\n", req_exec_ckpt_checkpointopen);
  411. ckptCheckpoint = findCheckpoint (&req_lib_ckpt_checkpointopen->checkpointName);
  412. /*
  413. * If checkpoint doesn't exist, create one
  414. */
  415. if (ckptCheckpoint == 0) {
  416. ckptCheckpoint = malloc (sizeof (struct saCkptCheckpoint));
  417. if (ckptCheckpoint == 0) {
  418. error = SA_ERR_NO_MEMORY;
  419. goto error_exit;
  420. }
  421. ckptCheckpointSection = malloc (sizeof (struct saCkptCheckpointSection));
  422. if (ckptCheckpointSection == 0) {
  423. free (ckptCheckpoint);
  424. error = SA_ERR_NO_MEMORY;
  425. goto error_exit;
  426. }
  427. memcpy (&ckptCheckpoint->name,
  428. &req_lib_ckpt_checkpointopen->checkpointName,
  429. sizeof (SaNameT));
  430. memcpy (&ckptCheckpoint->checkpointCreationAttributes,
  431. &req_lib_ckpt_checkpointopen->checkpointCreationAttributes,
  432. sizeof (SaCkptCheckpointCreationAttributesT));
  433. ckptCheckpoint->unlinked = 0;
  434. list_init (&ckptCheckpoint->list);
  435. list_init (&ckptCheckpoint->checkpointSectionsListHead);
  436. list_add (&ckptCheckpoint->list, &checkpointListHead);
  437. ckptCheckpoint->referenceCount = 0;
  438. ckptCheckpoint->retention_timer = 0;
  439. /*
  440. * Add in default checkpoint section
  441. */
  442. list_init (&ckptCheckpointSection->list);
  443. list_add (&ckptCheckpointSection->list, &ckptCheckpoint->checkpointSectionsListHead);
  444. ckptCheckpointSection->sectionDescriptor.expirationTime = 0xFFFFFFFF; //SA_END_TIME;
  445. /*
  446. * Default section id
  447. */
  448. ckptCheckpointSection->sectionDescriptor.sectionId.id = 0;
  449. ckptCheckpointSection->sectionDescriptor.sectionId.idLen = 0;
  450. ckptCheckpointSection->sectionDescriptor.sectionSize = 0;
  451. ckptCheckpointSection->sectionDescriptor.expirationTime = 0xffffffff; /* SA_END_TIME */
  452. ckptCheckpointSection->sectionDescriptor.sectionState = SA_CKPT_SECTION_VALID;
  453. ckptCheckpointSection->sectionDescriptor.lastUpdate = 0; // current time
  454. ckptCheckpointSection->sectionData = 0;
  455. }
  456. /*
  457. * If the checkpoint has been unlinked, it is an invalid name
  458. */
  459. if (ckptCheckpoint->unlinked) {
  460. error = SA_ERR_INVALID_PARAM; /* Is this the correct return ? */
  461. goto error_exit;
  462. }
  463. /*
  464. * Setup connection information and mark checkpoint as referenced
  465. */
  466. log_printf (LOG_LEVEL_DEBUG, "CHECKPOINT opened is %p\n", ckptCheckpoint);
  467. ckptCheckpoint->referenceCount += 1;
  468. /*
  469. * Reset retention duration since this checkpoint was just opened
  470. */
  471. poll_timer_delete (*gmi_poll_handle, ckptCheckpoint->retention_timer);
  472. ckptCheckpoint->retention_timer = 0;
  473. /*
  474. * Send error result to CKPT library
  475. */
  476. error_exit:
  477. /*
  478. * If this node was the source of the message, respond to this node
  479. */
  480. if (req_exec_ckpt_checkpointopen->source.in_addr.s_addr == this_ip.sin_addr.s_addr) {
  481. req_exec_ckpt_checkpointopen->source.conn_info->ais_ci.u.libckpt_ci.checkpoint = ckptCheckpoint;
  482. req_exec_ckpt_checkpointopen->source.conn_info->ais_ci.u.libckpt_ci.checkpointOpenFlags = req_lib_ckpt_checkpointopen->checkpointOpenFlags;
  483. res_lib_ckpt_checkpointopen.header.size = sizeof (struct res_lib_ckpt_checkpointopen);
  484. res_lib_ckpt_checkpointopen.header.id = MESSAGE_RES_CKPT_CHECKPOINT_CHECKPOINTOPEN;
  485. res_lib_ckpt_checkpointopen.header.error = error;
  486. libais_send_response (req_exec_ckpt_checkpointopen->source.conn_info, &res_lib_ckpt_checkpointopen,
  487. sizeof (struct res_lib_ckpt_checkpointopen));
  488. }
  489. // return (error == SA_OK ? 0 : -1);
  490. return (0);
  491. }
  492. void timer_function_retention (void *data)
  493. {
  494. struct req_exec_ckpt_checkpointunlink req_exec_ckpt_checkpointunlink;
  495. struct iovec iovecs[2];
  496. int result;
  497. req_exec_ckpt_checkpointunlink.header.size =
  498. sizeof (struct req_exec_ckpt_checkpointunlink);
  499. req_exec_ckpt_checkpointunlink.header.id = MESSAGE_REQ_EXEC_CKPT_CHECKPOINTUNLINK;
  500. req_exec_ckpt_checkpointunlink.source.conn_info = 0;
  501. req_exec_ckpt_checkpointunlink.source.in_addr.s_addr = 0;
  502. printf ("Retention timer expired\n");
  503. memcpy (&req_exec_ckpt_checkpointunlink.req_lib_ckpt_checkpointunlink.checkpointName,
  504. data,
  505. sizeof (SaNameT));
  506. iovecs[0].iov_base = (char *)&req_exec_ckpt_checkpointunlink;
  507. iovecs[0].iov_len = sizeof (req_exec_ckpt_checkpointunlink);
  508. result = gmi_mcast (&aisexec_groupname, iovecs, 1, GMI_PRIO_MED);
  509. }
  510. extern int message_handler_req_exec_ckpt_checkpointclose (void *message, struct in_addr source_addr)
  511. {
  512. struct req_exec_ckpt_checkpointclose *req_exec_ckpt_checkpointclose = (struct req_exec_ckpt_checkpointclose *)message;
  513. struct saCkptCheckpoint *checkpoint = 0;
  514. log_printf (LOG_LEVEL_DEBUG, "Got EXEC request to close checkpoint %s\n", getSaNameT (&req_exec_ckpt_checkpointclose->checkpointName));
  515. checkpoint = findCheckpoint (&req_exec_ckpt_checkpointclose->checkpointName);
  516. if (checkpoint == 0) {
  517. return (0);
  518. }
  519. checkpoint->referenceCount--;
  520. log_printf (LOG_LEVEL_DEBUG, "disconnect called, new CKPT ref count is %d\n",
  521. checkpoint->referenceCount);
  522. /*
  523. * If checkpoint has been unlinked and this is the last reference, delete it
  524. */
  525. if (checkpoint->unlinked && checkpoint->referenceCount == 0) {
  526. log_printf (LOG_LEVEL_DEBUG, "Unlinking checkpoint.\n");
  527. checkpoint_release (checkpoint);
  528. } else
  529. if (checkpoint->referenceCount == 0) {
  530. poll_timer_add (*gmi_poll_handle,
  531. checkpoint->checkpointCreationAttributes.retentionDuration / 100000,
  532. &checkpoint->name,
  533. timer_function_retention,
  534. &checkpoint->retention_timer);
  535. }
  536. return (0);
  537. }
  538. static int message_handler_req_exec_ckpt_checkpointunlink (void *message, struct in_addr source_addr)
  539. {
  540. struct req_exec_ckpt_checkpointunlink *req_exec_ckpt_checkpointunlink = (struct req_exec_ckpt_checkpointunlink *)message;
  541. struct req_lib_ckpt_checkpointunlink *req_lib_ckpt_checkpointunlink = (struct req_lib_ckpt_checkpointunlink *)&req_exec_ckpt_checkpointunlink->req_lib_ckpt_checkpointunlink;
  542. struct res_lib_ckpt_checkpointunlink res_lib_ckpt_checkpointunlink;
  543. struct saCkptCheckpoint *ckptCheckpoint = 0;
  544. SaErrorT error = SA_OK;
  545. log_printf (LOG_LEVEL_DEBUG, "Got EXEC request to unlink checkpoint %p\n", req_exec_ckpt_checkpointunlink);
  546. ckptCheckpoint = findCheckpoint (&req_lib_ckpt_checkpointunlink->checkpointName);
  547. if (ckptCheckpoint == 0) {
  548. error = SA_ERR_NOT_EXIST;
  549. goto error_exit;
  550. }
  551. if (ckptCheckpoint->unlinked) {
  552. error = SA_ERR_INVALID_PARAM;
  553. goto error_exit;
  554. }
  555. ckptCheckpoint->unlinked = 1;
  556. /*
  557. * Immediately delete entry if reference count is zero
  558. */
  559. if (ckptCheckpoint->referenceCount == 0) {
  560. /*
  561. * Remove retention timer since this checkpoint was unlinked and is no
  562. * longer referenced
  563. */
  564. checkpoint_release (ckptCheckpoint);
  565. }
  566. error_exit:
  567. /*
  568. * If this node was the source of the message, respond to this node
  569. */
  570. if (req_exec_ckpt_checkpointunlink->source.in_addr.s_addr == this_ip.sin_addr.s_addr) {
  571. res_lib_ckpt_checkpointunlink.header.size = sizeof (struct res_lib_ckpt_checkpointunlink);
  572. res_lib_ckpt_checkpointunlink.header.id = MESSAGE_RES_CKPT_CHECKPOINT_CHECKPOINTUNLINK;
  573. res_lib_ckpt_checkpointunlink.header.error = error;
  574. libais_send_response (req_exec_ckpt_checkpointunlink->source.conn_info, &res_lib_ckpt_checkpointunlink,
  575. sizeof (struct res_lib_ckpt_checkpointunlink));
  576. }
  577. return (0);
  578. }
  579. static int message_handler_req_exec_ckpt_checkpointretentiondurationset (void *message, struct in_addr source_addr)
  580. {
  581. struct req_exec_ckpt_checkpointretentiondurationset *req_exec_ckpt_checkpointretentiondurationset = (struct req_exec_ckpt_checkpointretentiondurationset *)message;
  582. struct saCkptCheckpoint *checkpoint;
  583. log_printf (LOG_LEVEL_DEBUG, "Got EXEC request to set retention duratione checkpoint %p\n", req_exec_ckpt_checkpointretentiondurationset);
  584. checkpoint = findCheckpoint (&req_exec_ckpt_checkpointretentiondurationset->checkpointName);
  585. if (checkpoint) {
  586. log_printf (LOG_LEVEL_DEBUG, "setting retention duration\n");
  587. checkpoint->checkpointCreationAttributes.retentionDuration = req_exec_ckpt_checkpointretentiondurationset->retentionDuration;
  588. }
  589. return (0);
  590. }
  591. static int message_handler_req_exec_ckpt_sectioncreate (void *message, struct in_addr source_addr) {
  592. struct req_exec_ckpt_sectioncreate *req_exec_ckpt_sectioncreate = (struct req_exec_ckpt_sectioncreate *)message;
  593. struct req_lib_ckpt_sectioncreate *req_lib_ckpt_sectioncreate = (struct req_lib_ckpt_sectioncreate *)&req_exec_ckpt_sectioncreate->req_lib_ckpt_sectioncreate;
  594. struct res_lib_ckpt_sectioncreate res_lib_ckpt_sectioncreate;
  595. struct saCkptCheckpoint *ckptCheckpoint;
  596. struct saCkptCheckpointSection *ckptCheckpointSection;
  597. void *initialData;
  598. void *sectionId;
  599. SaErrorT error = SA_OK;
  600. log_printf (LOG_LEVEL_DEBUG, "Executive request to create a checkpoint section.\n");
  601. ckptCheckpoint = findCheckpoint (&req_exec_ckpt_sectioncreate->checkpointName);
  602. if (ckptCheckpoint == 0) {
  603. error = SA_ERR_SYSTEM; // TODO find the right error for this
  604. goto error_exit;
  605. }
  606. /*
  607. * Determine if user-specified checkpoint ID already exists
  608. */
  609. ckptCheckpointSection = findCheckpointSection (ckptCheckpoint,
  610. ((char *)req_lib_ckpt_sectioncreate) + sizeof (struct req_lib_ckpt_sectioncreate),
  611. req_lib_ckpt_sectioncreate->idLen);
  612. if (ckptCheckpointSection) {
  613. error = SA_ERR_EXIST;
  614. goto error_exit;
  615. }
  616. /*
  617. * Allocate checkpoint section
  618. */
  619. ckptCheckpointSection = malloc (sizeof (struct saCkptCheckpointSection));
  620. if (ckptCheckpointSection == 0) {
  621. error = SA_ERR_NO_MEMORY;
  622. goto error_exit;
  623. }
  624. /*
  625. * Allocate checkpoint section data
  626. */
  627. initialData = malloc (req_lib_ckpt_sectioncreate->initialDataSize);
  628. if (initialData == 0) {
  629. free (ckptCheckpointSection);
  630. error = SA_ERR_NO_MEMORY;
  631. goto error_exit;
  632. }
  633. /*
  634. * Allocate checkpoint section id
  635. */
  636. sectionId = malloc (req_lib_ckpt_sectioncreate->idLen);
  637. if (sectionId == 0) {
  638. free (ckptCheckpointSection);
  639. free (initialData);
  640. error = SA_ERR_NO_MEMORY;
  641. goto error_exit;
  642. }
  643. /*
  644. * Copy checkpoint section and section ID
  645. */
  646. memcpy (sectionId, ((char *)req_lib_ckpt_sectioncreate) + sizeof (struct req_lib_ckpt_sectioncreate),
  647. req_lib_ckpt_sectioncreate->idLen);
  648. memcpy (initialData,
  649. ((char *)req_lib_ckpt_sectioncreate) +
  650. sizeof (struct req_lib_ckpt_sectioncreate) +
  651. req_lib_ckpt_sectioncreate->idLen,
  652. req_lib_ckpt_sectioncreate->initialDataSize);
  653. /*
  654. * Configure checkpoint section
  655. */
  656. ckptCheckpointSection->sectionDescriptor.expirationTime = req_lib_ckpt_sectioncreate->expirationTime;
  657. ckptCheckpointSection->sectionDescriptor.sectionId.id = sectionId;
  658. ckptCheckpointSection->sectionDescriptor.sectionId.idLen = req_lib_ckpt_sectioncreate->idLen;
  659. ckptCheckpointSection->sectionDescriptor.sectionSize = req_lib_ckpt_sectioncreate->initialDataSize;
  660. ckptCheckpointSection->sectionDescriptor.sectionState = SA_CKPT_SECTION_VALID;
  661. ckptCheckpointSection->sectionDescriptor.lastUpdate = 0; // TODO current time
  662. ckptCheckpointSection->sectionData = initialData;
  663. /*
  664. * Add checkpoint section to checkpoint
  665. */
  666. list_init (&ckptCheckpointSection->list);
  667. list_add (&ckptCheckpointSection->list, &ckptCheckpoint->checkpointSectionsListHead);
  668. error_exit:
  669. if (req_exec_ckpt_sectioncreate->source.in_addr.s_addr == this_ip.sin_addr.s_addr) {
  670. res_lib_ckpt_sectioncreate.header.size = sizeof (struct res_lib_ckpt_sectioncreate);
  671. res_lib_ckpt_sectioncreate.header.id = MESSAGE_RES_CKPT_CHECKPOINT_SECTIONCREATE;
  672. res_lib_ckpt_sectioncreate.header.error = error;
  673. libais_send_response (req_exec_ckpt_sectioncreate->source.conn_info,
  674. &res_lib_ckpt_sectioncreate,
  675. sizeof (struct res_lib_ckpt_sectioncreate));
  676. }
  677. return (0);
  678. }
  679. static int message_handler_req_exec_ckpt_sectiondelete (void *message, struct in_addr source_addr) {
  680. struct req_exec_ckpt_sectiondelete *req_exec_ckpt_sectiondelete = (struct req_exec_ckpt_sectiondelete *)message;
  681. struct req_lib_ckpt_sectiondelete *req_lib_ckpt_sectiondelete = (struct req_lib_ckpt_sectiondelete *)&req_exec_ckpt_sectiondelete->req_lib_ckpt_sectiondelete;
  682. struct res_lib_ckpt_sectiondelete res_lib_ckpt_sectiondelete;
  683. struct saCkptCheckpoint *ckptCheckpoint;
  684. struct saCkptCheckpointSection *ckptCheckpointSection;
  685. SaErrorT error = SA_OK;
  686. ckptCheckpoint = findCheckpoint (&req_exec_ckpt_sectiondelete->checkpointName);
  687. if (ckptCheckpoint == 0) {
  688. error = SA_ERR_NOT_EXIST;
  689. goto error_exit;
  690. }
  691. /*
  692. * Determine if the user is trying to delete the default section
  693. */
  694. if (req_lib_ckpt_sectiondelete->idLen == 0) {
  695. error = SA_ERR_INVALID_PARAM;
  696. goto error_exit;
  697. }
  698. /*
  699. * Find checkpoint section to be deleted
  700. */
  701. ckptCheckpointSection = findCheckpointSection (ckptCheckpoint,
  702. ((char *)(req_lib_ckpt_sectiondelete) + sizeof (struct req_lib_ckpt_sectiondelete)),
  703. req_lib_ckpt_sectiondelete->idLen);
  704. if (ckptCheckpointSection == 0) {
  705. printf ("section not found\n");
  706. error = SA_ERR_NOT_EXIST;
  707. goto error_exit;
  708. }
  709. /*
  710. * Delete checkpoint section
  711. */
  712. list_del (&ckptCheckpointSection->list);
  713. free (ckptCheckpointSection->sectionDescriptor.sectionId.id);
  714. free (ckptCheckpointSection->sectionData);
  715. free (ckptCheckpointSection);
  716. /*
  717. * return result to CKPT library
  718. */
  719. error_exit:
  720. if (req_exec_ckpt_sectiondelete->source.in_addr.s_addr == this_ip.sin_addr.s_addr) {
  721. res_lib_ckpt_sectiondelete.header.size = sizeof (struct res_lib_ckpt_sectiondelete);
  722. res_lib_ckpt_sectiondelete.header.id = MESSAGE_RES_CKPT_CHECKPOINT_SECTIONDELETE;
  723. res_lib_ckpt_sectiondelete.header.error = error;
  724. libais_send_response (req_exec_ckpt_sectiondelete->source.conn_info,
  725. &res_lib_ckpt_sectiondelete,
  726. sizeof (struct res_lib_ckpt_sectiondelete));
  727. }
  728. return (0);
  729. }
  730. static int message_handler_req_exec_ckpt_sectionexpirationtimeset (void *message, struct in_addr source_addr) {
  731. struct req_exec_ckpt_sectionexpirationtimeset *req_exec_ckpt_sectionexpirationtimeset = (struct req_exec_ckpt_sectionexpirationtimeset *)message;
  732. struct req_lib_ckpt_sectionexpirationtimeset *req_lib_ckpt_sectionexpirationtimeset = (struct req_lib_ckpt_sectionexpirationtimeset *)&req_exec_ckpt_sectionexpirationtimeset->req_lib_ckpt_sectionexpirationtimeset;
  733. struct res_lib_ckpt_sectionexpirationtimeset res_lib_ckpt_sectionexpirationtimeset;
  734. struct saCkptCheckpoint *ckptCheckpoint;
  735. struct saCkptCheckpointSection *ckptCheckpointSection;
  736. SaErrorT error = SA_OK;
  737. log_printf (LOG_LEVEL_DEBUG, "Executive request to set section expiratoin time\n");
  738. ckptCheckpoint = findCheckpoint (&req_exec_ckpt_sectionexpirationtimeset->checkpointName);
  739. if (ckptCheckpoint == 0) {
  740. error = SA_ERR_NOT_EXIST;
  741. goto error_exit;
  742. }
  743. /*
  744. * Determine if the user is trying to set expiration time for the default section
  745. */
  746. if (req_lib_ckpt_sectionexpirationtimeset->idLen == 0) {
  747. error = SA_ERR_INVALID_PARAM;
  748. goto error_exit;
  749. }
  750. /*
  751. * Find checkpoint section that expiration time should be set for
  752. */
  753. ckptCheckpointSection = findCheckpointSection (ckptCheckpoint,
  754. ((char *)req_lib_ckpt_sectionexpirationtimeset) +
  755. sizeof (struct req_lib_ckpt_sectionexpirationtimeset),
  756. req_lib_ckpt_sectionexpirationtimeset->idLen);
  757. if (ckptCheckpointSection == 0) {
  758. error = SA_ERR_NOT_EXIST;
  759. goto error_exit;
  760. }
  761. ckptCheckpointSection->sectionDescriptor.expirationTime = req_lib_ckpt_sectionexpirationtimeset->expirationTime;
  762. error_exit:
  763. if (req_exec_ckpt_sectionexpirationtimeset->source.in_addr.s_addr == this_ip.sin_addr.s_addr) {
  764. res_lib_ckpt_sectionexpirationtimeset.header.size = sizeof (struct res_lib_ckpt_sectionexpirationtimeset);
  765. res_lib_ckpt_sectionexpirationtimeset.header.id = MESSAGE_RES_CKPT_CHECKPOINT_SECTIONEXPIRATIONTIMESET;
  766. res_lib_ckpt_sectionexpirationtimeset.header.error = error;
  767. libais_send_response (req_exec_ckpt_sectionexpirationtimeset->source.conn_info,
  768. &res_lib_ckpt_sectionexpirationtimeset,
  769. sizeof (struct res_lib_ckpt_sectionexpirationtimeset));
  770. }
  771. return (0);
  772. }
  773. static int message_handler_req_exec_ckpt_sectionwrite (void *message, struct in_addr source_addr) {
  774. struct req_exec_ckpt_sectionwrite *req_exec_ckpt_sectionwrite = (struct req_exec_ckpt_sectionwrite *)message;
  775. struct req_lib_ckpt_sectionwrite *req_lib_ckpt_sectionwrite = (struct req_lib_ckpt_sectionwrite *)&req_exec_ckpt_sectionwrite->req_lib_ckpt_sectionwrite;
  776. struct res_lib_ckpt_sectionwrite res_lib_ckpt_sectionwrite;
  777. struct saCkptCheckpoint *ckptCheckpoint;
  778. struct saCkptCheckpointSection *ckptCheckpointSection;
  779. int sizeRequired;
  780. void *sectionData;
  781. SaErrorT error = SA_OK;
  782. log_printf (LOG_LEVEL_DEBUG, "Executive request to section write.\n");
  783. ckptCheckpoint = findCheckpoint (&req_exec_ckpt_sectionwrite->checkpointName);
  784. if (ckptCheckpoint == 0) {
  785. error = SA_ERR_NOT_EXIST;
  786. goto error_exit;
  787. }
  788. //printf ("writing checkpoint section is %s\n", ((char *)req_lib_ckpt_sectionwrite) + sizeof (struct req_lib_ckpt_sectionwrite));
  789. /*
  790. * Find checkpoint section to be written
  791. */
  792. ckptCheckpointSection = findCheckpointSection (ckptCheckpoint,
  793. ((char *)req_lib_ckpt_sectionwrite) + sizeof (struct req_lib_ckpt_sectionwrite),
  794. req_lib_ckpt_sectionwrite->idLen);
  795. if (ckptCheckpointSection == 0) {
  796. printf ("CANT FIND SECTION '%s'\n",
  797. ((char *)req_lib_ckpt_sectionwrite) + sizeof (struct req_lib_ckpt_sectionwrite));
  798. error = SA_ERR_NOT_EXIST;
  799. goto error_exit;
  800. }
  801. /*
  802. * If write would extend past end of section data, enlarge section
  803. */
  804. sizeRequired = req_lib_ckpt_sectionwrite->dataOffset + req_lib_ckpt_sectionwrite->dataSize;
  805. if (sizeRequired > ckptCheckpointSection->sectionDescriptor.sectionSize) {
  806. printf ("reallocating data\n");
  807. sectionData = realloc (ckptCheckpointSection->sectionData, sizeRequired);
  808. if (sectionData == 0) {
  809. error = SA_ERR_NO_MEMORY;
  810. goto error_exit;
  811. }
  812. /*
  813. * Install new section data
  814. */
  815. ckptCheckpointSection->sectionData = sectionData;
  816. ckptCheckpointSection->sectionDescriptor.sectionSize = sizeRequired;
  817. }
  818. /*
  819. * Write checkpoint section to section data
  820. */
  821. if (req_lib_ckpt_sectionwrite->dataSize > 0) {
  822. char *sd;
  823. int *val;
  824. val = ckptCheckpointSection->sectionData;
  825. sd = (char *)ckptCheckpointSection->sectionData;
  826. memcpy (&sd[req_lib_ckpt_sectionwrite->dataOffset],
  827. ((char *)req_exec_ckpt_sectionwrite) + sizeof (struct req_exec_ckpt_sectionwrite) +
  828. req_lib_ckpt_sectionwrite->idLen,
  829. req_lib_ckpt_sectionwrite->dataSize);
  830. }
  831. /*
  832. * Write write response to CKPT library
  833. */
  834. error_exit:
  835. if (req_exec_ckpt_sectionwrite->source.in_addr.s_addr == this_ip.sin_addr.s_addr) {
  836. res_lib_ckpt_sectionwrite.header.size = sizeof (struct res_lib_ckpt_sectionwrite);
  837. res_lib_ckpt_sectionwrite.header.id = MESSAGE_RES_CKPT_CHECKPOINT_SECTIONWRITE;
  838. res_lib_ckpt_sectionwrite.header.error = error;
  839. libais_send_response (req_exec_ckpt_sectionwrite->source.conn_info,
  840. &res_lib_ckpt_sectionwrite,
  841. sizeof (struct res_lib_ckpt_sectionwrite));
  842. }
  843. return (0);
  844. }
  845. static int message_handler_req_exec_ckpt_sectionoverwrite (void *message, struct in_addr source_addr) {
  846. struct req_exec_ckpt_sectionoverwrite *req_exec_ckpt_sectionoverwrite = (struct req_exec_ckpt_sectionoverwrite *)message;
  847. struct req_lib_ckpt_sectionoverwrite *req_lib_ckpt_sectionoverwrite = (struct req_lib_ckpt_sectionoverwrite *)&req_exec_ckpt_sectionoverwrite->req_lib_ckpt_sectionoverwrite;
  848. struct res_lib_ckpt_sectionoverwrite res_lib_ckpt_sectionoverwrite;
  849. struct saCkptCheckpoint *ckptCheckpoint;
  850. struct saCkptCheckpointSection *ckptCheckpointSection;
  851. void *sectionData;
  852. SaErrorT error = SA_OK;
  853. log_printf (LOG_LEVEL_DEBUG, "Executive request to section overwrite.\n");
  854. ckptCheckpoint = findCheckpoint (&req_exec_ckpt_sectionoverwrite->checkpointName);
  855. if (ckptCheckpoint == 0) {
  856. error = SA_ERR_NOT_EXIST;
  857. goto error_exit;
  858. }
  859. /*
  860. * Find checkpoint section to be overwritten
  861. */
  862. ckptCheckpointSection = findCheckpointSection (ckptCheckpoint,
  863. ((char *)req_lib_ckpt_sectionoverwrite) +
  864. sizeof (struct req_lib_ckpt_sectionoverwrite),
  865. req_lib_ckpt_sectionoverwrite->idLen);
  866. if (ckptCheckpointSection == 0) {
  867. error = SA_ERR_NOT_EXIST;
  868. goto error_exit;
  869. }
  870. /*
  871. * Allocate checkpoint section data
  872. */
  873. sectionData = malloc (req_lib_ckpt_sectionoverwrite->dataSize);
  874. if (sectionData == 0) {
  875. error = SA_ERR_NO_MEMORY;
  876. goto error_exit;
  877. }
  878. memcpy (sectionData,
  879. ((char *)req_lib_ckpt_sectionoverwrite) +
  880. sizeof (struct req_lib_ckpt_sectionoverwrite) +
  881. req_lib_ckpt_sectionoverwrite->idLen,
  882. req_lib_ckpt_sectionoverwrite->dataSize);
  883. /*
  884. * release old checkpoint section data
  885. */
  886. free (ckptCheckpointSection->sectionData);
  887. /*
  888. * Install overwritten checkpoint section data
  889. */
  890. ckptCheckpointSection->sectionDescriptor.sectionSize = req_lib_ckpt_sectionoverwrite->dataSize;
  891. ckptCheckpointSection->sectionDescriptor.sectionState = SA_CKPT_SECTION_VALID;
  892. ckptCheckpointSection->sectionDescriptor.lastUpdate = 0; // TODO current time
  893. ckptCheckpointSection->sectionData = sectionData;
  894. /*
  895. * return result to CKPT library
  896. */
  897. error_exit:
  898. if (req_exec_ckpt_sectionoverwrite->source.in_addr.s_addr == this_ip.sin_addr.s_addr) {
  899. res_lib_ckpt_sectionoverwrite.header.size = sizeof (struct res_lib_ckpt_sectionoverwrite);
  900. res_lib_ckpt_sectionoverwrite.header.id = MESSAGE_RES_CKPT_CHECKPOINT_SECTIONOVERWRITE;
  901. res_lib_ckpt_sectionoverwrite.header.error = error;
  902. libais_send_response (req_exec_ckpt_sectionoverwrite->source.conn_info,
  903. &res_lib_ckpt_sectionoverwrite,
  904. sizeof (struct res_lib_ckpt_sectionoverwrite));
  905. }
  906. return (0);
  907. }
  908. static int message_handler_req_exec_ckpt_sectionread (void *message, struct in_addr source_addr) {
  909. struct req_exec_ckpt_sectionread *req_exec_ckpt_sectionread = (struct req_exec_ckpt_sectionread *)message;
  910. struct req_lib_ckpt_sectionread *req_lib_ckpt_sectionread = (struct req_lib_ckpt_sectionread *)&req_exec_ckpt_sectionread->req_lib_ckpt_sectionread;
  911. struct res_lib_ckpt_sectionread res_lib_ckpt_sectionread;
  912. struct saCkptCheckpoint *ckptCheckpoint;
  913. struct saCkptCheckpointSection *ckptCheckpointSection = 0;
  914. int sectionSize = 0;
  915. SaErrorT error = SA_OK;
  916. log_printf (LOG_LEVEL_DEBUG, "Executive request for section read.\n");
  917. ckptCheckpoint = findCheckpoint (&req_exec_ckpt_sectionread->checkpointName);
  918. if (ckptCheckpoint == 0) {
  919. error = SA_ERR_SYSTEM; // TODO find the right error for this
  920. goto error_exit;
  921. }
  922. /*
  923. * Find checkpoint section to be read
  924. */
  925. ckptCheckpointSection = findCheckpointSection (ckptCheckpoint,
  926. ((char *)req_lib_ckpt_sectionread) +
  927. sizeof (struct req_lib_ckpt_sectionread),
  928. req_lib_ckpt_sectionread->idLen);
  929. if (ckptCheckpointSection == 0) {
  930. error = SA_ERR_NOT_EXIST;
  931. goto error_exit;
  932. }
  933. /*
  934. * Determine the section size
  935. */
  936. sectionSize = ckptCheckpointSection->sectionDescriptor.sectionSize -
  937. req_lib_ckpt_sectionread->dataOffset;
  938. /*
  939. * If the library has less space available then can be sent from the
  940. * section, reduce bytes sent to library to max requested
  941. */
  942. if (sectionSize > req_lib_ckpt_sectionread->dataSize) {
  943. sectionSize = req_lib_ckpt_sectionread->dataSize;
  944. }
  945. /*
  946. * If dataOffset is past end of data, return INVALID PARAM
  947. */
  948. if (req_lib_ckpt_sectionread->dataOffset > sectionSize) {
  949. sectionSize = 0;
  950. error = SA_ERR_INVALID_PARAM;
  951. goto error_exit;
  952. }
  953. /*
  954. * Write read response to CKPT library
  955. */
  956. error_exit:
  957. if (req_exec_ckpt_sectionread->source.in_addr.s_addr == this_ip.sin_addr.s_addr) {
  958. res_lib_ckpt_sectionread.header.size = sizeof (struct res_lib_ckpt_sectionread) + sectionSize;
  959. res_lib_ckpt_sectionread.header.id = MESSAGE_RES_CKPT_CHECKPOINT_SECTIONREAD;
  960. res_lib_ckpt_sectionread.header.error = error;
  961. libais_send_response (req_exec_ckpt_sectionread->source.conn_info,
  962. &res_lib_ckpt_sectionread,
  963. sizeof (struct res_lib_ckpt_sectionread));
  964. /*
  965. * Write checkpoint to CKPT library section if section has data
  966. */
  967. if (sectionSize) {
  968. char *sd;
  969. sd = (char *)ckptCheckpointSection->sectionData;
  970. libais_send_response (req_exec_ckpt_sectionread->source.conn_info,
  971. &sd[req_lib_ckpt_sectionread->dataOffset],
  972. sectionSize);
  973. }
  974. }
  975. return (0);
  976. }
  977. static int message_handler_req_lib_ckpt_init (struct conn_info *conn_info, void *message)
  978. {
  979. struct res_lib_init res_lib_init;
  980. SaErrorT error = SA_ERR_SECURITY;
  981. log_printf (LOG_LEVEL_DEBUG, "Got request to initialize CKPT.\n");
  982. if (conn_info->authenticated) {
  983. conn_info->service = SOCKET_SERVICE_CKPT;
  984. error = SA_OK;
  985. }
  986. res_lib_init.header.size = sizeof (struct res_lib_init);
  987. res_lib_init.header.id = MESSAGE_RES_INIT;
  988. res_lib_init.header.error = error;
  989. libais_send_response (conn_info, &res_lib_init, sizeof (res_lib_init));
  990. if (conn_info->authenticated) {
  991. return (0);
  992. }
  993. return (-1);
  994. }
  995. static int message_handler_req_lib_ckpt_checkpoint_init (struct conn_info *conn_info, void *message)
  996. {
  997. struct res_lib_init res_lib_init;
  998. SaErrorT error = SA_ERR_SECURITY;
  999. log_printf (LOG_LEVEL_DEBUG, "Got request to initialize CKPT checkpoint.\n");
  1000. if (conn_info->authenticated) {
  1001. conn_info->service = SOCKET_SERVICE_CKPT_CHECKPOINT;
  1002. conn_info->ais_ci.u.libckpt_ci.checkpoint = 0;
  1003. conn_info->ais_ci.u.libckpt_ci.checkpointOpenFlags = 0;
  1004. error = SA_OK;
  1005. }
  1006. res_lib_init.header.size = sizeof (struct res_lib_init);
  1007. res_lib_init.header.id = MESSAGE_RES_INIT;
  1008. res_lib_init.header.error = error;
  1009. libais_send_response (conn_info, &res_lib_init, sizeof (res_lib_init));
  1010. if (conn_info->authenticated) {
  1011. return (0);
  1012. }
  1013. return (-1);
  1014. }
  1015. static int message_handler_req_lib_ckpt_sectioniterator_init (struct conn_info *conn_info, void *message)
  1016. {
  1017. struct res_lib_init res_lib_init;
  1018. SaErrorT error = SA_ERR_SECURITY;
  1019. log_printf (LOG_LEVEL_DEBUG, "Got request to initialize CKPT section iterator.\n");
  1020. if (conn_info->authenticated) {
  1021. conn_info->service = SOCKET_SERVICE_CKPT_SECTIONITERATOR;
  1022. list_init (&conn_info->ais_ci.u.libckpt_ci.sectionIterator.list);
  1023. conn_info->ais_ci.u.libckpt_ci.sectionIterator.sectionIteratorEntries = 0;
  1024. conn_info->ais_ci.u.libckpt_ci.sectionIterator.iteratorCount = 0;
  1025. conn_info->ais_ci.u.libckpt_ci.sectionIterator.iteratorPos = 0;
  1026. list_add (&conn_info->ais_ci.u.libckpt_ci.sectionIterator.list,
  1027. &checkpointIteratorListHead);
  1028. error = SA_OK;
  1029. }
  1030. res_lib_init.header.size = sizeof (struct res_lib_init);
  1031. res_lib_init.header.id = MESSAGE_RES_INIT;
  1032. res_lib_init.header.error = error;
  1033. libais_send_response (conn_info, &res_lib_init, sizeof (res_lib_init));
  1034. if (conn_info->authenticated) {
  1035. return (0);
  1036. }
  1037. return (-1);
  1038. }
  1039. static int message_handler_req_lib_ckpt_checkpointopen (struct conn_info *conn_info, void *message)
  1040. {
  1041. struct req_lib_ckpt_checkpointopen *req_lib_ckpt_checkpointopen = (struct req_lib_ckpt_checkpointopen *)message;
  1042. struct req_exec_ckpt_checkpointopen req_exec_ckpt_checkpointopen;
  1043. struct iovec iovecs[2];
  1044. int result;
  1045. log_printf (LOG_LEVEL_DEBUG, "Library request to open checkpoint.\n");
  1046. req_exec_ckpt_checkpointopen.header.size =
  1047. sizeof (struct req_exec_ckpt_checkpointopen);
  1048. req_exec_ckpt_checkpointopen.header.id = MESSAGE_REQ_EXEC_CKPT_CHECKPOINTOPEN;
  1049. req_exec_ckpt_checkpointopen.source.conn_info = conn_info;
  1050. req_exec_ckpt_checkpointopen.source.in_addr.s_addr = this_ip.sin_addr.s_addr;
  1051. memcpy (&req_exec_ckpt_checkpointopen.req_lib_ckpt_checkpointopen,
  1052. req_lib_ckpt_checkpointopen,
  1053. sizeof (struct req_lib_ckpt_checkpointopen));
  1054. iovecs[0].iov_base = (char *)&req_exec_ckpt_checkpointopen;
  1055. iovecs[0].iov_len = sizeof (req_exec_ckpt_checkpointopen);
  1056. result = gmi_mcast (&aisexec_groupname, iovecs, 1, GMI_PRIO_MED);
  1057. return (0);
  1058. }
  1059. static int message_handler_req_lib_ckpt_checkpointopenasync (struct conn_info *conn_info, void *message)
  1060. {
  1061. return (0);
  1062. }
  1063. static int message_handler_req_lib_ckpt_checkpointunlink (struct conn_info *conn_info, void *message)
  1064. {
  1065. struct req_lib_ckpt_checkpointunlink *req_lib_ckpt_checkpointunlink = (struct req_lib_ckpt_checkpointunlink *)message;
  1066. struct req_exec_ckpt_checkpointunlink req_exec_ckpt_checkpointunlink;
  1067. struct iovec iovecs[2];
  1068. int result;
  1069. req_exec_ckpt_checkpointunlink.header.size =
  1070. sizeof (struct req_exec_ckpt_checkpointunlink);
  1071. req_exec_ckpt_checkpointunlink.header.id = MESSAGE_REQ_EXEC_CKPT_CHECKPOINTUNLINK;
  1072. req_exec_ckpt_checkpointunlink.source.conn_info = conn_info;
  1073. req_exec_ckpt_checkpointunlink.source.in_addr.s_addr = this_ip.sin_addr.s_addr;
  1074. memcpy (&req_exec_ckpt_checkpointunlink.req_lib_ckpt_checkpointunlink,
  1075. req_lib_ckpt_checkpointunlink,
  1076. sizeof (struct req_lib_ckpt_checkpointunlink));
  1077. iovecs[0].iov_base = (char *)&req_exec_ckpt_checkpointunlink;
  1078. iovecs[0].iov_len = sizeof (req_exec_ckpt_checkpointunlink);
  1079. result = gmi_mcast (&aisexec_groupname, iovecs, 1, GMI_PRIO_MED);
  1080. return (0);
  1081. }
  1082. static int message_handler_req_lib_ckpt_checkpointretentiondurationset (struct conn_info *conn_info, void *message)
  1083. {
  1084. struct req_lib_ckpt_checkpointretentiondurationset *req_lib_ckpt_checkpointretentiondurationset = (struct req_lib_ckpt_checkpointretentiondurationset *)message;
  1085. struct req_exec_ckpt_checkpointretentiondurationset req_exec_ckpt_checkpointretentiondurationset;
  1086. struct iovec iovecs[2];
  1087. log_printf (LOG_LEVEL_DEBUG, "DURATION SET FROM API fd %d\n", conn_info);
  1088. req_exec_ckpt_checkpointretentiondurationset.header.id = MESSAGE_REQ_EXEC_CKPT_CHECKPOINTRETENTIONDURATIONSET;
  1089. req_exec_ckpt_checkpointretentiondurationset.header.size = sizeof (struct req_exec_ckpt_checkpointretentiondurationset);
  1090. memcpy (&req_exec_ckpt_checkpointretentiondurationset.checkpointName,
  1091. &conn_info->ais_ci.u.libckpt_ci.checkpoint->name,
  1092. sizeof (SaNameT));
  1093. req_exec_ckpt_checkpointretentiondurationset.retentionDuration = req_lib_ckpt_checkpointretentiondurationset->retentionDuration;
  1094. iovecs[0].iov_base = (char *)&req_exec_ckpt_checkpointretentiondurationset;
  1095. iovecs[0].iov_len = sizeof (req_exec_ckpt_checkpointretentiondurationset);
  1096. gmi_mcast (&aisexec_groupname, iovecs, 1, GMI_PRIO_LOW);
  1097. return (0);
  1098. }
  1099. static int message_handler_req_lib_ckpt_activecheckpointset (struct conn_info *conn_info, void *message)
  1100. {
  1101. return (0);
  1102. }
  1103. static int message_handler_req_lib_ckpt_checkpointstatusget (struct conn_info *conn_info, void *message)
  1104. {
  1105. struct req_lib_ckpt_checkpointstatusget *req_lib_ckpt_checkpointstatusget = (struct req_lib_ckpt_checkpointstatusget *)message;
  1106. struct res_lib_ckpt_checkpointstatusget res_lib_ckpt_checkpointstatusget;
  1107. struct saCkptCheckpoint *checkpoint;
  1108. int memoryUsed = 0;
  1109. int numberOfSections = 0;
  1110. struct list_head *checkpointSectionList;
  1111. struct saCkptCheckpointSection *checkpointSection;
  1112. req_lib_ckpt_checkpointstatusget = 0; /* The request info isn't used */
  1113. log_printf (LOG_LEVEL_DEBUG, "in status get\n");
  1114. /*
  1115. * Count memory used by checkpoint sections
  1116. */
  1117. checkpoint = conn_info->ais_ci.u.libckpt_ci.checkpoint;
  1118. for (checkpointSectionList = checkpoint->checkpointSectionsListHead.next;
  1119. checkpointSectionList != &checkpoint->checkpointSectionsListHead;
  1120. checkpointSectionList = checkpointSectionList->next) {
  1121. checkpointSection = list_entry (checkpointSectionList,
  1122. struct saCkptCheckpointSection, list);
  1123. memoryUsed += checkpointSection->sectionDescriptor.sectionSize;
  1124. numberOfSections += 1;
  1125. }
  1126. /*
  1127. * Build checkpoint status get response
  1128. */
  1129. res_lib_ckpt_checkpointstatusget.header.size = sizeof (struct res_lib_ckpt_checkpointstatusget);
  1130. res_lib_ckpt_checkpointstatusget.header.id = MESSAGE_RES_CKPT_CHECKPOINT_CHECKPOINTSTATUSGET;
  1131. res_lib_ckpt_checkpointstatusget.header.error = SA_OK;
  1132. memcpy (&res_lib_ckpt_checkpointstatusget.checkpointStatus.checkpointCreationAttributes,
  1133. &checkpoint->checkpointCreationAttributes,
  1134. sizeof (SaCkptCheckpointCreationAttributesT));
  1135. res_lib_ckpt_checkpointstatusget.checkpointStatus.numberOfSections = numberOfSections;
  1136. res_lib_ckpt_checkpointstatusget.checkpointStatus.memoryUsed = memoryUsed;
  1137. log_printf (LOG_LEVEL_DEBUG, "before sending message\n");
  1138. libais_send_response (conn_info, &res_lib_ckpt_checkpointstatusget,
  1139. sizeof (struct res_lib_ckpt_checkpointstatusget));
  1140. return (0);
  1141. }
  1142. static int message_handler_req_lib_ckpt_sectioncreate (struct conn_info *conn_info, void *message)
  1143. {
  1144. struct req_lib_ckpt_sectioncreate *req_lib_ckpt_sectioncreate = (struct req_lib_ckpt_sectioncreate *)message;
  1145. struct req_exec_ckpt_sectioncreate req_exec_ckpt_sectioncreate;
  1146. struct res_lib_ckpt_sectioncreate res_lib_ckpt_sectioncreate;
  1147. struct iovec iovecs[2];
  1148. log_printf (LOG_LEVEL_DEBUG, "Section create from API fd %d\n", conn_info);
  1149. /*
  1150. * Determine if checkpoint is opened in write mode If not, send error to api
  1151. */
  1152. if ((conn_info->ais_ci.u.libckpt_ci.checkpointOpenFlags & SA_CKPT_CHECKPOINT_WRITE) == 0) {
  1153. res_lib_ckpt_sectioncreate.header.size = sizeof (struct res_lib_ckpt_sectioncreate);
  1154. res_lib_ckpt_sectioncreate.header.id = MESSAGE_RES_CKPT_CHECKPOINT_SECTIONCREATE;
  1155. res_lib_ckpt_sectioncreate.header.error = SA_ERR_ACCESS;
  1156. libais_send_response (conn_info, &res_lib_ckpt_sectioncreate,
  1157. sizeof (struct res_lib_ckpt_sectioncreate));
  1158. return (0);
  1159. }
  1160. /*
  1161. * checkpoint opened is writeable mode so send message to cluster
  1162. */
  1163. req_exec_ckpt_sectioncreate.header.id = MESSAGE_REQ_EXEC_CKPT_SECTIONCREATE;
  1164. req_exec_ckpt_sectioncreate.header.size = sizeof (struct req_exec_ckpt_sectioncreate);
  1165. memcpy (&req_exec_ckpt_sectioncreate.req_lib_ckpt_sectioncreate,
  1166. req_lib_ckpt_sectioncreate,
  1167. sizeof (struct req_lib_ckpt_sectioncreate));
  1168. memcpy (&req_exec_ckpt_sectioncreate.checkpointName,
  1169. &conn_info->ais_ci.u.libckpt_ci.checkpoint->name,
  1170. sizeof (SaNameT));
  1171. req_exec_ckpt_sectioncreate.source.conn_info = conn_info;
  1172. req_exec_ckpt_sectioncreate.source.in_addr.s_addr = this_ip.sin_addr.s_addr;
  1173. iovecs[0].iov_base = (char *)&req_exec_ckpt_sectioncreate;
  1174. iovecs[0].iov_len = sizeof (req_exec_ckpt_sectioncreate);
  1175. /*
  1176. * Send section name and initial data in message
  1177. */
  1178. iovecs[1].iov_base = ((char *)req_lib_ckpt_sectioncreate) + sizeof (struct req_lib_ckpt_sectioncreate);
  1179. iovecs[1].iov_len = req_lib_ckpt_sectioncreate->header.size - sizeof (struct req_lib_ckpt_sectioncreate);
  1180. #ifdef DEBUG
  1181. printf ("LIBRARY SECTIONCREATE string is %s len is %d\n", (unsigned char *)iovecs[1].iov_base,
  1182. iovecs[1].iov_len);
  1183. printf ("|\n");
  1184. { int i;
  1185. char *abc = iovecs[1].iov_base;
  1186. for (i = 0; i < 14;i++) {
  1187. printf ("%c ", abc[i]);
  1188. }
  1189. }
  1190. printf ("|\n");
  1191. #endif
  1192. if (iovecs[1].iov_len > 0) {
  1193. log_printf (LOG_LEVEL_DEBUG, "IOV_BASE is %s\n", iovecs[1].iov_base);
  1194. gmi_mcast (&aisexec_groupname, iovecs, 2, GMI_PRIO_MED);
  1195. } else {
  1196. gmi_mcast (&aisexec_groupname, iovecs, 1, GMI_PRIO_MED);
  1197. }
  1198. return (0);
  1199. }
  1200. static int message_handler_req_lib_ckpt_sectiondelete (struct conn_info *conn_info, void *message)
  1201. {
  1202. struct req_lib_ckpt_sectiondelete *req_lib_ckpt_sectiondelete = (struct req_lib_ckpt_sectiondelete *)message;
  1203. struct req_exec_ckpt_sectiondelete req_exec_ckpt_sectiondelete;
  1204. struct iovec iovecs[2];
  1205. log_printf (LOG_LEVEL_DEBUG, "section delete from API fd %d\n", conn_info);
  1206. req_exec_ckpt_sectiondelete.header.id = MESSAGE_REQ_EXEC_CKPT_SECTIONDELETE;
  1207. req_exec_ckpt_sectiondelete.header.size = sizeof (struct req_exec_ckpt_sectiondelete);
  1208. memcpy (&req_exec_ckpt_sectiondelete.checkpointName,
  1209. &conn_info->ais_ci.u.libckpt_ci.checkpoint->name,
  1210. sizeof (SaNameT));
  1211. memcpy (&req_exec_ckpt_sectiondelete.req_lib_ckpt_sectiondelete,
  1212. req_lib_ckpt_sectiondelete,
  1213. sizeof (struct req_lib_ckpt_sectiondelete));
  1214. req_exec_ckpt_sectiondelete.source.conn_info = conn_info;
  1215. req_exec_ckpt_sectiondelete.source.in_addr.s_addr = this_ip.sin_addr.s_addr;
  1216. iovecs[0].iov_base = (char *)&req_exec_ckpt_sectiondelete;
  1217. iovecs[0].iov_len = sizeof (req_exec_ckpt_sectiondelete);
  1218. /*
  1219. * Send section name
  1220. */
  1221. iovecs[1].iov_base = ((char *)req_lib_ckpt_sectiondelete) + sizeof (struct req_lib_ckpt_sectiondelete);
  1222. iovecs[1].iov_len = req_lib_ckpt_sectiondelete->header.size - sizeof (struct req_lib_ckpt_sectiondelete);
  1223. if (iovecs[1].iov_len > 0) {
  1224. log_printf (LOG_LEVEL_DEBUG, "IOV_BASE is %s\n", iovecs[1].iov_base);
  1225. gmi_mcast (&aisexec_groupname, iovecs, 2, GMI_PRIO_MED);
  1226. } else {
  1227. gmi_mcast (&aisexec_groupname, iovecs, 1, GMI_PRIO_MED);
  1228. }
  1229. return (0);
  1230. }
  1231. static int message_handler_req_lib_ckpt_sectionexpirationtimeset (struct conn_info *conn_info, void *message)
  1232. {
  1233. struct req_lib_ckpt_sectionexpirationtimeset *req_lib_ckpt_sectionexpirationtimeset = (struct req_lib_ckpt_sectionexpirationtimeset *)message;
  1234. struct req_exec_ckpt_sectionexpirationtimeset req_exec_ckpt_sectionexpirationtimeset;
  1235. struct iovec iovecs[2];
  1236. log_printf (LOG_LEVEL_DEBUG, "section expiration time set fd=%d\n", conn_info);
  1237. req_exec_ckpt_sectionexpirationtimeset.header.id = MESSAGE_REQ_EXEC_CKPT_SECTIONEXPIRATIONTIMESET;
  1238. req_exec_ckpt_sectionexpirationtimeset.header.size = sizeof (struct req_exec_ckpt_sectionexpirationtimeset);
  1239. memcpy (&req_exec_ckpt_sectionexpirationtimeset.checkpointName,
  1240. &conn_info->ais_ci.u.libckpt_ci.checkpoint->name,
  1241. sizeof (SaNameT));
  1242. memcpy (&req_exec_ckpt_sectionexpirationtimeset.req_lib_ckpt_sectionexpirationtimeset,
  1243. req_lib_ckpt_sectionexpirationtimeset,
  1244. sizeof (struct req_lib_ckpt_sectionexpirationtimeset));
  1245. req_exec_ckpt_sectionexpirationtimeset.source.conn_info = conn_info;
  1246. req_exec_ckpt_sectionexpirationtimeset.source.in_addr.s_addr = this_ip.sin_addr.s_addr;
  1247. iovecs[0].iov_base = (char *)&req_exec_ckpt_sectionexpirationtimeset;
  1248. iovecs[0].iov_len = sizeof (req_exec_ckpt_sectionexpirationtimeset);
  1249. /*
  1250. * Send section name
  1251. */
  1252. iovecs[1].iov_base = ((char *)req_lib_ckpt_sectionexpirationtimeset) + sizeof (struct req_lib_ckpt_sectionexpirationtimeset);
  1253. iovecs[1].iov_len = req_lib_ckpt_sectionexpirationtimeset->header.size - sizeof (struct req_lib_ckpt_sectionexpirationtimeset);
  1254. if (iovecs[1].iov_len > 0) {
  1255. log_printf (LOG_LEVEL_DEBUG, "IOV_BASE is %s\n", iovecs[1].iov_base);
  1256. gmi_mcast (&aisexec_groupname, iovecs, 2, GMI_PRIO_LOW);
  1257. } else {
  1258. gmi_mcast (&aisexec_groupname, iovecs, 1, GMI_PRIO_LOW);
  1259. }
  1260. return (0);
  1261. }
  1262. int write_inv = 0;
  1263. static int message_handler_req_lib_ckpt_sectionwrite (struct conn_info *conn_info, void *message)
  1264. {
  1265. struct req_lib_ckpt_sectionwrite *req_lib_ckpt_sectionwrite = (struct req_lib_ckpt_sectionwrite *)message;
  1266. struct req_exec_ckpt_sectionwrite req_exec_ckpt_sectionwrite;
  1267. struct res_lib_ckpt_sectionwrite res_lib_ckpt_sectionwrite;
  1268. struct iovec iovecs[2];
  1269. log_printf (LOG_LEVEL_DEBUG, "Section write from API fd %d\n", conn_info);
  1270. // UNDO printf ("section write %d\n", write_inv++);
  1271. /*
  1272. * Determine if checkpoint is opened in write mode If not, send error to api
  1273. */
  1274. if ((conn_info->ais_ci.u.libckpt_ci.checkpointOpenFlags & SA_CKPT_CHECKPOINT_WRITE) == 0) {
  1275. res_lib_ckpt_sectionwrite.header.size = sizeof (struct res_lib_ckpt_sectionwrite);
  1276. res_lib_ckpt_sectionwrite.header.id = MESSAGE_RES_CKPT_CHECKPOINT_SECTIONWRITE;
  1277. res_lib_ckpt_sectionwrite.header.error = SA_ERR_ACCESS;
  1278. libais_send_response (conn_info, &res_lib_ckpt_sectionwrite,
  1279. sizeof (struct res_lib_ckpt_sectionwrite));
  1280. return (0);
  1281. }
  1282. /*
  1283. * checkpoint opened is writeable mode so send message to cluster
  1284. */
  1285. req_exec_ckpt_sectionwrite.header.id = MESSAGE_REQ_EXEC_CKPT_SECTIONWRITE;
  1286. req_exec_ckpt_sectionwrite.header.size = sizeof (struct req_exec_ckpt_sectionwrite);
  1287. memcpy (&req_exec_ckpt_sectionwrite.req_lib_ckpt_sectionwrite,
  1288. req_lib_ckpt_sectionwrite,
  1289. sizeof (struct req_lib_ckpt_sectionwrite));
  1290. memcpy (&req_exec_ckpt_sectionwrite.checkpointName,
  1291. &conn_info->ais_ci.u.libckpt_ci.checkpoint->name,
  1292. sizeof (SaNameT));
  1293. req_exec_ckpt_sectionwrite.source.conn_info = conn_info;
  1294. req_exec_ckpt_sectionwrite.source.in_addr.s_addr = this_ip.sin_addr.s_addr;
  1295. iovecs[0].iov_base = (char *)&req_exec_ckpt_sectionwrite;
  1296. iovecs[0].iov_len = sizeof (req_exec_ckpt_sectionwrite);
  1297. /*
  1298. * Send section name and data to write in message
  1299. */
  1300. iovecs[1].iov_base = ((char *)req_lib_ckpt_sectionwrite) + sizeof (struct req_lib_ckpt_sectionwrite);
  1301. iovecs[1].iov_len = req_lib_ckpt_sectionwrite->header.size - sizeof (struct req_lib_ckpt_sectionwrite);
  1302. //printf ("LIB writing checkpoint section is %s\n", ((char *)req_lib_ckpt_sectionwrite) + sizeof (struct req_lib_ckpt_sectionwrite));
  1303. if (iovecs[1].iov_len > 0) {
  1304. gmi_mcast (&aisexec_groupname, iovecs, 2, GMI_PRIO_LOW);
  1305. } else {
  1306. gmi_mcast (&aisexec_groupname, iovecs, 1, GMI_PRIO_LOW);
  1307. }
  1308. return (0);
  1309. }
  1310. static int message_handler_req_lib_ckpt_sectionoverwrite (struct conn_info *conn_info, void *message)
  1311. {
  1312. struct req_lib_ckpt_sectionoverwrite *req_lib_ckpt_sectionoverwrite = (struct req_lib_ckpt_sectionoverwrite *)message;
  1313. struct req_exec_ckpt_sectionoverwrite req_exec_ckpt_sectionoverwrite;
  1314. struct res_lib_ckpt_sectionoverwrite res_lib_ckpt_sectionoverwrite;
  1315. struct iovec iovecs[2];
  1316. log_printf (LOG_LEVEL_DEBUG, "Section overwrite from API fd %d\n", conn_info);
  1317. /*
  1318. * Determine if checkpoint is opened in write mode If not, send error to api
  1319. */
  1320. if ((conn_info->ais_ci.u.libckpt_ci.checkpointOpenFlags & SA_CKPT_CHECKPOINT_WRITE) == 0) {
  1321. res_lib_ckpt_sectionoverwrite.header.size = sizeof (struct res_lib_ckpt_sectionoverwrite);
  1322. res_lib_ckpt_sectionoverwrite.header.id = MESSAGE_RES_CKPT_CHECKPOINT_SECTIONOVERWRITE;
  1323. res_lib_ckpt_sectionoverwrite.header.error = SA_ERR_ACCESS;
  1324. libais_send_response (conn_info, &res_lib_ckpt_sectionoverwrite,
  1325. sizeof (struct res_lib_ckpt_sectionoverwrite));
  1326. return (0);
  1327. }
  1328. /*
  1329. * checkpoint opened is writeable mode so send message to cluster
  1330. */
  1331. req_exec_ckpt_sectionoverwrite.header.id = MESSAGE_REQ_EXEC_CKPT_SECTIONOVERWRITE;
  1332. req_exec_ckpt_sectionoverwrite.header.size = sizeof (struct req_exec_ckpt_sectionoverwrite);
  1333. memcpy (&req_exec_ckpt_sectionoverwrite.req_lib_ckpt_sectionoverwrite,
  1334. req_lib_ckpt_sectionoverwrite,
  1335. sizeof (struct req_lib_ckpt_sectionoverwrite));
  1336. memcpy (&req_exec_ckpt_sectionoverwrite.checkpointName,
  1337. &conn_info->ais_ci.u.libckpt_ci.checkpoint->name,
  1338. sizeof (SaNameT));
  1339. req_exec_ckpt_sectionoverwrite.source.conn_info = conn_info;
  1340. req_exec_ckpt_sectionoverwrite.source.in_addr.s_addr = this_ip.sin_addr.s_addr;
  1341. iovecs[0].iov_base = (char *)&req_exec_ckpt_sectionoverwrite;
  1342. iovecs[0].iov_len = sizeof (req_exec_ckpt_sectionoverwrite);
  1343. /*
  1344. * Send section name and data to overwrite in message
  1345. */
  1346. iovecs[1].iov_base = ((char *)req_lib_ckpt_sectionoverwrite) + sizeof (struct req_lib_ckpt_sectionoverwrite);
  1347. iovecs[1].iov_len = req_lib_ckpt_sectionoverwrite->header.size - sizeof (struct req_lib_ckpt_sectionoverwrite);
  1348. if (iovecs[1].iov_len > 0) {
  1349. gmi_mcast (&aisexec_groupname, iovecs, 2, GMI_PRIO_LOW);
  1350. } else {
  1351. gmi_mcast (&aisexec_groupname, iovecs, 1, GMI_PRIO_LOW);
  1352. }
  1353. return (0);
  1354. }
  1355. static int message_handler_req_lib_ckpt_sectionread (struct conn_info *conn_info, void *message)
  1356. {
  1357. struct req_lib_ckpt_sectionread *req_lib_ckpt_sectionread = (struct req_lib_ckpt_sectionread *)message;
  1358. struct req_exec_ckpt_sectionread req_exec_ckpt_sectionread;
  1359. struct res_lib_ckpt_sectionread res_lib_ckpt_sectionread;
  1360. struct iovec iovecs[2];
  1361. log_printf (LOG_LEVEL_DEBUG, "Section overwrite from API fd %d\n", conn_info);
  1362. /*
  1363. * Determine if checkpoint is opened in write mode If not, send error to api
  1364. */
  1365. if ((conn_info->ais_ci.u.libckpt_ci.checkpointOpenFlags & SA_CKPT_CHECKPOINT_READ) == 0) {
  1366. res_lib_ckpt_sectionread.header.size = sizeof (struct res_lib_ckpt_sectionread);
  1367. res_lib_ckpt_sectionread.header.id = MESSAGE_RES_CKPT_CHECKPOINT_SECTIONREAD;
  1368. res_lib_ckpt_sectionread.header.error = SA_ERR_ACCESS;
  1369. libais_send_response (conn_info, &res_lib_ckpt_sectionread,
  1370. sizeof (struct res_lib_ckpt_sectionread));
  1371. return (0);
  1372. }
  1373. /*
  1374. * checkpoint opened is writeable mode so send message to cluster
  1375. */
  1376. req_exec_ckpt_sectionread.header.id = MESSAGE_REQ_EXEC_CKPT_SECTIONREAD;
  1377. req_exec_ckpt_sectionread.header.size = sizeof (struct req_exec_ckpt_sectionread);
  1378. memcpy (&req_exec_ckpt_sectionread.req_lib_ckpt_sectionread,
  1379. req_lib_ckpt_sectionread,
  1380. sizeof (struct req_lib_ckpt_sectionread));
  1381. memcpy (&req_exec_ckpt_sectionread.checkpointName,
  1382. &conn_info->ais_ci.u.libckpt_ci.checkpoint->name,
  1383. sizeof (SaNameT));
  1384. req_exec_ckpt_sectionread.source.conn_info = conn_info;
  1385. req_exec_ckpt_sectionread.source.in_addr.s_addr = this_ip.sin_addr.s_addr;
  1386. iovecs[0].iov_base = (char *)&req_exec_ckpt_sectionread;
  1387. iovecs[0].iov_len = sizeof (req_exec_ckpt_sectionread);
  1388. /*
  1389. * Send section name and data to overwrite in message
  1390. */
  1391. iovecs[1].iov_base = ((char *)req_lib_ckpt_sectionread) + sizeof (struct req_lib_ckpt_sectionread);
  1392. iovecs[1].iov_len = req_lib_ckpt_sectionread->header.size - sizeof (struct req_lib_ckpt_sectionread);
  1393. if (iovecs[1].iov_len > 0) {
  1394. gmi_mcast (&aisexec_groupname, iovecs, 2, GMI_PRIO_LOW);
  1395. } else {
  1396. gmi_mcast (&aisexec_groupname, iovecs, 1, GMI_PRIO_LOW);
  1397. }
  1398. return (0);
  1399. }
  1400. static int message_handler_req_lib_ckpt_checkpointsynchronize (struct conn_info *conn_info, void *message)
  1401. {
  1402. return (0);
  1403. }
  1404. static int message_handler_req_lib_ckpt_checkpointsynchronizeasync (struct conn_info *conn_info, void *message)
  1405. {
  1406. return (0);
  1407. }
  1408. static int message_handler_req_lib_ckpt_sectioniteratorinitialize (struct conn_info *conn_info, void *message)
  1409. {
  1410. struct req_lib_ckpt_sectioniteratorinitialize *req_lib_ckpt_sectioniteratorinitialize = (struct req_lib_ckpt_sectioniteratorinitialize *)message;
  1411. struct res_lib_ckpt_sectioniteratorinitialize res_lib_ckpt_sectioniteratorinitialize;
  1412. struct saCkptCheckpoint *ckptCheckpoint;
  1413. struct saCkptCheckpointSection *ckptCheckpointSection;
  1414. struct saCkptSectionIteratorEntry *ckptSectionIteratorEntries;
  1415. struct saCkptSectionIterator *ckptSectionIterator;
  1416. struct list_head *checkpointSectionList;
  1417. int addEntry = 0;
  1418. int iteratorEntries = 0;
  1419. SaErrorT error = SA_OK;
  1420. log_printf (LOG_LEVEL_DEBUG, "section iterator initialize\n");
  1421. ckptSectionIterator = &conn_info->ais_ci.u.libckpt_ci.sectionIterator;
  1422. ckptCheckpoint = findCheckpoint (&req_lib_ckpt_sectioniteratorinitialize->checkpointName);
  1423. if (ckptCheckpoint == 0) {
  1424. error = SA_ERR_NOT_EXIST;
  1425. goto error_exit;
  1426. }
  1427. /*
  1428. * Iterate list of checkpoint sections
  1429. */
  1430. for (checkpointSectionList = ckptCheckpoint->checkpointSectionsListHead.next;
  1431. checkpointSectionList != &ckptCheckpoint->checkpointSectionsListHead;
  1432. checkpointSectionList = checkpointSectionList->next) {
  1433. ckptCheckpointSection = list_entry (checkpointSectionList,
  1434. struct saCkptCheckpointSection, list);
  1435. addEntry = 1;
  1436. /*
  1437. * Item should be added to iterator list
  1438. */
  1439. if (addEntry) {
  1440. iteratorEntries += 1;
  1441. ckptSectionIteratorEntries =
  1442. realloc (ckptSectionIterator->sectionIteratorEntries,
  1443. sizeof (struct saCkptSectionIteratorEntry) * iteratorEntries);
  1444. if (ckptSectionIteratorEntries == 0) {
  1445. if (ckptSectionIterator->sectionIteratorEntries) {
  1446. free (ckptSectionIterator->sectionIteratorEntries);
  1447. }
  1448. error = SA_ERR_NO_MEMORY;
  1449. goto error_exit;
  1450. }
  1451. ckptSectionIteratorEntries[iteratorEntries - 1].active = 1;
  1452. ckptSectionIteratorEntries[iteratorEntries - 1].checkpointSection = ckptCheckpointSection;
  1453. ckptSectionIterator->sectionIteratorEntries = ckptSectionIteratorEntries;
  1454. }
  1455. }
  1456. ckptSectionIterator->iteratorCount = iteratorEntries;
  1457. error_exit:
  1458. res_lib_ckpt_sectioniteratorinitialize.header.size = sizeof (struct res_lib_ckpt_sectioniteratorinitialize);
  1459. res_lib_ckpt_sectioniteratorinitialize.header.id = MESSAGE_RES_CKPT_SECTIONITERATOR_SECTIONITERATORINITIALIZE;
  1460. res_lib_ckpt_sectioniteratorinitialize.header.error = error;
  1461. libais_send_response (conn_info, &res_lib_ckpt_sectioniteratorinitialize,
  1462. sizeof (struct res_lib_ckpt_sectioniteratorinitialize));
  1463. return (0);
  1464. }
  1465. static int message_handler_req_lib_ckpt_sectioniteratornext (struct conn_info *conn_info, void *message)
  1466. {
  1467. struct req_lib_ckpt_sectioniteratornext *req_lib_ckpt_sectioniteratornext = (struct req_lib_ckpt_sectioniteratornext *)message;
  1468. struct res_lib_ckpt_sectioniteratornext res_lib_ckpt_sectioniteratornext;
  1469. struct saCkptSectionIterator *ckptSectionIterator;
  1470. SaErrorT error = SA_OK;
  1471. int sectionIdSize = 0;
  1472. int iteratorPos = 0;
  1473. req_lib_ckpt_sectioniteratornext = 0; /* this variable not used */
  1474. log_printf (LOG_LEVEL_DEBUG, "section iterator next\n");
  1475. ckptSectionIterator = &conn_info->ais_ci.u.libckpt_ci.sectionIterator;
  1476. /*
  1477. * Find active iterator entry
  1478. */
  1479. for (;;) {
  1480. /*
  1481. * No more sections in iterator
  1482. */
  1483. if (ckptSectionIterator->iteratorPos + 1 >= ckptSectionIterator->iteratorCount) {
  1484. error = SA_ERR_NOT_EXIST;
  1485. goto error_exit;
  1486. }
  1487. /*
  1488. * active iterator entry
  1489. */
  1490. if (ckptSectionIterator->sectionIteratorEntries[ckptSectionIterator->iteratorPos].active == 1) {
  1491. break;
  1492. }
  1493. ckptSectionIterator->iteratorPos += 1;
  1494. }
  1495. /*
  1496. * Prepare response to API
  1497. */
  1498. iteratorPos = ckptSectionIterator->iteratorPos;
  1499. sectionIdSize = ckptSectionIterator->sectionIteratorEntries[iteratorPos].checkpointSection->sectionDescriptor.sectionId.idLen;
  1500. memcpy (&res_lib_ckpt_sectioniteratornext.sectionDescriptor,
  1501. &ckptSectionIterator->sectionIteratorEntries[iteratorPos].checkpointSection->sectionDescriptor,
  1502. sizeof (SaCkptSectionDescriptorT));
  1503. /*
  1504. * Get to next iterator entry
  1505. */
  1506. ckptSectionIterator->iteratorPos += 1;
  1507. error_exit:
  1508. res_lib_ckpt_sectioniteratornext.header.size = sizeof (struct res_lib_ckpt_sectioniteratornext) + sectionIdSize;
  1509. res_lib_ckpt_sectioniteratornext.header.id = MESSAGE_RES_CKPT_SECTIONITERATOR_SECTIONITERATORNEXT;
  1510. res_lib_ckpt_sectioniteratornext.header.error = error;
  1511. libais_send_response (conn_info, &res_lib_ckpt_sectioniteratornext,
  1512. sizeof (struct res_lib_ckpt_sectioniteratornext));
  1513. libais_send_response (conn_info,
  1514. ckptSectionIterator->sectionIteratorEntries[iteratorPos].checkpointSection->sectionDescriptor.sectionId.id,
  1515. sectionIdSize);
  1516. return (0);
  1517. }