2 * Copyright (c) 2002-2004 MontaVista Software, Inc.
3 * Copyright (c) 2006 Red Hat, Inc.
7 * Author: Steven Dake (sdake@mvista.com)
9 * This software licensed under BSD license, the text of which follows:
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions are met:
14 * - Redistributions of source code must retain the above copyright notice,
15 * this list of conditions and the following disclaimer.
16 * - Redistributions in binary form must reproduce the above copyright notice,
17 * this list of conditions and the following disclaimer in the documentation
18 * and/or other materials provided with the distribution.
19 * - Neither the name of the MontaVista Software, Inc. nor the names of its
20 * contributors may be used to endorse or promote products derived from this
21 * software without specific prior written permission.
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
27 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
33 * THE POSSIBILITY OF SUCH DAMAGE.
43 #include <sys/types.h>
45 #include <sys/socket.h>
46 #include <sys/select.h>
59 struct message_overlay
{
60 mar_res_header_t header
__attribute__((aligned(8)));
65 * Data structure for instance data
70 SaCkptCallbacksT callbacks
;
72 SaCkptHandleT ckptHandle
;
73 pthread_mutex_t response_mutex
;
74 pthread_mutex_t dispatch_mutex
;
75 struct list_head checkpoint_list
;
78 struct ckptCheckpointInstance
{
80 SaCkptHandleT ckptHandle
;
81 SaCkptCheckpointHandleT checkpointHandle
;
82 SaCkptCheckpointOpenFlagsT checkpointOpenFlags
;
83 SaNameT checkpointName
;
84 unsigned int checkpointId
;
85 pthread_mutex_t response_mutex
;
86 struct list_head list
;
87 struct list_head section_iteration_list_head
;
90 struct ckptSectionIterationInstance
{
92 SaCkptSectionIterationHandleT sectionIterationHandle
;
93 SaNameT checkpointName
;
94 SaSizeT maxSectionIdSize
;
95 struct list_head sectionIdListHead
;
96 pthread_mutex_t response_mutex
;
97 unsigned int executive_iteration_handle
;
98 struct list_head list
;
101 void ckptHandleInstanceDestructor (void *instance
);
102 void checkpointHandleInstanceDestructor (void *instance
);
103 void ckptSectionIterationHandleInstanceDestructor (void *instance
);
106 * All CKPT instances in this database
108 static struct saHandleDatabase ckptHandleDatabase
= {
111 .mutex
= PTHREAD_MUTEX_INITIALIZER
,
112 .handleInstanceDestructor
= ckptHandleInstanceDestructor
116 * All Checkpoint instances in this database
118 static struct saHandleDatabase checkpointHandleDatabase
= {
121 .mutex
= PTHREAD_MUTEX_INITIALIZER
,
122 .handleInstanceDestructor
= checkpointHandleInstanceDestructor
126 * All section iterators in this database
128 static struct saHandleDatabase ckptSectionIterationHandleDatabase
= {
131 .mutex
= PTHREAD_MUTEX_INITIALIZER
,
132 .handleInstanceDestructor
= ckptSectionIterationHandleInstanceDestructor
138 static SaVersionT ckptVersionsSupported
[] = {
142 static struct saVersionDatabase ckptVersionDatabase
= {
143 sizeof (ckptVersionsSupported
) / sizeof (SaVersionT
),
144 ckptVersionsSupported
147 struct iteratorSectionIdListEntry
{
148 struct list_head list
;
149 unsigned char data
[0];
156 void ckptHandleInstanceDestructor (void *instance
)
158 struct ckptInstance
*ckptInstance
= instance
;
160 pthread_mutex_destroy (&ckptInstance
->response_mutex
);
161 pthread_mutex_destroy (&ckptInstance
->dispatch_mutex
);
164 void checkpointHandleInstanceDestructor (void *instance
)
166 struct ckptCheckpointInstance
*checkpointInstance
= instance
;
168 pthread_mutex_destroy (&checkpointInstance
->response_mutex
);
171 void ckptSectionIterationHandleInstanceDestructor (void *instance
)
173 struct ckptSectionIterationInstance
*iterationInstance
= instance
;
175 pthread_mutex_destroy (&iterationInstance
->response_mutex
);
178 static void ckptSectionIterationInstanceFinalize (struct ckptSectionIterationInstance
*ckptSectionIterationInstance
)
180 struct iteratorSectionIdListEntry
*iteratorSectionIdListEntry
;
181 struct list_head
*sectionIdIterationList
;
182 struct list_head
*sectionIdIterationListNext
;
184 * iterate list of section ids for this iterator to free the allocated memory
185 * be careful to cache next pointer because free removes memory from use
187 for (sectionIdIterationList
= ckptSectionIterationInstance
->sectionIdListHead
.next
,
188 sectionIdIterationListNext
= sectionIdIterationList
->next
;
189 sectionIdIterationList
!= &ckptSectionIterationInstance
->sectionIdListHead
;
190 sectionIdIterationList
= sectionIdIterationListNext
,
191 sectionIdIterationListNext
= sectionIdIterationList
->next
) {
193 iteratorSectionIdListEntry
= list_entry (sectionIdIterationList
,
194 struct iteratorSectionIdListEntry
, list
);
196 free (iteratorSectionIdListEntry
);
199 list_del (&ckptSectionIterationInstance
->list
);
201 saHandleDestroy (&ckptSectionIterationHandleDatabase
,
202 ckptSectionIterationInstance
->sectionIterationHandle
);
205 static void ckptCheckpointInstanceFinalize (struct ckptCheckpointInstance
*ckptCheckpointInstance
)
207 struct ckptSectionIterationInstance
*sectionIterationInstance
;
208 struct list_head
*sectionIterationList
;
209 struct list_head
*sectionIterationListNext
;
211 for (sectionIterationList
= ckptCheckpointInstance
->section_iteration_list_head
.next
,
212 sectionIterationListNext
= sectionIterationList
->next
;
213 sectionIterationList
!= &ckptCheckpointInstance
->section_iteration_list_head
;
214 sectionIterationList
= sectionIterationListNext
,
215 sectionIterationListNext
= sectionIterationList
->next
) {
217 sectionIterationInstance
= list_entry (sectionIterationList
,
218 struct ckptSectionIterationInstance
, list
);
220 ckptSectionIterationInstanceFinalize (sectionIterationInstance
);
223 list_del (&ckptCheckpointInstance
->list
);
225 saHandleDestroy (&checkpointHandleDatabase
, ckptCheckpointInstance
->checkpointHandle
);
228 static void ckptInstanceFinalize (struct ckptInstance
*ckptInstance
)
230 struct ckptCheckpointInstance
*ckptCheckpointInstance
;
231 struct list_head
*checkpointInstanceList
;
232 struct list_head
*checkpointInstanceListNext
;
234 for (checkpointInstanceList
= ckptInstance
->checkpoint_list
.next
,
235 checkpointInstanceListNext
= checkpointInstanceList
->next
;
236 checkpointInstanceList
!= &ckptInstance
->checkpoint_list
;
237 checkpointInstanceList
= checkpointInstanceListNext
,
238 checkpointInstanceListNext
= checkpointInstanceList
->next
) {
240 ckptCheckpointInstance
= list_entry (checkpointInstanceList
,
241 struct ckptCheckpointInstance
, list
);
243 ckptCheckpointInstanceFinalize (ckptCheckpointInstance
);
246 saHandleDestroy (&ckptHandleDatabase
, ckptInstance
->ckptHandle
);
250 * @defgroup saCkpt SAF AIS Checkpoint API
258 SaCkptHandleT
*ckptHandle
,
259 const SaCkptCallbacksT
*callbacks
,
262 struct ckptInstance
*ckptInstance
;
263 SaAisErrorT error
= SA_AIS_OK
;
265 if (ckptHandle
== NULL
) {
266 return (SA_AIS_ERR_INVALID_PARAM
);
269 error
= saVersionVerify (&ckptVersionDatabase
, version
);
270 if (error
!= SA_AIS_OK
) {
271 goto error_no_destroy
;
274 error
= saHandleCreate (&ckptHandleDatabase
, sizeof (struct ckptInstance
),
276 if (error
!= SA_AIS_OK
) {
277 goto error_no_destroy
;
280 error
= saHandleInstanceGet (&ckptHandleDatabase
, *ckptHandle
,
281 (void *)&ckptInstance
);
282 if (error
!= SA_AIS_OK
) {
286 ckptInstance
->response_fd
= -1;
288 error
= saServiceConnect (&ckptInstance
->response_fd
,
289 &ckptInstance
->dispatch_fd
, CKPT_SERVICE
);
290 if (error
!= SA_AIS_OK
) {
291 goto error_put_destroy
;
295 memcpy (&ckptInstance
->callbacks
, callbacks
, sizeof (SaCkptCallbacksT
));
297 memset (&ckptInstance
->callbacks
, 0, sizeof (SaCkptCallbacksT
));
300 list_init (&ckptInstance
->checkpoint_list
);
302 ckptInstance
->ckptHandle
= *ckptHandle
;
304 pthread_mutex_init (&ckptInstance
->response_mutex
, NULL
);
306 saHandleInstancePut (&ckptHandleDatabase
, *ckptHandle
);
311 saHandleInstancePut (&ckptHandleDatabase
, *ckptHandle
);
313 saHandleDestroy (&ckptHandleDatabase
, *ckptHandle
);
319 saCkptSelectionObjectGet (
320 const SaCkptHandleT ckptHandle
,
321 SaSelectionObjectT
*selectionObject
)
323 struct ckptInstance
*ckptInstance
;
326 if (selectionObject
== NULL
) {
327 return (SA_AIS_ERR_INVALID_PARAM
);
329 error
= saHandleInstanceGet (&ckptHandleDatabase
, ckptHandle
, (void *)&ckptInstance
);
330 if (error
!= SA_AIS_OK
) {
334 *selectionObject
= ckptInstance
->dispatch_fd
;
336 saHandleInstancePut (&ckptHandleDatabase
, ckptHandle
);
343 const SaCkptHandleT ckptHandle
,
344 SaDispatchFlagsT dispatchFlags
)
349 SaCkptCallbacksT callbacks
;
352 struct ckptInstance
*ckptInstance
;
353 int cont
= 1; /* always continue do loop except when set to 0 */
354 struct message_overlay dispatch_data
;
355 struct res_lib_ckpt_checkpointopenasync
*res_lib_ckpt_checkpointopenasync
;
356 struct res_lib_ckpt_checkpointsynchronizeasync
*res_lib_ckpt_checkpointsynchronizeasync
;
357 struct ckptCheckpointInstance
*ckptCheckpointInstance
;
359 if (dispatchFlags
!= SA_DISPATCH_ONE
&&
360 dispatchFlags
!= SA_DISPATCH_ALL
&&
361 dispatchFlags
!= SA_DISPATCH_BLOCKING
) {
363 return (SA_AIS_ERR_INVALID_PARAM
);
366 error
= saHandleInstanceGet (&ckptHandleDatabase
, ckptHandle
,
367 (void *)&ckptInstance
);
368 if (error
!= SA_AIS_OK
) {
373 * Timeout instantly for SA_DISPATCH_ALL
375 if (dispatchFlags
== SA_DISPATCH_ALL
) {
381 * Read data directly from socket
383 poll_fd
= ckptInstance
->dispatch_fd
;
385 ufds
.events
= POLLIN
;
388 error
= saPollRetry(&ufds
, 1, timeout
);
389 if (error
!= SA_AIS_OK
) {
392 pthread_mutex_lock(&ckptInstance
->dispatch_mutex
);
394 if (ckptInstance
->finalize
== 1) {
399 if ((ufds
.revents
& (POLLERR
|POLLHUP
|POLLNVAL
)) != 0) {
400 error
= SA_AIS_ERR_BAD_HANDLE
;
404 dispatch_avail
= (ufds
.revents
& POLLIN
);
406 if (dispatch_avail
== 0 && dispatchFlags
== SA_DISPATCH_ALL
) {
407 pthread_mutex_unlock(&ckptInstance
->dispatch_mutex
);
408 break; /* exit do while cont is 1 loop */
410 if (dispatch_avail
== 0) {
411 pthread_mutex_unlock(&ckptInstance
->dispatch_mutex
);
415 memset(&dispatch_data
,0, sizeof(struct message_overlay
));
416 error
= saRecvRetry (ckptInstance
->dispatch_fd
, &dispatch_data
.header
, sizeof (mar_res_header_t
));
417 if (error
!= SA_AIS_OK
) {
420 if (dispatch_data
.header
.size
> sizeof (mar_res_header_t
)) {
421 error
= saRecvRetry (ckptInstance
->dispatch_fd
, &dispatch_data
.data
,
422 dispatch_data
.header
.size
- sizeof (mar_res_header_t
));
423 if (error
!= SA_AIS_OK
) {
429 * Make copy of callbacks, message data, unlock instance,
430 * and call callback. A risk of this dispatch method is that
431 * the callback routines may operate at the same time that
432 * CkptFinalize has been called in another thread.
434 memcpy(&callbacks
,&ckptInstance
->callbacks
, sizeof(ckptInstance
->callbacks
));
435 pthread_mutex_unlock(&ckptInstance
->dispatch_mutex
);
437 * Dispatch incoming response
439 switch (dispatch_data
.header
.id
) {
440 case MESSAGE_RES_CKPT_CHECKPOINT_CHECKPOINTOPENASYNC
:
441 if (callbacks
.saCkptCheckpointOpenCallback
== NULL
) {
444 res_lib_ckpt_checkpointopenasync
= (struct res_lib_ckpt_checkpointopenasync
*) &dispatch_data
;
447 * This instance get/listadd/put required so that close
448 * later has the proper list of checkpoints
450 if (res_lib_ckpt_checkpointopenasync
->header
.error
== SA_AIS_OK
) {
451 error
= saHandleInstanceGet (&checkpointHandleDatabase
,
452 res_lib_ckpt_checkpointopenasync
->checkpoint_handle
,
453 (void *)&ckptCheckpointInstance
);
455 assert (error
== SA_AIS_OK
); /* should only be valid handles here */
456 ckptCheckpointInstance
->checkpointId
=
457 res_lib_ckpt_checkpointopenasync
->ckpt_id
;
460 * open succeeded without error
462 list_init (&ckptCheckpointInstance
->list
);
463 list_init (&ckptCheckpointInstance
->section_iteration_list_head
);
464 list_add (&ckptCheckpointInstance
->list
,
465 &ckptInstance
->checkpoint_list
);
467 callbacks
.saCkptCheckpointOpenCallback(
468 res_lib_ckpt_checkpointopenasync
->invocation
,
469 res_lib_ckpt_checkpointopenasync
->checkpoint_handle
,
470 res_lib_ckpt_checkpointopenasync
->header
.error
);
471 saHandleInstancePut (&checkpointHandleDatabase
,
472 res_lib_ckpt_checkpointopenasync
->checkpoint_handle
);
475 * open failed with error
477 callbacks
.saCkptCheckpointOpenCallback(
478 res_lib_ckpt_checkpointopenasync
->invocation
,
480 res_lib_ckpt_checkpointopenasync
->header
.error
);
484 case MESSAGE_RES_CKPT_CHECKPOINT_CHECKPOINTSYNCHRONIZEASYNC
:
485 if (callbacks
.saCkptCheckpointSynchronizeCallback
== NULL
) {
489 res_lib_ckpt_checkpointsynchronizeasync
= (struct res_lib_ckpt_checkpointsynchronizeasync
*) &dispatch_data
;
491 callbacks
.saCkptCheckpointSynchronizeCallback(
492 res_lib_ckpt_checkpointsynchronizeasync
->invocation
,
493 res_lib_ckpt_checkpointsynchronizeasync
->header
.error
);
499 * Determine if more messages should be processed
501 switch (dispatchFlags
) {
502 case SA_DISPATCH_ONE
:
505 case SA_DISPATCH_ALL
:
507 case SA_DISPATCH_BLOCKING
:
512 pthread_mutex_unlock(&ckptInstance
->dispatch_mutex
);
514 saHandleInstancePut(&ckptHandleDatabase
, ckptHandle
);
521 const SaCkptHandleT ckptHandle
)
523 struct ckptInstance
*ckptInstance
;
526 error
= saHandleInstanceGet (&ckptHandleDatabase
, ckptHandle
,
527 (void *)&ckptInstance
);
528 if (error
!= SA_AIS_OK
) {
532 pthread_mutex_lock (&ckptInstance
->response_mutex
);
535 * Another thread has already started finalizing
537 if (ckptInstance
->finalize
) {
538 pthread_mutex_unlock (&ckptInstance
->response_mutex
);
539 saHandleInstancePut (&ckptHandleDatabase
, ckptHandle
);
540 return (SA_AIS_ERR_BAD_HANDLE
);
543 ckptInstance
->finalize
= 1;
545 pthread_mutex_unlock (&ckptInstance
->response_mutex
);
547 ckptInstanceFinalize (ckptInstance
);
549 if (ckptInstance
->response_fd
!= -1) {
550 shutdown (ckptInstance
->response_fd
, 0);
551 close (ckptInstance
->response_fd
);
554 if (ckptInstance
->dispatch_fd
!= -1) {
555 shutdown (ckptInstance
->dispatch_fd
, 0);
556 close (ckptInstance
->dispatch_fd
);
559 saHandleInstancePut (&ckptHandleDatabase
, ckptHandle
);
565 saCkptCheckpointOpen (
566 SaCkptHandleT ckptHandle
,
567 const SaNameT
*checkpointName
,
568 const SaCkptCheckpointCreationAttributesT
*checkpointCreationAttributes
,
569 SaCkptCheckpointOpenFlagsT checkpointOpenFlags
,
571 SaCkptCheckpointHandleT
*checkpointHandle
)
574 struct ckptCheckpointInstance
*ckptCheckpointInstance
;
575 struct ckptInstance
*ckptInstance
;
576 struct req_lib_ckpt_checkpointopen req_lib_ckpt_checkpointopen
;
577 struct res_lib_ckpt_checkpointopen res_lib_ckpt_checkpointopen
;
579 if (checkpointHandle
== NULL
) {
580 return (SA_AIS_ERR_INVALID_PARAM
);
583 if (checkpointName
== NULL
) {
584 return (SA_AIS_ERR_INVALID_PARAM
);
587 if (checkpointOpenFlags
& ~(SA_CKPT_CHECKPOINT_READ
|SA_CKPT_CHECKPOINT_WRITE
|SA_CKPT_CHECKPOINT_CREATE
)) {
588 return (SA_AIS_ERR_BAD_FLAGS
);
591 if ((checkpointOpenFlags
& SA_CKPT_CHECKPOINT_CREATE
) &&
592 checkpointCreationAttributes
== NULL
) {
594 return (SA_AIS_ERR_INVALID_PARAM
);
597 if (((checkpointOpenFlags
& SA_CKPT_CHECKPOINT_CREATE
) == 0) &&
598 checkpointCreationAttributes
!= NULL
) {
600 return (SA_AIS_ERR_INVALID_PARAM
);
603 if (checkpointCreationAttributes
&&
604 (checkpointCreationAttributes
->checkpointSize
>
605 (checkpointCreationAttributes
->maxSections
* checkpointCreationAttributes
->maxSectionSize
))) {
607 return (SA_AIS_ERR_INVALID_PARAM
);
610 error
= saHandleInstanceGet (&ckptHandleDatabase
, ckptHandle
,
611 (void *)&ckptInstance
);
612 if (error
!= SA_AIS_OK
) {
616 error
= saHandleCreate (&checkpointHandleDatabase
,
617 sizeof (struct ckptCheckpointInstance
), checkpointHandle
);
618 if (error
!= SA_AIS_OK
) {
622 error
= saHandleInstanceGet (&checkpointHandleDatabase
,
623 *checkpointHandle
, (void *)&ckptCheckpointInstance
);
624 if (error
!= SA_AIS_OK
) {
628 ckptCheckpointInstance
->response_fd
= ckptInstance
->response_fd
;
630 ckptCheckpointInstance
->ckptHandle
= ckptHandle
;
631 ckptCheckpointInstance
->checkpointHandle
= *checkpointHandle
;
632 ckptCheckpointInstance
->checkpointOpenFlags
= checkpointOpenFlags
;
633 list_init (&ckptCheckpointInstance
->section_iteration_list_head
);
635 req_lib_ckpt_checkpointopen
.header
.size
= sizeof (struct req_lib_ckpt_checkpointopen
);
636 req_lib_ckpt_checkpointopen
.header
.id
= MESSAGE_REQ_CKPT_CHECKPOINT_CHECKPOINTOPEN
;
637 marshall_to_mar_name_t (&req_lib_ckpt_checkpointopen
.checkpoint_name
,
638 (SaNameT
*)checkpointName
);
639 memcpy (&ckptCheckpointInstance
->checkpointName
, checkpointName
, sizeof (SaNameT
));
640 req_lib_ckpt_checkpointopen
.async_call
= 0;
641 req_lib_ckpt_checkpointopen
.invocation
= 0;
642 req_lib_ckpt_checkpointopen
.fail_with_error
= SA_AIS_OK
;
643 req_lib_ckpt_checkpointopen
.checkpoint_creation_attributes_set
= 0;
644 if (checkpointCreationAttributes
) {
645 marshall_to_mar_ckpt_checkpoint_creation_attributes_t (
646 &req_lib_ckpt_checkpointopen
.checkpoint_creation_attributes
,
647 (SaCkptCheckpointCreationAttributesT
*)checkpointCreationAttributes
);
648 req_lib_ckpt_checkpointopen
.checkpoint_creation_attributes_set
= 1;
650 req_lib_ckpt_checkpointopen
.checkpoint_open_flags
= checkpointOpenFlags
;
652 error
= saSendRetry (ckptCheckpointInstance
->response_fd
, &req_lib_ckpt_checkpointopen
,
653 sizeof (struct req_lib_ckpt_checkpointopen
));
654 if (error
!= SA_AIS_OK
) {
655 goto error_put_destroy
;
658 error
= saRecvRetry (ckptCheckpointInstance
->response_fd
, &res_lib_ckpt_checkpointopen
,
659 sizeof (struct res_lib_ckpt_checkpointopen
));
660 if (error
!= SA_AIS_OK
) {
661 goto error_put_destroy
;
664 if (res_lib_ckpt_checkpointopen
.header
.error
!= SA_AIS_OK
) {
665 error
= res_lib_ckpt_checkpointopen
.header
.error
;
666 goto error_put_destroy
;
668 ckptCheckpointInstance
->checkpointId
=
669 res_lib_ckpt_checkpointopen
.ckpt_id
;
671 pthread_mutex_init (&ckptCheckpointInstance
->response_mutex
, NULL
);
673 saHandleInstancePut (&checkpointHandleDatabase
, *checkpointHandle
);
675 saHandleInstancePut (&ckptHandleDatabase
, ckptHandle
);
677 list_init (&ckptCheckpointInstance
->list
);
679 list_add (&ckptCheckpointInstance
->list
, &ckptInstance
->checkpoint_list
);
683 saHandleInstancePut (&checkpointHandleDatabase
, *checkpointHandle
);
685 saHandleDestroy (&checkpointHandleDatabase
, *checkpointHandle
);
687 saHandleInstancePut (&ckptHandleDatabase
, ckptHandle
);
693 saCkptCheckpointOpenAsync (
694 const SaCkptHandleT ckptHandle
,
695 SaInvocationT invocation
,
696 const SaNameT
*checkpointName
,
697 const SaCkptCheckpointCreationAttributesT
*checkpointCreationAttributes
,
698 SaCkptCheckpointOpenFlagsT checkpointOpenFlags
)
700 struct ckptCheckpointInstance
*ckptCheckpointInstance
;
701 struct ckptInstance
*ckptInstance
;
702 SaCkptCheckpointHandleT checkpointHandle
;
704 struct req_lib_ckpt_checkpointopen req_lib_ckpt_checkpointopen
;
705 struct res_lib_ckpt_checkpointopenasync res_lib_ckpt_checkpointopenasync
;
706 SaAisErrorT failWithError
= SA_AIS_OK
;
708 if (checkpointName
== NULL
) {
709 failWithError
= SA_AIS_ERR_INVALID_PARAM
;
711 if (checkpointOpenFlags
&
712 ~(SA_CKPT_CHECKPOINT_READ
|SA_CKPT_CHECKPOINT_WRITE
|SA_CKPT_CHECKPOINT_CREATE
)) {
713 failWithError
= SA_AIS_ERR_BAD_FLAGS
;
715 if ((checkpointOpenFlags
& SA_CKPT_CHECKPOINT_CREATE
) &&
716 checkpointCreationAttributes
== NULL
) {
718 failWithError
= SA_AIS_ERR_INVALID_PARAM
;
720 if (((checkpointOpenFlags
& SA_CKPT_CHECKPOINT_CREATE
) == 0) &&
721 checkpointCreationAttributes
!= NULL
) {
723 failWithError
= SA_AIS_ERR_INVALID_PARAM
;
725 if (checkpointCreationAttributes
&&
726 (checkpointCreationAttributes
->checkpointSize
>
727 (checkpointCreationAttributes
->maxSections
* checkpointCreationAttributes
->maxSectionSize
))) {
729 failWithError
= SA_AIS_ERR_INVALID_PARAM
;
732 error
= saHandleInstanceGet (&ckptHandleDatabase
, ckptHandle
,
733 (void *)&ckptInstance
);
734 if (error
!= SA_AIS_OK
) {
738 if (ckptInstance
->callbacks
.saCkptCheckpointOpenCallback
== NULL
) {
739 error
= SA_AIS_ERR_INIT
;
743 error
= saHandleCreate (&checkpointHandleDatabase
,
744 sizeof (struct ckptCheckpointInstance
), &checkpointHandle
);
745 if (error
!= SA_AIS_OK
) {
749 error
= saHandleInstanceGet (&checkpointHandleDatabase
, checkpointHandle
,
750 (void *)&ckptCheckpointInstance
);
751 if (error
!= SA_AIS_OK
) {
755 ckptCheckpointInstance
->response_fd
= ckptInstance
->response_fd
;
756 ckptCheckpointInstance
->ckptHandle
= ckptHandle
;
757 ckptCheckpointInstance
->checkpointHandle
= checkpointHandle
;
758 ckptCheckpointInstance
->checkpointOpenFlags
= checkpointOpenFlags
;
759 if (failWithError
== SA_AIS_OK
) {
760 memcpy (&ckptCheckpointInstance
->checkpointName
, checkpointName
,
762 marshall_to_mar_name_t (&req_lib_ckpt_checkpointopen
.checkpoint_name
,
763 (SaNameT
*)checkpointName
);
766 req_lib_ckpt_checkpointopen
.header
.size
= sizeof (struct req_lib_ckpt_checkpointopen
);
767 req_lib_ckpt_checkpointopen
.header
.id
= MESSAGE_REQ_CKPT_CHECKPOINT_CHECKPOINTOPEN
;
768 req_lib_ckpt_checkpointopen
.async_call
= 1;
769 req_lib_ckpt_checkpointopen
.invocation
= invocation
;
770 req_lib_ckpt_checkpointopen
.fail_with_error
= failWithError
;
771 req_lib_ckpt_checkpointopen
.checkpoint_creation_attributes_set
= 0;
772 if (checkpointCreationAttributes
) {
773 marshall_to_mar_ckpt_checkpoint_creation_attributes_t (
774 &req_lib_ckpt_checkpointopen
.checkpoint_creation_attributes
,
775 (SaCkptCheckpointCreationAttributesT
*)checkpointCreationAttributes
);
776 req_lib_ckpt_checkpointopen
.checkpoint_creation_attributes_set
= 1;
779 req_lib_ckpt_checkpointopen
.checkpoint_open_flags
= checkpointOpenFlags
;
780 req_lib_ckpt_checkpointopen
.checkpoint_handle
= checkpointHandle
;
782 error
= saSendReceiveReply (ckptInstance
->response_fd
,
783 &req_lib_ckpt_checkpointopen
,
784 sizeof (struct req_lib_ckpt_checkpointopen
),
785 &res_lib_ckpt_checkpointopenasync
,
786 sizeof (struct res_lib_ckpt_checkpointopenasync
));
788 if (error
!= SA_AIS_OK
) {
789 goto error_put_destroy
;
792 if (res_lib_ckpt_checkpointopenasync
.header
.error
!= SA_AIS_OK
) {
793 error
= res_lib_ckpt_checkpointopenasync
.header
.error
;
794 goto error_put_destroy
;
797 pthread_mutex_init (&ckptCheckpointInstance
->response_mutex
, NULL
);
799 saHandleInstancePut (&checkpointHandleDatabase
, checkpointHandle
);
801 saHandleInstancePut (&ckptHandleDatabase
, ckptHandle
);
803 return (error
== SA_AIS_OK
? res_lib_ckpt_checkpointopenasync
.header
.error
: error
);
806 saHandleInstancePut (&checkpointHandleDatabase
, checkpointHandle
);
808 saHandleDestroy (&checkpointHandleDatabase
, checkpointHandle
);
810 saHandleInstancePut (&ckptHandleDatabase
, ckptHandle
);
816 saCkptCheckpointClose (
817 SaCkptCheckpointHandleT checkpointHandle
)
819 struct req_lib_ckpt_checkpointclose req_lib_ckpt_checkpointclose
;
820 struct res_lib_ckpt_checkpointclose res_lib_ckpt_checkpointclose
;
822 struct ckptCheckpointInstance
*ckptCheckpointInstance
;
824 error
= saHandleInstanceGet (&checkpointHandleDatabase
, checkpointHandle
,
825 (void *)&ckptCheckpointInstance
);
826 if (error
!= SA_AIS_OK
) {
830 req_lib_ckpt_checkpointclose
.header
.size
= sizeof (struct req_lib_ckpt_checkpointclose
);
831 req_lib_ckpt_checkpointclose
.header
.id
= MESSAGE_REQ_CKPT_CHECKPOINT_CHECKPOINTCLOSE
;
832 marshall_to_mar_name_t (&req_lib_ckpt_checkpointclose
.checkpoint_name
,
833 &ckptCheckpointInstance
->checkpointName
);
834 req_lib_ckpt_checkpointclose
.ckpt_id
=
835 ckptCheckpointInstance
->checkpointId
;
837 pthread_mutex_lock (&ckptCheckpointInstance
->response_mutex
);
839 error
= saSendReceiveReply (ckptCheckpointInstance
->response_fd
,
840 &req_lib_ckpt_checkpointclose
,
841 sizeof (struct req_lib_ckpt_checkpointclose
),
842 &res_lib_ckpt_checkpointclose
,
843 sizeof (struct res_lib_ckpt_checkpointclose
));
845 pthread_mutex_unlock (&ckptCheckpointInstance
->response_mutex
);
847 if (error
== SA_AIS_OK
) {
848 error
= res_lib_ckpt_checkpointclose
.header
.error
;
851 if (error
== SA_AIS_OK
) {
852 ckptCheckpointInstanceFinalize (ckptCheckpointInstance
);
855 saHandleInstancePut (&checkpointHandleDatabase
, checkpointHandle
);
861 saCkptCheckpointUnlink (
862 SaCkptHandleT ckptHandle
,
863 const SaNameT
*checkpointName
)
866 struct ckptInstance
*ckptInstance
;
867 struct req_lib_ckpt_checkpointunlink req_lib_ckpt_checkpointunlink
;
868 struct res_lib_ckpt_checkpointunlink res_lib_ckpt_checkpointunlink
;
870 if (checkpointName
== NULL
) {
871 return (SA_AIS_ERR_INVALID_PARAM
);
873 error
= saHandleInstanceGet (&ckptHandleDatabase
, ckptHandle
, (void *)&ckptInstance
);
874 if (error
!= SA_AIS_OK
) {
878 req_lib_ckpt_checkpointunlink
.header
.size
= sizeof (struct req_lib_ckpt_checkpointunlink
);
879 req_lib_ckpt_checkpointunlink
.header
.id
= MESSAGE_REQ_CKPT_CHECKPOINT_CHECKPOINTUNLINK
;
880 marshall_to_mar_name_t (&req_lib_ckpt_checkpointunlink
.checkpoint_name
,
881 (SaNameT
*)checkpointName
);
883 pthread_mutex_lock (&ckptInstance
->response_mutex
);
885 error
= saSendReceiveReply (ckptInstance
->response_fd
,
886 &req_lib_ckpt_checkpointunlink
,
887 sizeof (struct req_lib_ckpt_checkpointunlink
),
888 &res_lib_ckpt_checkpointunlink
,
889 sizeof (struct res_lib_ckpt_checkpointunlink
));
891 pthread_mutex_unlock (&ckptInstance
->response_mutex
);
893 saHandleInstancePut (&ckptHandleDatabase
, ckptHandle
);
895 return (error
== SA_AIS_OK
? res_lib_ckpt_checkpointunlink
.header
.error
: error
);
900 saCkptCheckpointRetentionDurationSet (
901 SaCkptCheckpointHandleT checkpointHandle
,
902 SaTimeT retentionDuration
)
905 struct ckptCheckpointInstance
*ckptCheckpointInstance
;
906 struct req_lib_ckpt_checkpointretentiondurationset req_lib_ckpt_checkpointretentiondurationset
;
907 struct res_lib_ckpt_checkpointretentiondurationset res_lib_ckpt_checkpointretentiondurationset
;
909 error
= saHandleInstanceGet (&checkpointHandleDatabase
, checkpointHandle
,
910 (void *)&ckptCheckpointInstance
);
911 if (error
!= SA_AIS_OK
) {
915 req_lib_ckpt_checkpointretentiondurationset
.header
.size
= sizeof (struct req_lib_ckpt_checkpointretentiondurationset
);
916 req_lib_ckpt_checkpointretentiondurationset
.header
.id
= MESSAGE_REQ_CKPT_CHECKPOINT_CHECKPOINTRETENTIONDURATIONSET
;
918 req_lib_ckpt_checkpointretentiondurationset
.retention_duration
= retentionDuration
;
919 marshall_to_mar_name_t (&req_lib_ckpt_checkpointretentiondurationset
.checkpoint_name
,
920 &ckptCheckpointInstance
->checkpointName
);
921 req_lib_ckpt_checkpointretentiondurationset
.ckpt_id
=
922 ckptCheckpointInstance
->checkpointId
;
924 pthread_mutex_lock (&ckptCheckpointInstance
->response_mutex
);
926 error
= saSendReceiveReply (ckptCheckpointInstance
->response_fd
,
927 &req_lib_ckpt_checkpointretentiondurationset
,
928 sizeof (struct req_lib_ckpt_checkpointretentiondurationset
),
929 &res_lib_ckpt_checkpointretentiondurationset
,
930 sizeof (struct res_lib_ckpt_checkpointretentiondurationset
));
932 pthread_mutex_unlock (&ckptCheckpointInstance
->response_mutex
);
934 saHandleInstancePut (&checkpointHandleDatabase
, checkpointHandle
);
935 return (error
== SA_AIS_OK
? res_lib_ckpt_checkpointretentiondurationset
.header
.error
: error
);
939 saCkptActiveReplicaSet (
940 SaCkptCheckpointHandleT checkpointHandle
)
943 struct ckptCheckpointInstance
*ckptCheckpointInstance
;
944 struct req_lib_ckpt_activereplicaset req_lib_ckpt_activereplicaset
;
945 struct res_lib_ckpt_activereplicaset res_lib_ckpt_activereplicaset
;
947 error
= saHandleInstanceGet (&checkpointHandleDatabase
, checkpointHandle
,
948 (void *)&ckptCheckpointInstance
);
949 if (error
!= SA_AIS_OK
) {
953 if ((ckptCheckpointInstance
->checkpointOpenFlags
& SA_CKPT_CHECKPOINT_WRITE
) == 0) {
954 error
= SA_AIS_ERR_ACCESS
;
958 req_lib_ckpt_activereplicaset
.header
.size
= sizeof (struct req_lib_ckpt_activereplicaset
);
959 req_lib_ckpt_activereplicaset
.header
.id
= MESSAGE_REQ_CKPT_ACTIVEREPLICASET
;
960 marshall_to_mar_name_t (&req_lib_ckpt_activereplicaset
.checkpoint_name
,
961 &ckptCheckpointInstance
->checkpointName
);
962 req_lib_ckpt_activereplicaset
.ckpt_id
=
963 ckptCheckpointInstance
->checkpointId
;
965 pthread_mutex_lock (&ckptCheckpointInstance
->response_mutex
);
967 error
= saSendReceiveReply (ckptCheckpointInstance
->response_fd
,
968 &req_lib_ckpt_activereplicaset
,
969 sizeof (struct req_lib_ckpt_activereplicaset
),
970 &res_lib_ckpt_activereplicaset
,
971 sizeof (struct res_lib_ckpt_activereplicaset
));
973 pthread_mutex_unlock (&ckptCheckpointInstance
->response_mutex
);
976 saHandleInstancePut (&checkpointHandleDatabase
, checkpointHandle
);
978 return (error
== SA_AIS_OK
? res_lib_ckpt_activereplicaset
.header
.error
: error
);
982 saCkptCheckpointStatusGet (
983 SaCkptCheckpointHandleT checkpointHandle
,
984 SaCkptCheckpointDescriptorT
*checkpointStatus
)
987 struct ckptCheckpointInstance
*ckptCheckpointInstance
;
988 struct req_lib_ckpt_checkpointstatusget req_lib_ckpt_checkpointstatusget
;
989 struct res_lib_ckpt_checkpointstatusget res_lib_ckpt_checkpointstatusget
;
991 if (checkpointStatus
== NULL
) {
992 return (SA_AIS_ERR_INVALID_PARAM
);
994 error
= saHandleInstanceGet (&checkpointHandleDatabase
, checkpointHandle
,
995 (void *)&ckptCheckpointInstance
);
996 if (error
!= SA_AIS_OK
) {
1000 req_lib_ckpt_checkpointstatusget
.header
.size
= sizeof (struct req_lib_ckpt_checkpointstatusget
);
1001 req_lib_ckpt_checkpointstatusget
.header
.id
= MESSAGE_REQ_CKPT_CHECKPOINT_CHECKPOINTSTATUSGET
;
1003 marshall_to_mar_name_t (&req_lib_ckpt_checkpointstatusget
.checkpoint_name
,
1004 &ckptCheckpointInstance
->checkpointName
);
1005 req_lib_ckpt_checkpointstatusget
.ckpt_id
=
1006 ckptCheckpointInstance
->checkpointId
;
1008 pthread_mutex_lock (&ckptCheckpointInstance
->response_mutex
);
1010 error
= saSendReceiveReply (ckptCheckpointInstance
->response_fd
,
1011 &req_lib_ckpt_checkpointstatusget
,
1012 sizeof (struct req_lib_ckpt_checkpointstatusget
),
1013 &res_lib_ckpt_checkpointstatusget
,
1014 sizeof (struct res_lib_ckpt_checkpointstatusget
));
1016 pthread_mutex_unlock (&ckptCheckpointInstance
->response_mutex
);
1018 marshall_from_mar_ckpt_checkpoint_descriptor_t (
1020 &res_lib_ckpt_checkpointstatusget
.checkpoint_descriptor
);
1022 saHandleInstancePut (&checkpointHandleDatabase
, checkpointHandle
);
1024 return (error
== SA_AIS_OK
? res_lib_ckpt_checkpointstatusget
.header
.error
: error
);
1028 saCkptSectionCreate (
1029 SaCkptCheckpointHandleT checkpointHandle
,
1030 SaCkptSectionCreationAttributesT
*sectionCreationAttributes
,
1031 const void *initialData
,
1032 SaUint32T initialDataSize
)
1035 struct ckptCheckpointInstance
*ckptCheckpointInstance
;
1036 struct req_lib_ckpt_sectioncreate req_lib_ckpt_sectioncreate
;
1037 struct res_lib_ckpt_sectioncreate res_lib_ckpt_sectioncreate
;
1039 if (sectionCreationAttributes
== NULL
) {
1040 return (SA_AIS_ERR_INVALID_PARAM
);
1043 if (initialData
== NULL
) {
1044 return (SA_AIS_ERR_INVALID_PARAM
);
1047 error
= saHandleInstanceGet (&checkpointHandleDatabase
, checkpointHandle
,
1048 (void *)&ckptCheckpointInstance
);
1049 if (error
!= SA_AIS_OK
) {
1053 if ((ckptCheckpointInstance
->checkpointOpenFlags
& SA_CKPT_CHECKPOINT_WRITE
) == 0) {
1054 error
= SA_AIS_ERR_ACCESS
;
1058 req_lib_ckpt_sectioncreate
.header
.size
=
1059 sizeof (struct req_lib_ckpt_sectioncreate
) +
1060 sectionCreationAttributes
->sectionId
->idLen
+
1063 req_lib_ckpt_sectioncreate
.header
.id
= MESSAGE_REQ_CKPT_CHECKPOINT_SECTIONCREATE
;
1064 req_lib_ckpt_sectioncreate
.id_len
= sectionCreationAttributes
->sectionId
->idLen
;
1065 req_lib_ckpt_sectioncreate
.expiration_time
= sectionCreationAttributes
->expirationTime
;
1066 req_lib_ckpt_sectioncreate
.initial_data_size
= initialDataSize
;
1068 marshall_to_mar_name_t (&req_lib_ckpt_sectioncreate
.checkpoint_name
,
1069 &ckptCheckpointInstance
->checkpointName
);
1070 req_lib_ckpt_sectioncreate
.ckpt_id
=
1071 ckptCheckpointInstance
->checkpointId
;
1073 pthread_mutex_lock (&ckptCheckpointInstance
->response_mutex
);
1075 error
= saSendRetry (ckptCheckpointInstance
->response_fd
, &req_lib_ckpt_sectioncreate
,
1076 sizeof (struct req_lib_ckpt_sectioncreate
));
1077 if (error
!= SA_AIS_OK
) {
1082 * Write section identifier to server
1084 error
= saSendRetry (ckptCheckpointInstance
->response_fd
, sectionCreationAttributes
->sectionId
->id
,
1085 sectionCreationAttributes
->sectionId
->idLen
);
1086 if (error
!= SA_AIS_OK
) {
1090 error
= saSendRetry (ckptCheckpointInstance
->response_fd
, initialData
,
1092 if (error
!= SA_AIS_OK
) {
1096 error
= saRecvRetry (ckptCheckpointInstance
->response_fd
,
1097 &res_lib_ckpt_sectioncreate
,
1098 sizeof (struct res_lib_ckpt_sectioncreate
));
1100 pthread_mutex_unlock (&ckptCheckpointInstance
->response_mutex
);
1103 saHandleInstancePut (&checkpointHandleDatabase
, checkpointHandle
);
1105 return (error
== SA_AIS_OK
? res_lib_ckpt_sectioncreate
.header
.error
: error
);
1110 saCkptSectionDelete (
1111 SaCkptCheckpointHandleT checkpointHandle
,
1112 const SaCkptSectionIdT
*sectionId
)
1115 struct ckptCheckpointInstance
*ckptCheckpointInstance
;
1116 struct req_lib_ckpt_sectiondelete req_lib_ckpt_sectiondelete
;
1117 struct res_lib_ckpt_sectiondelete res_lib_ckpt_sectiondelete
;
1119 if (sectionId
== NULL
) {
1120 return (SA_AIS_ERR_INVALID_PARAM
);
1123 error
= saHandleInstanceGet (&checkpointHandleDatabase
, checkpointHandle
,
1124 (void *)&ckptCheckpointInstance
);
1125 if (error
!= SA_AIS_OK
) {
1129 if ((ckptCheckpointInstance
->checkpointOpenFlags
& SA_CKPT_CHECKPOINT_WRITE
) == 0) {
1130 error
= SA_AIS_ERR_ACCESS
;
1134 pthread_mutex_lock (&ckptCheckpointInstance
->response_mutex
);
1136 req_lib_ckpt_sectiondelete
.header
.size
= sizeof (struct req_lib_ckpt_sectiondelete
) + sectionId
->idLen
;
1137 req_lib_ckpt_sectiondelete
.header
.id
= MESSAGE_REQ_CKPT_CHECKPOINT_SECTIONDELETE
;
1138 req_lib_ckpt_sectiondelete
.id_len
= sectionId
->idLen
;
1140 marshall_to_mar_name_t (
1141 &req_lib_ckpt_sectiondelete
.checkpoint_name
,
1142 &ckptCheckpointInstance
->checkpointName
);
1143 req_lib_ckpt_sectiondelete
.ckpt_id
=
1144 ckptCheckpointInstance
->checkpointId
;
1146 error
= saSendRetry (ckptCheckpointInstance
->response_fd
, &req_lib_ckpt_sectiondelete
,
1147 sizeof (struct req_lib_ckpt_sectiondelete
));
1148 if (error
!= SA_AIS_OK
) {
1153 * Write section identifier to server
1155 error
= saSendRetry (ckptCheckpointInstance
->response_fd
, sectionId
->id
,
1157 if (error
!= SA_AIS_OK
) {
1160 error
= saRecvRetry (ckptCheckpointInstance
->response_fd
,
1161 &res_lib_ckpt_sectiondelete
,
1162 sizeof (struct res_lib_ckpt_sectiondelete
));
1165 pthread_mutex_unlock (&ckptCheckpointInstance
->response_mutex
);
1168 saHandleInstancePut (&checkpointHandleDatabase
, checkpointHandle
);
1169 return (error
== SA_AIS_OK
? res_lib_ckpt_sectiondelete
.header
.error
: error
);
1173 saCkptSectionExpirationTimeSet (
1174 SaCkptCheckpointHandleT checkpointHandle
,
1175 const SaCkptSectionIdT
*sectionId
,
1176 SaTimeT expirationTime
)
1179 struct ckptCheckpointInstance
*ckptCheckpointInstance
;
1180 struct req_lib_ckpt_sectionexpirationtimeset req_lib_ckpt_sectionexpirationtimeset
;
1181 struct res_lib_ckpt_sectionexpirationtimeset res_lib_ckpt_sectionexpirationtimeset
;
1183 if (sectionId
== NULL
) {
1184 return (SA_AIS_ERR_INVALID_PARAM
);
1187 error
= saHandleInstanceGet (&checkpointHandleDatabase
, checkpointHandle
,
1188 (void *)&ckptCheckpointInstance
);
1189 if (error
!= SA_AIS_OK
) {
1193 if ((ckptCheckpointInstance
->checkpointOpenFlags
& SA_CKPT_CHECKPOINT_WRITE
) == 0) {
1194 error
= SA_AIS_ERR_ACCESS
;
1199 req_lib_ckpt_sectionexpirationtimeset
.header
.size
= sizeof (struct req_lib_ckpt_sectionexpirationtimeset
) + sectionId
->idLen
;
1200 req_lib_ckpt_sectionexpirationtimeset
.header
.id
= MESSAGE_REQ_CKPT_CHECKPOINT_SECTIONEXPIRATIONTIMESET
;
1201 req_lib_ckpt_sectionexpirationtimeset
.id_len
= sectionId
->idLen
;
1202 req_lib_ckpt_sectionexpirationtimeset
.expiration_time
= expirationTime
;
1204 marshall_to_mar_name_t (&req_lib_ckpt_sectionexpirationtimeset
.checkpoint_name
,
1205 &ckptCheckpointInstance
->checkpointName
);
1206 req_lib_ckpt_sectionexpirationtimeset
.ckpt_id
=
1207 ckptCheckpointInstance
->checkpointId
;
1209 pthread_mutex_lock (&ckptCheckpointInstance
->response_mutex
);
1211 error
= saSendRetry (ckptCheckpointInstance
->response_fd
, &req_lib_ckpt_sectionexpirationtimeset
,
1212 sizeof (struct req_lib_ckpt_sectionexpirationtimeset
));
1213 if (error
!= SA_AIS_OK
) {
1218 * Write section identifier to server
1220 if (sectionId
->idLen
) {
1221 error
= saSendRetry (ckptCheckpointInstance
->response_fd
, sectionId
->id
,
1223 if (error
!= SA_AIS_OK
) {
1228 error
= saRecvRetry (ckptCheckpointInstance
->response_fd
,
1229 &res_lib_ckpt_sectionexpirationtimeset
,
1230 sizeof (struct res_lib_ckpt_sectionexpirationtimeset
));
1233 pthread_mutex_unlock (&ckptCheckpointInstance
->response_mutex
);
1236 saHandleInstancePut (&checkpointHandleDatabase
, checkpointHandle
);
1238 return (error
== SA_AIS_OK
? res_lib_ckpt_sectionexpirationtimeset
.header
.error
: error
);
1242 saCkptSectionIterationInitialize (
1243 SaCkptCheckpointHandleT checkpointHandle
,
1244 SaCkptSectionsChosenT sectionsChosen
,
1245 SaTimeT expirationTime
,
1246 SaCkptSectionIterationHandleT
*sectionIterationHandle
)
1249 struct ckptCheckpointInstance
*ckptCheckpointInstance
;
1250 struct ckptSectionIterationInstance
*ckptSectionIterationInstance
;
1251 struct req_lib_ckpt_sectioniterationinitialize req_lib_ckpt_sectioniterationinitialize
;
1252 struct res_lib_ckpt_sectioniterationinitialize res_lib_ckpt_sectioniterationinitialize
;
1254 if (sectionIterationHandle
== NULL
) {
1255 return (SA_AIS_ERR_INVALID_PARAM
);
1258 if (sectionsChosen
!= SA_CKPT_SECTIONS_FOREVER
&&
1259 sectionsChosen
!= SA_CKPT_SECTIONS_LEQ_EXPIRATION_TIME
&&
1260 sectionsChosen
!= SA_CKPT_SECTIONS_GEQ_EXPIRATION_TIME
&&
1261 sectionsChosen
!= SA_CKPT_SECTIONS_CORRUPTED
&&
1262 sectionsChosen
!= SA_CKPT_SECTIONS_ANY
) {
1264 return (SA_AIS_ERR_INVALID_PARAM
);
1266 error
= saHandleInstanceGet (&checkpointHandleDatabase
, checkpointHandle
,
1267 (void *)&ckptCheckpointInstance
);
1268 if (error
!= SA_AIS_OK
) {
1272 error
= saHandleCreate (&ckptSectionIterationHandleDatabase
,
1273 sizeof (struct ckptSectionIterationInstance
), sectionIterationHandle
);
1274 if (error
!= SA_AIS_OK
) {
1275 goto error_put_checkpoint_db
;
1278 error
= saHandleInstanceGet (&ckptSectionIterationHandleDatabase
,
1279 *sectionIterationHandle
, (void *)&ckptSectionIterationInstance
);
1280 if (error
!= SA_AIS_OK
) {
1284 ckptSectionIterationInstance
->response_fd
= ckptCheckpointInstance
->response_fd
;
1285 ckptSectionIterationInstance
->sectionIterationHandle
= *sectionIterationHandle
;
1287 memcpy (&ckptSectionIterationInstance
->checkpointName
,
1288 &ckptCheckpointInstance
->checkpointName
, sizeof (SaNameT
));
1290 list_init (&ckptSectionIterationInstance
->list
);
1292 list_add (&ckptSectionIterationInstance
->list
,
1293 &ckptCheckpointInstance
->section_iteration_list_head
);
1295 pthread_mutex_init (&ckptSectionIterationInstance
->response_mutex
, NULL
);
1298 * Setup section id list for iterator next
1300 list_init (&ckptSectionIterationInstance
->sectionIdListHead
);
1302 req_lib_ckpt_sectioniterationinitialize
.header
.size
= sizeof (struct req_lib_ckpt_sectioniterationinitialize
);
1303 req_lib_ckpt_sectioniterationinitialize
.header
.id
= MESSAGE_REQ_CKPT_SECTIONITERATIONINITIALIZE
;
1304 req_lib_ckpt_sectioniterationinitialize
.sections_chosen
= sectionsChosen
;
1305 req_lib_ckpt_sectioniterationinitialize
.expiration_time
= expirationTime
;
1306 marshall_to_mar_name_t (
1307 &req_lib_ckpt_sectioniterationinitialize
.checkpoint_name
,
1308 &ckptCheckpointInstance
->checkpointName
);
1309 req_lib_ckpt_sectioniterationinitialize
.ckpt_id
=
1310 ckptCheckpointInstance
->checkpointId
;
1312 pthread_mutex_lock (&ckptSectionIterationInstance
->response_mutex
);
1314 error
= saSendReceiveReply (ckptSectionIterationInstance
->response_fd
,
1315 &req_lib_ckpt_sectioniterationinitialize
,
1316 sizeof (struct req_lib_ckpt_sectioniterationinitialize
),
1317 &res_lib_ckpt_sectioniterationinitialize
,
1318 sizeof (struct res_lib_ckpt_sectioniterationinitialize
));
1320 pthread_mutex_unlock (&ckptSectionIterationInstance
->response_mutex
);
1322 if (error
!= SA_AIS_OK
) {
1323 goto error_put_destroy
;
1326 ckptSectionIterationInstance
->executive_iteration_handle
=
1327 res_lib_ckpt_sectioniterationinitialize
.iteration_handle
;
1328 ckptSectionIterationInstance
->maxSectionIdSize
=
1329 res_lib_ckpt_sectioniterationinitialize
.max_section_id_size
;
1331 saHandleInstancePut (&ckptSectionIterationHandleDatabase
, *sectionIterationHandle
);
1332 saHandleInstancePut (&checkpointHandleDatabase
, checkpointHandle
);
1334 return (error
== SA_AIS_OK
? res_lib_ckpt_sectioniterationinitialize
.header
.error
: error
);
1337 saHandleInstancePut (&ckptSectionIterationHandleDatabase
, *sectionIterationHandle
);
1339 saHandleDestroy (&ckptSectionIterationHandleDatabase
, *sectionIterationHandle
);
1340 error_put_checkpoint_db
:
1341 saHandleInstancePut (&checkpointHandleDatabase
, checkpointHandle
);
1346 saCkptSectionIterationNext (
1347 SaCkptSectionIterationHandleT sectionIterationHandle
,
1348 SaCkptSectionDescriptorT
*sectionDescriptor
)
1351 struct ckptSectionIterationInstance
*ckptSectionIterationInstance
;
1352 struct req_lib_ckpt_sectioniterationnext req_lib_ckpt_sectioniterationnext
;
1353 struct res_lib_ckpt_sectioniterationnext res_lib_ckpt_sectioniterationnext
;
1354 struct iteratorSectionIdListEntry
*iteratorSectionIdListEntry
;
1356 if (sectionDescriptor
== NULL
) {
1357 return (SA_AIS_ERR_INVALID_PARAM
);
1360 error
= saHandleInstanceGet (&ckptSectionIterationHandleDatabase
,
1361 sectionIterationHandle
, (void *)&ckptSectionIterationInstance
);
1362 if (error
!= SA_AIS_OK
) {
1366 * Allocate section id storage area
1368 iteratorSectionIdListEntry
= malloc (sizeof (struct list_head
) +
1369 ckptSectionIterationInstance
->maxSectionIdSize
);
1370 if (iteratorSectionIdListEntry
== 0) {
1371 error
= SA_AIS_ERR_NO_MEMORY
;
1372 goto error_put_nounlock
;
1375 req_lib_ckpt_sectioniterationnext
.header
.size
= sizeof (struct req_lib_ckpt_sectioniterationnext
);
1376 req_lib_ckpt_sectioniterationnext
.header
.id
= MESSAGE_REQ_CKPT_SECTIONITERATIONNEXT
;
1377 req_lib_ckpt_sectioniterationnext
.iteration_handle
= ckptSectionIterationInstance
->executive_iteration_handle
;
1379 pthread_mutex_lock (&ckptSectionIterationInstance
->response_mutex
);
1381 error
= saSendReceiveReply (ckptSectionIterationInstance
->response_fd
,
1382 &req_lib_ckpt_sectioniterationnext
,
1383 sizeof (struct req_lib_ckpt_sectioniterationnext
),
1384 &res_lib_ckpt_sectioniterationnext
,
1385 sizeof (struct res_lib_ckpt_sectioniterationnext
));
1387 if (error
!= SA_AIS_OK
) {
1388 goto error_put_unlock
;
1391 marshall_from_mar_ckpt_section_descriptor_t (
1393 &res_lib_ckpt_sectioniterationnext
.section_descriptor
);
1395 sectionDescriptor
->sectionId
.id
= &iteratorSectionIdListEntry
->data
[0];
1397 if ((res_lib_ckpt_sectioniterationnext
.header
.size
- sizeof (struct res_lib_ckpt_sectioniterationnext
)) > 0) {
1398 error
= saRecvRetry (ckptSectionIterationInstance
->response_fd
,
1399 sectionDescriptor
->sectionId
.id
,
1400 res_lib_ckpt_sectioniterationnext
.header
.size
-
1401 sizeof (struct res_lib_ckpt_sectioniterationnext
));
1404 error
= (error
== SA_AIS_OK
? res_lib_ckpt_sectioniterationnext
.header
.error
: error
);
1407 * Add to persistent memory list for this sectioniterator
1409 if (error
== SA_AIS_OK
) {
1410 list_init (&iteratorSectionIdListEntry
->list
);
1411 list_add (&iteratorSectionIdListEntry
->list
, &ckptSectionIterationInstance
->sectionIdListHead
);
1415 pthread_mutex_unlock (&ckptSectionIterationInstance
->response_mutex
);
1416 if (error
!= SA_AIS_OK
) {
1417 free (iteratorSectionIdListEntry
);
1421 saHandleInstancePut (&ckptSectionIterationHandleDatabase
, sectionIterationHandle
);
1428 saCkptSectionIterationFinalize (
1429 SaCkptSectionIterationHandleT sectionIterationHandle
)
1432 struct ckptSectionIterationInstance
*ckptSectionIterationInstance
;
1433 struct req_lib_ckpt_sectioniterationfinalize req_lib_ckpt_sectioniterationfinalize
;
1434 struct res_lib_ckpt_sectioniterationfinalize res_lib_ckpt_sectioniterationfinalize
;
1436 error
= saHandleInstanceGet (&ckptSectionIterationHandleDatabase
,
1437 sectionIterationHandle
, (void *)&ckptSectionIterationInstance
);
1438 if (error
!= SA_AIS_OK
) {
1442 req_lib_ckpt_sectioniterationfinalize
.header
.size
= sizeof (struct req_lib_ckpt_sectioniterationfinalize
);
1443 req_lib_ckpt_sectioniterationfinalize
.header
.id
= MESSAGE_REQ_CKPT_SECTIONITERATIONFINALIZE
;
1444 req_lib_ckpt_sectioniterationfinalize
.iteration_handle
= ckptSectionIterationInstance
->executive_iteration_handle
;
1446 pthread_mutex_lock (&ckptSectionIterationInstance
->response_mutex
);
1448 error
= saSendReceiveReply (ckptSectionIterationInstance
->response_fd
,
1449 &req_lib_ckpt_sectioniterationfinalize
,
1450 sizeof (struct req_lib_ckpt_sectioniterationfinalize
),
1451 &res_lib_ckpt_sectioniterationfinalize
,
1452 sizeof (struct res_lib_ckpt_sectioniterationfinalize
));
1454 pthread_mutex_unlock (&ckptSectionIterationInstance
->response_mutex
);
1456 if (error
!= SA_AIS_OK
) {
1460 ckptSectionIterationInstanceFinalize (ckptSectionIterationInstance
);
1462 saHandleInstancePut (&ckptSectionIterationHandleDatabase
, sectionIterationHandle
);
1467 pthread_mutex_unlock (&ckptSectionIterationInstance
->response_mutex
);
1469 saHandleInstancePut (&ckptSectionIterationHandleDatabase
, sectionIterationHandle
);
1471 return (error
== SA_AIS_OK
? res_lib_ckpt_sectioniterationfinalize
.header
.error
: error
);
1475 saCkptCheckpointWrite (
1476 SaCkptCheckpointHandleT checkpointHandle
,
1477 const SaCkptIOVectorElementT
*ioVector
,
1478 SaUint32T numberOfElements
,
1479 SaUint32T
*erroneousVectorIndex
)
1481 SaAisErrorT error
= SA_AIS_OK
;
1482 struct ckptCheckpointInstance
*ckptCheckpointInstance
;
1483 struct req_lib_ckpt_sectionwrite req_lib_ckpt_sectionwrite
;
1484 struct res_lib_ckpt_sectionwrite res_lib_ckpt_sectionwrite
;
1486 struct iovec iov
[3];
1490 if (ioVector
== NULL
) {
1491 return (SA_AIS_ERR_INVALID_PARAM
);
1494 error
= saHandleInstanceGet (&checkpointHandleDatabase
, checkpointHandle
,
1495 (void *)&ckptCheckpointInstance
);
1496 if (error
!= SA_AIS_OK
) {
1500 if ((ckptCheckpointInstance
->checkpointOpenFlags
& SA_CKPT_CHECKPOINT_WRITE
) == 0) {
1501 error
= SA_AIS_ERR_ACCESS
;
1504 req_lib_ckpt_sectionwrite
.header
.id
= MESSAGE_REQ_CKPT_CHECKPOINT_SECTIONWRITE
;
1507 * Make sure ioVector is valid
1509 for (i
= 0; i
< numberOfElements
; i
++) {
1510 if (ioVector
[i
].dataSize
== 0) {
1511 *erroneousVectorIndex
= i
;
1512 error
= SA_AIS_ERR_INVALID_PARAM
;
1515 if (ioVector
[i
].dataBuffer
== NULL
) {
1516 *erroneousVectorIndex
= i
;
1517 error
= SA_AIS_ERR_INVALID_PARAM
;
1522 pthread_mutex_lock (&ckptCheckpointInstance
->response_mutex
);
1524 for (i
= 0; i
< numberOfElements
; i
++) {
1526 req_lib_ckpt_sectionwrite
.header
.size
= sizeof (struct req_lib_ckpt_sectionwrite
) + ioVector
[i
].sectionId
.idLen
+ ioVector
[i
].dataSize
;
1528 req_lib_ckpt_sectionwrite
.data_offset
= ioVector
[i
].dataOffset
;
1529 req_lib_ckpt_sectionwrite
.data_size
= ioVector
[i
].dataSize
;
1530 req_lib_ckpt_sectionwrite
.id_len
= ioVector
[i
].sectionId
.idLen
;
1532 marshall_to_mar_name_t (&req_lib_ckpt_sectionwrite
.checkpoint_name
,
1533 &ckptCheckpointInstance
->checkpointName
);
1534 req_lib_ckpt_sectionwrite
.ckpt_id
=
1535 ckptCheckpointInstance
->checkpointId
;
1539 iov
[iov_idx
].iov_base
= (char *)&req_lib_ckpt_sectionwrite
;
1540 iov
[iov_idx
].iov_len
= sizeof (struct req_lib_ckpt_sectionwrite
);
1543 if (ioVector
[i
].sectionId
.idLen
) {
1544 iov
[iov_idx
].iov_base
= (char *)ioVector
[i
].sectionId
.id
;
1545 iov
[iov_idx
].iov_len
= ioVector
[i
].sectionId
.idLen
;
1548 iov
[iov_idx
].iov_base
= ioVector
[i
].dataBuffer
;
1549 iov
[iov_idx
].iov_len
= ioVector
[i
].dataSize
;
1552 error
= saSendMsgRetry (ckptCheckpointInstance
->response_fd
,
1555 if (error
!= SA_AIS_OK
) {
1562 error
= saRecvRetry (ckptCheckpointInstance
->response_fd
, &res_lib_ckpt_sectionwrite
,
1563 sizeof (struct res_lib_ckpt_sectionwrite
));
1564 if (error
!= SA_AIS_OK
) {
1568 if (res_lib_ckpt_sectionwrite
.header
.error
== SA_AIS_ERR_TRY_AGAIN
) {
1569 error
= SA_AIS_ERR_TRY_AGAIN
;
1573 * If error, report back erroneous index
1575 if (res_lib_ckpt_sectionwrite
.header
.error
!= SA_AIS_OK
) {
1576 if (erroneousVectorIndex
) {
1577 *erroneousVectorIndex
= i
;
1584 pthread_mutex_unlock (&ckptCheckpointInstance
->response_mutex
);
1587 saHandleInstancePut (&checkpointHandleDatabase
, checkpointHandle
);
1589 return (error
== SA_AIS_OK
? res_lib_ckpt_sectionwrite
.header
.error
: error
);
1593 saCkptSectionOverwrite (
1594 SaCkptCheckpointHandleT checkpointHandle
,
1595 const SaCkptSectionIdT
*sectionId
,
1596 const void *dataBuffer
,
1600 struct ckptCheckpointInstance
*ckptCheckpointInstance
;
1601 struct req_lib_ckpt_sectionoverwrite req_lib_ckpt_sectionoverwrite
;
1602 struct res_lib_ckpt_sectionoverwrite res_lib_ckpt_sectionoverwrite
;
1604 if (dataBuffer
== NULL
) {
1605 return (SA_AIS_ERR_INVALID_PARAM
);
1608 if (sectionId
== NULL
) {
1609 return (SA_AIS_ERR_INVALID_PARAM
);
1612 error
= saHandleInstanceGet (&checkpointHandleDatabase
, checkpointHandle
,
1613 (void *)&ckptCheckpointInstance
);
1614 if (error
!= SA_AIS_OK
) {
1618 if ((ckptCheckpointInstance
->checkpointOpenFlags
& SA_CKPT_CHECKPOINT_WRITE
) == 0) {
1619 return (SA_AIS_ERR_ACCESS
);
1622 req_lib_ckpt_sectionoverwrite
.header
.size
= sizeof (struct req_lib_ckpt_sectionoverwrite
) + sectionId
->idLen
+ dataSize
;
1623 req_lib_ckpt_sectionoverwrite
.header
.id
= MESSAGE_REQ_CKPT_CHECKPOINT_SECTIONOVERWRITE
;
1624 req_lib_ckpt_sectionoverwrite
.id_len
= sectionId
->idLen
;
1625 req_lib_ckpt_sectionoverwrite
.data_size
= dataSize
;
1626 marshall_to_mar_name_t (&req_lib_ckpt_sectionoverwrite
.checkpoint_name
,
1627 &ckptCheckpointInstance
->checkpointName
);
1628 req_lib_ckpt_sectionoverwrite
.ckpt_id
=
1629 ckptCheckpointInstance
->checkpointId
;
1631 pthread_mutex_lock (&ckptCheckpointInstance
->response_mutex
);
1633 error
= saSendRetry (ckptCheckpointInstance
->response_fd
, &req_lib_ckpt_sectionoverwrite
,
1634 sizeof (struct req_lib_ckpt_sectionoverwrite
));
1635 if (error
!= SA_AIS_OK
) {
1639 if (sectionId
->idLen
) {
1640 error
= saSendRetry (ckptCheckpointInstance
->response_fd
, sectionId
->id
,
1642 if (error
!= SA_AIS_OK
) {
1646 error
= saSendRetry (ckptCheckpointInstance
->response_fd
, dataBuffer
, dataSize
);
1647 if (error
!= SA_AIS_OK
) {
1651 error
= saRecvRetry (ckptCheckpointInstance
->response_fd
,
1652 &res_lib_ckpt_sectionoverwrite
,
1653 sizeof (struct res_lib_ckpt_sectionoverwrite
));
1656 pthread_mutex_unlock (&ckptCheckpointInstance
->response_mutex
);
1658 saHandleInstancePut (&checkpointHandleDatabase
, checkpointHandle
);
1660 return (error
== SA_AIS_OK
? res_lib_ckpt_sectionoverwrite
.header
.error
: error
);
1664 saCkptCheckpointRead (
1665 SaCkptCheckpointHandleT checkpointHandle
,
1666 SaCkptIOVectorElementT
*ioVector
,
1667 SaUint32T numberOfElements
,
1668 SaUint32T
*erroneousVectorIndex
)
1670 SaAisErrorT error
= SA_AIS_OK
;
1671 struct ckptCheckpointInstance
*ckptCheckpointInstance
;
1672 struct req_lib_ckpt_sectionread req_lib_ckpt_sectionread
;
1673 struct res_lib_ckpt_sectionread res_lib_ckpt_sectionread
;
1676 struct iovec iov
[3];
1678 if (ioVector
== NULL
) {
1679 return (SA_AIS_ERR_INVALID_PARAM
);
1682 error
= saHandleInstanceGet (&checkpointHandleDatabase
, checkpointHandle
,
1683 (void *)&ckptCheckpointInstance
);
1684 if (error
!= SA_AIS_OK
) {
1688 if ((ckptCheckpointInstance
->checkpointOpenFlags
& SA_CKPT_CHECKPOINT_READ
) == 0) {
1689 return (SA_AIS_ERR_ACCESS
);
1692 req_lib_ckpt_sectionread
.header
.id
= MESSAGE_REQ_CKPT_CHECKPOINT_SECTIONREAD
;
1694 pthread_mutex_lock (&ckptCheckpointInstance
->response_mutex
);
1696 for (i
= 0; i
< numberOfElements
; i
++) {
1697 req_lib_ckpt_sectionread
.header
.size
= sizeof (struct req_lib_ckpt_sectionread
) +
1698 ioVector
[i
].sectionId
.idLen
;
1700 req_lib_ckpt_sectionread
.id_len
= ioVector
[i
].sectionId
.idLen
;
1701 req_lib_ckpt_sectionread
.data_offset
= ioVector
[i
].dataOffset
;
1702 req_lib_ckpt_sectionread
.data_size
= ioVector
[i
].dataSize
;
1704 marshall_to_mar_name_t (&req_lib_ckpt_sectionread
.checkpoint_name
,
1705 &ckptCheckpointInstance
->checkpointName
);
1706 req_lib_ckpt_sectionread
.ckpt_id
=
1707 ckptCheckpointInstance
->checkpointId
;
1709 iov
[0].iov_base
= (char *)&req_lib_ckpt_sectionread
;
1710 iov
[0].iov_len
= sizeof (struct req_lib_ckpt_sectionread
);
1711 iov
[1].iov_base
= (char *)ioVector
[i
].sectionId
.id
;
1712 iov
[1].iov_len
= ioVector
[i
].sectionId
.idLen
;
1714 error
= saSendMsgRetry (ckptCheckpointInstance
->response_fd
,
1719 * Receive response header
1721 error
= saRecvRetry (ckptCheckpointInstance
->response_fd
, &res_lib_ckpt_sectionread
,
1722 sizeof (struct res_lib_ckpt_sectionread
));
1723 if (error
!= SA_AIS_OK
) {
1727 dataLength
= res_lib_ckpt_sectionread
.header
.size
- sizeof (struct res_lib_ckpt_sectionread
);
1730 * Receive checkpoint section data
1732 if (ioVector
[i
].dataBuffer
== 0) {
1733 ioVector
[i
].dataBuffer
=
1734 malloc (dataLength
);
1735 if (ioVector
[i
].dataBuffer
== NULL
) {
1736 error
= SA_AIS_ERR_NO_MEMORY
;
1741 if (dataLength
> 0) {
1742 error
= saRecvRetry (ckptCheckpointInstance
->response_fd
, ioVector
[i
].dataBuffer
,
1744 if (error
!= SA_AIS_OK
) {
1748 if (res_lib_ckpt_sectionread
.header
.error
!= SA_AIS_OK
) {
1753 * Report back bytes of data read
1755 ioVector
[i
].readSize
= res_lib_ckpt_sectionread
.data_read
;
1759 pthread_mutex_unlock (&ckptCheckpointInstance
->response_mutex
);
1761 saHandleInstancePut (&checkpointHandleDatabase
, checkpointHandle
);
1763 if (error
!= SA_AIS_OK
&& erroneousVectorIndex
) {
1764 *erroneousVectorIndex
= i
;
1766 return (error
== SA_AIS_OK
? res_lib_ckpt_sectionread
.header
.error
: error
);
1770 saCkptCheckpointSynchronize (
1771 SaCkptCheckpointHandleT checkpointHandle
,
1775 struct ckptCheckpointInstance
*ckptCheckpointInstance
;
1776 struct req_lib_ckpt_checkpointsynchronize req_lib_ckpt_checkpointsynchronize
;
1777 struct res_lib_ckpt_checkpointsynchronize res_lib_ckpt_checkpointsynchronize
;
1780 return (SA_AIS_ERR_TIMEOUT
);
1783 error
= saHandleInstanceGet (&checkpointHandleDatabase
, checkpointHandle
,
1784 (void *)&ckptCheckpointInstance
);
1785 if (error
!= SA_AIS_OK
) {
1789 if ((ckptCheckpointInstance
->checkpointOpenFlags
& SA_CKPT_CHECKPOINT_WRITE
) == 0) {
1790 error
= SA_AIS_ERR_ACCESS
;
1794 req_lib_ckpt_checkpointsynchronize
.header
.size
= sizeof (struct req_lib_ckpt_checkpointsynchronize
);
1795 req_lib_ckpt_checkpointsynchronize
.header
.id
= MESSAGE_REQ_CKPT_CHECKPOINT_CHECKPOINTSYNCHRONIZE
;
1796 marshall_to_mar_name_t (&req_lib_ckpt_checkpointsynchronize
.checkpoint_name
,
1797 &ckptCheckpointInstance
->checkpointName
);
1798 req_lib_ckpt_checkpointsynchronize
.ckpt_id
=
1799 ckptCheckpointInstance
->checkpointId
;
1801 pthread_mutex_lock (&ckptCheckpointInstance
->response_mutex
);
1803 error
= saSendReceiveReply (ckptCheckpointInstance
->response_fd
,
1804 &req_lib_ckpt_checkpointsynchronize
,
1805 sizeof (struct req_lib_ckpt_checkpointsynchronize
),
1806 &res_lib_ckpt_checkpointsynchronize
,
1807 sizeof (struct res_lib_ckpt_checkpointsynchronize
));
1809 pthread_mutex_unlock (&ckptCheckpointInstance
->response_mutex
);
1812 saHandleInstancePut (&checkpointHandleDatabase
, checkpointHandle
);
1814 return (error
== SA_AIS_OK
? res_lib_ckpt_checkpointsynchronize
.header
.error
: error
);
1818 saCkptCheckpointSynchronizeAsync (
1819 SaCkptCheckpointHandleT checkpointHandle
,
1820 SaInvocationT invocation
)
1823 struct ckptInstance
*ckptInstance
;
1824 struct ckptCheckpointInstance
*ckptCheckpointInstance
;
1825 struct req_lib_ckpt_checkpointsynchronizeasync req_lib_ckpt_checkpointsynchronizeasync
;
1826 struct res_lib_ckpt_checkpointsynchronizeasync res_lib_ckpt_checkpointsynchronizeasync
;
1828 error
= saHandleInstanceGet (&checkpointHandleDatabase
, checkpointHandle
,
1829 (void *)&ckptCheckpointInstance
);
1830 if (error
!= SA_AIS_OK
) {
1834 if ((ckptCheckpointInstance
->checkpointOpenFlags
& SA_CKPT_CHECKPOINT_WRITE
) == 0) {
1835 error
= SA_AIS_ERR_ACCESS
;
1839 error
= saHandleInstanceGet (&ckptHandleDatabase
, ckptCheckpointInstance
->ckptHandle
,
1840 (void *)&ckptInstance
);
1841 if (error
!= SA_AIS_OK
) {
1845 if (ckptInstance
->callbacks
.saCkptCheckpointSynchronizeCallback
== NULL
) {
1846 saHandleInstancePut (&ckptHandleDatabase
, ckptCheckpointInstance
->ckptHandle
);
1847 error
= SA_AIS_ERR_INIT
;
1851 saHandleInstancePut (&ckptHandleDatabase
, ckptCheckpointInstance
->ckptHandle
);
1853 req_lib_ckpt_checkpointsynchronizeasync
.header
.size
= sizeof (struct req_lib_ckpt_checkpointsynchronizeasync
);
1854 req_lib_ckpt_checkpointsynchronizeasync
.header
.id
= MESSAGE_REQ_CKPT_CHECKPOINT_CHECKPOINTSYNCHRONIZEASYNC
;
1855 marshall_to_mar_name_t (
1856 &req_lib_ckpt_checkpointsynchronizeasync
.checkpoint_name
,
1857 &ckptCheckpointInstance
->checkpointName
);
1858 req_lib_ckpt_checkpointsynchronizeasync
.ckpt_id
=
1859 ckptCheckpointInstance
->checkpointId
;
1860 req_lib_ckpt_checkpointsynchronizeasync
.invocation
= invocation
;
1862 pthread_mutex_lock (&ckptCheckpointInstance
->response_mutex
);
1864 error
= saSendReceiveReply (ckptCheckpointInstance
->response_fd
,
1865 &req_lib_ckpt_checkpointsynchronizeasync
,
1866 sizeof (struct req_lib_ckpt_checkpointsynchronizeasync
),
1867 &res_lib_ckpt_checkpointsynchronizeasync
,
1868 sizeof (struct res_lib_ckpt_checkpointsynchronizeasync
));
1870 pthread_mutex_unlock (&ckptCheckpointInstance
->response_mutex
);
1873 saHandleInstancePut (&checkpointHandleDatabase
, checkpointHandle
);
1875 return (error
== SA_AIS_OK
? res_lib_ckpt_checkpointsynchronizeasync
.header
.error
: error
);