Hi Ramesh,

- Most of the  your review comment are related to cpnd_ckpt_sec_write()
in case of cpnd_ckpt_sec_write fail nothing to be rollback of any cktp/section recently/long back/just- created just need to report we are not able to write user data in to SHM, so that the user will re-write


   So No action required.

- Few of them addressed in #2207

- Other comment are addressed

Please find the attached updated patch for your reference .

-AVM

On 12/1/2016 12:08 PM, ramesh betham wrote:
Hi Mahesh,

Please find my review comments inline with [Ramesh].

Thanks,
Ramesh.

On 11/29/2016 4:07 PM, mahesh.va...@oracle.com wrote:
  osaf/libs/common/cpsv/include/cpnd_cb.h   |   4 +-
  osaf/libs/common/cpsv/include/cpnd_init.h |   8 +-
  osaf/libs/common/cpsv/include/cpnd_sec.h  |   2 +-
  osaf/libs/core/include/ncs_osprm.h        |   2 +-
  osaf/services/saf/cpsv/cpnd/cpnd_db.c     |  12 ++--
  osaf/services/saf/cpsv/cpnd/cpnd_evt.c    |  82 +++++++++++++++++++++---------
  osaf/services/saf/cpsv/cpnd/cpnd_proc.c   |  31 ++++++----
  osaf/services/saf/cpsv/cpnd/cpnd_res.c    |  24 +++------
  osaf/services/saf/cpsv/cpnd/cpnd_sec.cc   |  12 ++--
  9 files changed, 103 insertions(+), 74 deletions(-)


diff --git a/osaf/libs/common/cpsv/include/cpnd_cb.h 
b/osaf/libs/common/cpsv/include/cpnd_cb.h
--- a/osaf/libs/common/cpsv/include/cpnd_cb.h
+++ b/osaf/libs/common/cpsv/include/cpnd_cb.h
@@ -341,8 +341,8 @@ uint32_t cpnd_amf_register(CPND_CB *cpnd
  uint32_t cpnd_amf_deregister(CPND_CB *cpnd_cb);
  uint32_t cpnd_client_extract_bits(uint32_t bitmap_value, uint32_t 
*bit_position);
  uint32_t cpnd_res_ckpt_sec_del(CPND_CKPT_NODE *cp_node);
-uint32_t cpnd_ckpt_replica_create_res(NCS_OS_POSIX_SHM_REQ_INFO *open_req, 
char *buf, CPND_CKPT_NODE **cp_node,
-                                           uint32_t ref_cnt, CKPT_INFO 
*cp_info, bool shm_alloc_guaranteed);
+uint32_t cpnd_ckpt_replica_create_res(CPND_CB *cb, NCS_OS_POSIX_SHM_REQ_INFO 
*open_req, char *buf, CPND_CKPT_NODE **cp_node,
+                                           uint32_t ref_cnt, CKPT_INFO 
*cp_info);
  int32_t cpnd_find_free_loc(CPND_CB *cb, CPND_TYPE_INFO type);
  uint32_t cpnd_ckpt_write_header(CPND_CB *cb, uint32_t nckpts);
  uint32_t cpnd_cli_info_write_header(CPND_CB *cb, int32_t n_clients);
diff --git a/osaf/libs/common/cpsv/include/cpnd_init.h 
b/osaf/libs/common/cpsv/include/cpnd_init.h
--- a/osaf/libs/common/cpsv/include/cpnd_init.h
+++ b/osaf/libs/common/cpsv/include/cpnd_init.h
@@ -90,7 +90,7 @@ uint32_t cpnd_ckpt_replica_create(CPND_C
  uint32_t cpnd_ckpt_remote_cpnd_add(CPND_CKPT_NODE *cp_node, MDS_DEST 
mds_info);
  uint32_t cpnd_ckpt_remote_cpnd_del(CPND_CKPT_NODE *cp_node, MDS_DEST 
mds_info);
  int32_t cpnd_ckpt_get_lck_sec_id(CPND_CKPT_NODE *cp_node);
-uint32_t cpnd_ckpt_sec_write(CPND_CKPT_NODE *cp_node, CPND_CKPT_SECTION_INFO
+uint32_t cpnd_ckpt_sec_write(CPND_CB *cb, CPND_CKPT_NODE *cp_node, 
CPND_CKPT_SECTION_INFO
                          *sec_info, const void *data, uint64_t size, uint64_t 
offset, uint32_t type);
  uint32_t cpnd_ckpt_sec_read(CPND_CKPT_NODE *cp_node, CPND_CKPT_SECTION_INFO
                         *sec_info, void *data, uint64_t size, uint64_t offset);
@@ -164,7 +164,7 @@ void cpnd_evt_node_getnext(CPND_CB *cb,
  uint32_t cpnd_evt_node_add(CPND_CB *cb, CPSV_CPND_ALL_REPL_EVT_NODE 
*evt_node);
  uint32_t cpnd_evt_node_del(CPND_CB *cb, CPSV_CPND_ALL_REPL_EVT_NODE 
*evt_node);
  CPND_CKPT_NODE *cpnd_ckpt_node_find_by_name(CPND_CB *cpnd_cb, SaConstStringT 
ckpt_name);
-CPND_CKPT_SECTION_INFO *cpnd_ckpt_sec_add(CPND_CKPT_NODE *cp_node, 
SaCkptSectionIdT *id, SaTimeT exp_time,
+CPND_CKPT_SECTION_INFO *cpnd_ckpt_sec_add(CPND_CB *cb, CPND_CKPT_NODE 
*cp_node, SaCkptSectionIdT *id, SaTimeT exp_time,
                                          uint32_t gen_flag);
  void cpnd_evt_backup_queue_add(CPND_CKPT_NODE *cp_node, CPND_EVT *evt);
  uint32_t cpnd_ckpt_node_tree_init(CPND_CB *cb);
@@ -176,8 +176,8 @@ void cpnd_client_node_tree_cleanup(CPND_
  void cpnd_client_node_tree_destroy(CPND_CB *cb);
  void cpnd_allrepl_write_evt_node_tree_cleanup(CPND_CB *cb);
  void cpnd_allrepl_write_evt_node_tree_destroy(CPND_CB *cb);
-uint32_t cpnd_sec_hdr_update(CPND_CKPT_SECTION_INFO *pSecPtr, CPND_CKPT_NODE 
*cp_node);
-uint32_t cpnd_ckpt_hdr_update(CPND_CKPT_NODE *cp_node);
+uint32_t cpnd_sec_hdr_update(CPND_CB *cb, CPND_CKPT_SECTION_INFO *pSecPtr, 
CPND_CKPT_NODE *cp_node);
+uint32_t cpnd_ckpt_hdr_update(CPND_CB *cb, CPND_CKPT_NODE *cp_node);
  void cpnd_ckpt_node_destroy(CPND_CB *cb, CPND_CKPT_NODE *cp_node);
  uint32_t cpnd_get_slot_sub_slot_id_from_mds_dest(MDS_DEST dest);
  uint32_t cpnd_get_slot_sub_slot_id_from_node_id(NCS_NODE_ID i_node_id);
diff --git a/osaf/libs/common/cpsv/include/cpnd_sec.h 
b/osaf/libs/common/cpsv/include/cpnd_sec.h
--- a/osaf/libs/common/cpsv/include/cpnd_sec.h
+++ b/osaf/libs/common/cpsv/include/cpnd_sec.h
@@ -39,7 +39,7 @@ CPND_CKPT_SECTION_INFO *
  cpnd_ckpt_sec_get_create(const CPND_CKPT_NODE *, const SaCkptSectionIdT *);
CPND_CKPT_SECTION_INFO *
-cpnd_ckpt_sec_del(CPND_CKPT_NODE *, SaCkptSectionIdT *);
+cpnd_ckpt_sec_del(CPND_CB *cb, CPND_CKPT_NODE *, SaCkptSectionIdT *);
CPND_CKPT_SECTION_INFO *
  cpnd_get_sect_with_id(const CPND_CKPT_NODE *, uint32_t lcl_sec_id);
diff --git a/osaf/libs/core/include/ncs_osprm.h 
b/osaf/libs/core/include/ncs_osprm.h
--- a/osaf/libs/core/include/ncs_osprm.h
+++ b/osaf/libs/core/include/ncs_osprm.h
@@ -564,7 +564,6 @@ typedef struct ncs_os_posix_shm_req_open
    uint32_t i_flags;
    uint32_t i_map_flags;
    uint64_t i_size;
-  bool ensures_space;
    uint64_t i_offset;
    void *o_addr;
    int32_t o_fd;
@@ -600,6 +599,7 @@ typedef struct ncs_os_posix_shm_req_writ
typedef struct ncs_shm_req_info {
    NCS_OS_POSIX_SHM_REQ_TYPE type;
+  bool ensures_space;
union {
      NCS_OS_POSIX_SHM_REQ_OPEN_INFO open;
diff --git a/osaf/services/saf/cpsv/cpnd/cpnd_db.c 
b/osaf/services/saf/cpsv/cpnd/cpnd_db.c
--- a/osaf/services/saf/cpsv/cpnd/cpnd_db.c
+++ b/osaf/services/saf/cpsv/cpnd/cpnd_db.c
@@ -384,7 +384,7 @@ uint32_t cpnd_evt_node_del(CPND_CB *cb,
   *
   * Notes         : None.
   
*****************************************************************************/
-CPND_CKPT_SECTION_INFO *cpnd_ckpt_sec_add(CPND_CKPT_NODE *cp_node, 
SaCkptSectionIdT *id,
+CPND_CKPT_SECTION_INFO *cpnd_ckpt_sec_add(CPND_CB *cb, CPND_CKPT_NODE 
*cp_node, SaCkptSectionIdT *id,
                                          SaTimeT exp_time, uint32_t gen_flag)
  {
        CPND_CKPT_SECTION_INFO *pSecPtr = NULL;
@@ -453,15 +453,15 @@ CPND_CKPT_SECTION_INFO *cpnd_ckpt_sec_ad
        cp_node->replica_info.n_secs++;
/* UPDATE THE SECTION HEADER */
-       rc = cpnd_sec_hdr_update(pSecPtr, cp_node);
+       rc = cpnd_sec_hdr_update(cb, pSecPtr, cp_node);
        if (rc == NCSCC_RC_FAILURE) {
-               LOG_NO("cpnd sect hdr update failed");
+               LOG_ER("cpnd sect hdr update failed");
                goto section_hdr_update_fails;
        }
        /* UPDATE THE CHECKPOINT HEADER */
-       rc = cpnd_ckpt_hdr_update(cp_node);
+       rc = cpnd_ckpt_hdr_update(cb, cp_node);
        if (rc == NCSCC_RC_FAILURE) {
-               LOG_NO("cpnd ckpt hdr update failed");
+               LOG_ER("cpnd ckpt hdr update failed");
                goto ckpt_hdr_update_fails;
        }
@@ -470,7 +470,7 @@ CPND_CKPT_SECTION_INFO *cpnd_ckpt_sec_ad section_hdr_update_fails:
   ckpt_hdr_update_fails:
-       cpnd_ckpt_sec_del(cp_node, id);
+       cpnd_ckpt_sec_del(cb, cp_node, id);
section_add_fails:
        if (pSecPtr->sec_id.id != NULL)
diff --git a/osaf/services/saf/cpsv/cpnd/cpnd_evt.c 
b/osaf/services/saf/cpsv/cpnd/cpnd_evt.c
--- a/osaf/services/saf/cpsv/cpnd/cpnd_evt.c
+++ b/osaf/services/saf/cpsv/cpnd/cpnd_evt.c
@@ -834,10 +834,12 @@ static uint32_t cpnd_evt_proc_ckpt_open(
                        }
/* UPDATE THE CHECKPOINT HEADER */
-                       rc = cpnd_ckpt_hdr_update(cp_node);
+                       rc = cpnd_ckpt_hdr_update(cb, cp_node);
                        if (rc == NCSCC_RC_FAILURE) {
-                               TRACE_4("cpnd ckpt hdr update failed 
ckpt_name:%s,client_hdl:%llx",
+                               LOG_ER("cpnd ckpt hdr update failed 
ckpt_name:%s,client_hdl:%llx",
                                                ckpt_name, client_hdl);
+                               send_evt.info.cpa.info.openRsp.error = 
SA_AIS_ERR_NO_RESOURCES;
+                               goto ckpt_node_free_error;
[Ramesh]: It suppose to go to "ckpt_shm_node_free_error" to do cpnd_ckpt_replica_destroy().
[AVM] Done
                        }
                }
@@ -861,7 +863,7 @@ static uint32_t cpnd_evt_proc_ckpt_open(
                    cp_node->create_attrib.maxSections == 1) {
SaCkptSectionIdT sec_id = SA_CKPT_DEFAULT_SECTION_ID;
-                       if(cpnd_ckpt_sec_add(cp_node, &sec_id, 0, 0) == NULL) {
+                       if(cpnd_ckpt_sec_add(cb, cp_node, &sec_id, 0, 0) == 
NULL) {
                                TRACE_4("cpnd ckpt rep create failed with 
rc:%d",rc);
                                goto ckpt_shm_node_free_error;
                        }
@@ -1275,7 +1277,12 @@ static uint32_t cpnd_evt_proc_ckpt_unlin
                cp_node->ckpt_name = strdup("");
if (cp_node->cpnd_rep_create) {
-                       rc = cpnd_ckpt_hdr_update(cp_node);
+                       rc = cpnd_ckpt_hdr_update(cb, cp_node);
+                       if (rc == NCSCC_RC_FAILURE) {
+                               error = SA_AIS_ERR_NO_RESOURCES;
+                               LOG_ER("cpnd ckpt hdr update failed for 
ckpt_id:%llx,rc:%d",cp_node->ckpt_id, rc);
+                               goto agent_rsp;
+                        }
}
                TRACE_4("cpnd proc ckpt unlink set for 
ckpt_id:%llx",cp_node->ckpt_id);
@@ -1484,7 +1491,11 @@ static uint32_t cpnd_evt_proc_ckpt_rdset
        cp_node->is_rdset = true;
        /*Non-collocated which does not have replica */
        if (cp_node->cpnd_rep_create)
-               cpnd_ckpt_hdr_update(cp_node);
+                if (cpnd_ckpt_hdr_update(cb, cp_node) == NCSCC_RC_FAILURE) {
+                        LOG_ER("cpnd sect hdr update failed");
+                        send_evt.info.cpa.info.rdsetRsp.error = 
SA_AIS_ERR_NO_RESOURCES;
+                        goto out_evt_free;
+                }
send_evt.info.cpa.info.rdsetRsp.error = SA_AIS_OK; @@ -1631,9 +1642,13 @@ static uint32_t cpnd_evt_proc_ckpt_arep_
                }
        }
- rc = cpnd_ckpt_hdr_update(cp_node);
-
-       send_evt.info.cpa.info.arsetRsp.error = SA_AIS_OK;
+       rc = cpnd_ckpt_hdr_update(cb, cp_node);
+       if (rc == NCSCC_RC_FAILURE) {
+               LOG_ER("cpnd  ckpt hdr update failed");
+               send_evt.info.cpa.info.arsetRsp.error = SA_AIS_ERR_NO_RESOURCES;
+       } else {
+               send_evt.info.cpa.info.arsetRsp.error = SA_AIS_OK;
+       }
[Ramesh]: Minor code adjustments, if FAILURE do goto agent_rsp and remove else and have SA_AIS_OK as final update.
        goto agent_rsp;
[AVM] Done

        goto agent_rsp;
agent_rsp:
@@ -2082,7 +2097,11 @@ static uint32_t cpnd_evt_proc_ckpt_sect_
                        sec_info->ckpt_sec_exptmr.uarg = cb->cpnd_cb_hdl_id;
                        sec_info->ckpt_sec_exptmr.lcl_sec_id = 
sec_info->lcl_sec_id;
- cpnd_sec_hdr_update(sec_info, cp_node);
+                       if (cpnd_sec_hdr_update(cb, sec_info, cp_node) == 
NCSCC_RC_FAILURE) {
+                               LOG_ER("cpnd sect hdr update failed");
+                               send_evt.info.cpa.info.sec_exptmr_rsp.error = 
SA_AIS_ERR_NO_RESOURCES;
+                               goto agent_rsp;
+                       }
cpnd_tmr_start(&sec_info->ckpt_sec_exptmr,
                                       
m_CPSV_CONVERT_SATIME_TEN_MILLI_SEC(sec_info->exp_tmr));
@@ -2108,7 +2127,11 @@ static uint32_t cpnd_evt_proc_ckpt_sect_
                }
                if (cp_node->cpnd_rep_create) {
                        sec_info->exp_tmr = evt->info.sec_expset.exp_time;
-                       cpnd_sec_hdr_update(sec_info, cp_node);
+                       if (cpnd_sec_hdr_update(cb, sec_info, cp_node) == 
NCSCC_RC_FAILURE) {
+                               LOG_ER("cpnd sect hdr update failed");
+                               send_evt.info.cpa.info.sec_exptmr_rsp.error = 
SA_AIS_ERR_NO_RESOURCES;
+                               goto agent_rsp;
+                       }
                }
        }
@@ -2237,11 +2260,11 @@ static uint32_t cpnd_evt_proc_ckpt_sect_ if (cp_node->cpnd_rep_create) {
                if (gen_sec_id)
-                       sec_info = cpnd_ckpt_sec_add(cp_node, 
evt->info.sec_creatReq.sec_attri.sectionId,
+                       sec_info = cpnd_ckpt_sec_add(cb, cp_node, 
evt->info.sec_creatReq.sec_attri.sectionId,
                                                     
evt->info.sec_creatReq.sec_attri.expirationTime, 1);
else
-                       sec_info = cpnd_ckpt_sec_add(cp_node, 
evt->info.sec_creatReq.sec_attri.sectionId,
+                       sec_info = cpnd_ckpt_sec_add(cb, cp_node, 
evt->info.sec_creatReq.sec_attri.sectionId,
                                                     
evt->info.sec_creatReq.sec_attri.expirationTime, 0);
if (sec_info == NULL) {
@@ -2255,7 +2278,7 @@ static uint32_t cpnd_evt_proc_ckpt_sect_
if ((evt->info.sec_creatReq.init_data != NULL) && (evt->info.sec_creatReq.init_size != 0)) { - rc = cpnd_ckpt_sec_write(cp_node, sec_info, evt->info.sec_creatReq.init_data,
+                       rc = cpnd_ckpt_sec_write(cb, cp_node, sec_info, 
evt->info.sec_creatReq.init_data,
                                                 
evt->info.sec_creatReq.init_size, 0, 1);
                        if (rc == NCSCC_RC_FAILURE) {
                                TRACE_4("cpnd ckpt sect write failed for 
section_is:%s,ckpt_id:%llx",sec_info->sec_id.id, cp_node->ckpt_id);
[Ramesh]: Similarly if there is a failure here, What happens to the sec_info related structs added to the DB in the above called function cpnd_ckpt_sec_add()? Also with the sec_hdr and ckpt_hdr written to shared memory?
[AVM] No action required

@@ -2357,10 +2380,10 @@ static uint32_t cpnd_evt_proc_ckpt_sect_
                                                                /* delete the 
section */
                                                                if (gen_sec_id)
                                                                        
tmp_sec_info =
-                                                                       
cpnd_ckpt_sec_del(cp_node, &sec_info->sec_id);
+                                                                       
cpnd_ckpt_sec_del(cb, cp_node, &sec_info->sec_id);
                                                                else
                                                                        
tmp_sec_info =
-                                                                       
cpnd_ckpt_sec_del(cp_node,
+                                                                       
cpnd_ckpt_sec_del(cb, cp_node,
                                                                                   
     evt->info.sec_creatReq.
                                                                                
        sec_attri.sectionId);
@@ -2494,7 +2517,7 @@ static uint32_t cpnd_evt_proc_ckpt_sect_
        rc = cpnd_ckpt_sec_find(cp_node, &evt->info.sec_delReq.sec_id);
        if (rc == NCSCC_RC_SUCCESS) {
- sec_info = cpnd_ckpt_sec_del(cp_node, &evt->info.sec_delReq.sec_id);
+               sec_info = cpnd_ckpt_sec_del(cb, cp_node, 
&evt->info.sec_delReq.sec_id);
                /* resetting lcl_sec_id mapping */
                if (sec_info == NULL) {
                        rc = NCSCC_RC_FAILURE;
@@ -2639,7 +2662,7 @@ static uint32_t cpnd_evt_proc_nd2nd_ckpt
        }
if (cp_node->cpnd_rep_create) {
-               sec_info = cpnd_ckpt_sec_add(cp_node, 
evt->info.active_sec_creat.sec_attri.sectionId,
+               sec_info = cpnd_ckpt_sec_add(cb, cp_node, 
evt->info.active_sec_creat.sec_attri.sectionId,
                                             
evt->info.active_sec_creat.sec_attri.expirationTime, 0);
                if (sec_info == NULL) {
                        TRACE_4("cpnd ckpt sect add failed for 
sect_id:%s,ckpt_id:%llx",
@@ -2649,7 +2672,7 @@ static uint32_t cpnd_evt_proc_nd2nd_ckpt
                }
if (evt->info.active_sec_creat.init_data != NULL) {
-                       rc = cpnd_ckpt_sec_write(cp_node, sec_info, 
evt->info.active_sec_creat.init_data,
+                       rc = cpnd_ckpt_sec_write(cb, cp_node, sec_info, 
evt->info.active_sec_creat.init_data,
                                                 
evt->info.active_sec_creat.init_size, 0, 1);
                        if (rc == NCSCC_RC_FAILURE) {
                                TRACE_4("cpnd ckpt sect write failed ");
[Ramesh]: Similarly if there is a failure here, What happens to the sec_info related structs added to the DB in the above called function cpnd_ckpt_sec_add()? Also with the sec_hdr and ckpt_hdr written to shared memory?
[AVM] No action required
@@ -2774,7 +2797,7 @@ static uint32_t cpnd_evt_proc_nd2nd_ckpt
                send_evt.info.cpnd.info.sec_delete_rsp.error = 
SA_AIS_ERR_TRY_AGAIN;
                goto nd_rsp;
        }
-       sec_info = cpnd_ckpt_sec_del(cp_node, &evt->info.sec_delete_req.sec_id);
+       sec_info = cpnd_ckpt_sec_del(cb, cp_node, 
&evt->info.sec_delete_req.sec_id);
        if (sec_info == NULL) {
                if 
(m_CPND_IS_COLLOCATED_ATTR_SET(cp_node->create_attrib.creationFlags)) {
                        TRACE_4("cpnd ckpt sect del failed for 
sec_id:%s,ckpt_id:%llx",
@@ -2883,7 +2906,13 @@ static uint32_t cpnd_evt_proc_nd2nd_ckpt
                        sec_info->ckpt_sec_exptmr.ckpt_id = cp_node->ckpt_id;
if (cp_node->cpnd_rep_create) {
-                               cpnd_sec_hdr_update(sec_info, cp_node);
+                               if ((cpnd_sec_hdr_update(cb, sec_info, 
cp_node)) == NCSCC_RC_FAILURE) {
+                                       LOG_ER("cpnd sect hdr update failed");
+                                       send_evt.type = CPSV_EVT_TYPE_CPND;
+                                       send_evt.info.cpnd.type = 
CPSV_EVT_ND2ND_CKPT_SECT_EXPTMR_RSP;
+                                       
send_evt.info.cpnd.info.sec_exp_rsp.error = SA_AIS_ERR_NO_RESOURCES;
+                                       goto nd_rsp;
+                               }
                        }
                        cpnd_tmr_start(&sec_info->ckpt_sec_exptmr, 
sec_info->exp_tmr);
                }
@@ -4144,15 +4173,16 @@ static uint32_t cpnd_evt_proc_ckpt_creat
                                TRACE_4("cpnd ckpt rep create failed for 
ckpt_id:%llx,rc:%d",cp_node->ckpt_id, rc);
                                goto ckpt_replica_create_failed;
                        }
-                       rc = cpnd_ckpt_hdr_update(cp_node);
+                       rc = cpnd_ckpt_hdr_update(cb, cp_node);
                        if (rc == NCSCC_RC_FAILURE) {
-                               TRACE_4("cpnd ckpt hdr update failed for 
ckpt_id:%llx,rc:%d",cp_node->ckpt_id, rc);
+                               LOG_ER("cpnd ckpt hdr update failed for 
ckpt_id:%llx,rc:%d",cp_node->ckpt_id, rc);
+                               goto ckpt_replica_create_failed;
[Ramesh]: There shall be a separate goto to do cpnd_ckpt_replica_destroy(), to reverse the created ones done in cpnd_ckpt_replica_create().
[AVM] Done
                        }
}
                if (evt->info.ckpt_create.ckpt_info.ckpt_rep_create == true && 
cp_node->create_attrib.maxSections == 1) {
                        SaCkptSectionIdT sec_id = SA_CKPT_DEFAULT_SECTION_ID;
-                       if (cpnd_ckpt_sec_add(cp_node, &sec_id, 0, 0) == NULL) {
+                       if (cpnd_ckpt_sec_add(cb, cp_node, &sec_id, 0, 0) == 
NULL) {
                                TRACE_4("cpnd ckpt rep create failed with 
rc:%d",rc);
                                goto ckpt_replica_create_failed;
                        }
@@ -4167,9 +4197,10 @@ static uint32_t cpnd_evt_proc_ckpt_creat
                        TRACE_4("cpnd ckpt rep create failed with rc:%d",rc);
                        goto ckpt_replica_create_failed;
                }
-               rc = cpnd_ckpt_hdr_update(cp_node);
+               rc = cpnd_ckpt_hdr_update(cb, cp_node);
                if (rc == NCSCC_RC_FAILURE) {
                        TRACE_4("CPND - Ckpt Header Update Failed with 
rc:%d",rc);
+                       goto ckpt_replica_create_failed;
[Ramesh]: Similarly here too.. that there shall be a separate goto to do cpnd_ckpt_replica_destroy(), to reverse the created ones done in cpnd_ckpt_replica_create().
[AVM] Done
                }
        }
@@ -4185,7 +4216,8 @@ static uint32_t cpnd_evt_proc_ckpt_creat
        rc = cpnd_mds_msg_send(cb, NCSMDS_SVC_ID_CPND, cp_node->active_mds_dest, 
&send_evt);
if (rc != NCSCC_RC_SUCCESS) {
-               TRACE_4("cpnd remote to active mds send failed for 
cpnd_mdest_id:%"PRIu64",active_mds_dest:%"PRIu64",ckpt_id:%llx,rc%d",cb->cpnd_mdest_id, 
cp_node->active_mds_dest, cp_node->ckpt_id, rc);
+               TRACE_4("cpnd remote to active mds send failed for 
cpnd_mdest_id:%"PRIu64",active_mds_dest:%"PRIu64",ckpt_id:%llx,rc%d",
+                               cb->cpnd_mdest_id, cp_node->active_mds_dest, 
cp_node->ckpt_id, rc);
goto ckpt_replica_create_failed;
        }
diff --git a/osaf/services/saf/cpsv/cpnd/cpnd_proc.c 
b/osaf/services/saf/cpsv/cpnd/cpnd_proc.c
--- a/osaf/services/saf/cpsv/cpnd/cpnd_proc.c
+++ b/osaf/services/saf/cpsv/cpnd/cpnd_proc.c
@@ -478,10 +478,7 @@ uint32_t cpnd_ckpt_replica_create(CPND_C
        cp_node->replica_info.open.info.open.i_size =
            sizeof(CPSV_CKPT_HDR) + cp_node->create_attrib.maxSections * 
(sizeof(CPSV_SECT_HDR) +
                                                                          
cp_node->create_attrib.maxSectionSize);
-       if (cb->shm_alloc_guaranteed == true)
-               cp_node->replica_info.open.info.open.ensures_space = true;
-       else
-               cp_node->replica_info.open.info.open.ensures_space = false;
+       cp_node->replica_info.open.ensures_space = cb->shm_alloc_guaranteed;
cp_node->replica_info.open.info.open.i_offset = 0;
        cp_node->replica_info.open.info.open.i_name = buf;
@@ -642,7 +639,7 @@ int32_t cpnd_ckpt_get_lck_sec_id(CPND_CK
   *
   * Notes         : None.
   
*****************************************************************************/
-uint32_t cpnd_ckpt_sec_write(CPND_CKPT_NODE *cp_node, CPND_CKPT_SECTION_INFO
+uint32_t cpnd_ckpt_sec_write(CPND_CB *cb, CPND_CKPT_NODE *cp_node, 
CPND_CKPT_SECTION_INFO
                          *sec_info, const void *data, uint64_t size, uint64_t 
offset, uint32_t type)
  {                             /* for sync type=2 */
        uint32_t rc = NCSCC_RC_SUCCESS;
@@ -674,7 +671,7 @@ uint32_t cpnd_ckpt_sec_write(CPND_CKPT_N
        write_req.info.write.i_offset = offset;
write_req.info.write.i_write_size = size;
-
+       write_req.ensures_space = cb->shm_alloc_guaranteed;
        ncs_os_posix_shm(&write_req);
[Ramesh]: Please handle the return code of ncs_os_posix_shm(). Also better to memset write_req struct with 0.
[AVM] done
m_GET_TIME_STAMP(sec_info->lastUpdate);
@@ -687,13 +684,19 @@ uint32_t cpnd_ckpt_sec_write(CPND_CKPT_N
                }
/* SECTION HEADER UPDATE */
-               cpnd_sec_hdr_update(sec_info, cp_node);
+               if (cpnd_sec_hdr_update(cb, sec_info, cp_node) == 
NCSCC_RC_FAILURE) {
+                    LOG_ER("cpnd sect hdr update failed");
+                   rc = NCSCC_RC_FAILURE;
[Ramesh]: Don't we need to revert the updates happened through above ncs_os_posix_shm()?
[AVM] No action required
+                }
} else if ((type == 1) || (type == 3)) {
                cp_node->replica_info.mem_used -= sec_info->sec_size;
                sec_info->sec_size = size;
                cp_node->replica_info.mem_used += size;
-               cpnd_sec_hdr_update(sec_info, cp_node);
+               if ((cpnd_sec_hdr_update(cb, sec_info, cp_node)) == 
NCSCC_RC_FAILURE) {
+                       LOG_ER("cpnd sect hdr update failed");
+                       rc = NCSCC_RC_FAILURE;
+               }
        }
        TRACE_LEAVE();
        return rc;
@@ -958,7 +961,7 @@ uint32_t cpnd_ckpt_update_replica(CPND_C
                sec_info = cpnd_ckpt_sec_get_create(cp_node, &data->sec_id);
                if (sec_info == NULL) {
                        if (type == CPSV_CKPT_ACCESS_SYNC) {
-                               sec_info = cpnd_ckpt_sec_add(cp_node, 
&data->sec_id, data->expirationTime, 0);
+                               sec_info = cpnd_ckpt_sec_add(cb, cp_node, 
&data->sec_id, data->expirationTime, 0);
if (sec_info == NULL) {
                                        TRACE_4("cpnd - ckpt sect add failed , sec_id:%s 
ckpt_id:%llx",data->sec_id.id,cp_node->ckpt_id);
@@ -975,7 +978,7 @@ uint32_t cpnd_ckpt_update_replica(CPND_C
                        }
                }
- rc = cpnd_ckpt_sec_write(cp_node, sec_info, data->data, data->dataSize,
+               rc = cpnd_ckpt_sec_write(cb, cp_node, sec_info, data->data, 
data->dataSize,
                                         data->dataOffset, write_data->type);
[Ramesh]: If there is a failure here, What happens to the sec_info related structs added to the DB in the above called function cpnd_ckpt_sec_add()? Also with the sec_hdr and ckpt_hdr written to shared memory?
[AVM]  No action required
                if (rc == NCSCC_RC_FAILURE) {
                        TRACE("cpnd ckpt sect write failed for 
sec_id:%s",data->sec_id.id);
@@ -1544,7 +1547,7 @@ uint32_t cpnd_proc_sec_expiry(CPND_CB *c
                return NCSCC_RC_FAILURE;
        }
- cpnd_ckpt_sec_del(cp_node, &pSec_info->sec_id);
+       cpnd_ckpt_sec_del(cb, cp_node, &pSec_info->sec_id);
        cp_node->replica_info.shm_sec_mapping[pSec_info->lcl_sec_id] = 1;
/* send out destory to all cpnd's maintaining this ckpt */
@@ -1804,7 +1807,7 @@ cpnd_proc_getnext_section(CPND_CKPT_NODE
   * Return Values : Success / Error
  ****************************************************************************/
-uint32_t cpnd_ckpt_hdr_update(CPND_CKPT_NODE *cp_node)
+uint32_t cpnd_ckpt_hdr_update(CPND_CB *cb, CPND_CKPT_NODE *cp_node)
  {
        CPSV_CKPT_HDR ckpt_hdr;
        uint32_t rc = NCSCC_RC_SUCCESS;
@@ -1830,6 +1833,7 @@ uint32_t cpnd_ckpt_hdr_update(CPND_CKPT_
        write_req.info.write.i_from_buff = (CPSV_CKPT_HDR *)&ckpt_hdr;
        write_req.info.write.i_offset = 0;
        write_req.info.write.i_write_size = sizeof(CPSV_CKPT_HDR);
+       write_req.ensures_space = cb->shm_alloc_guaranteed;
        rc = ncs_os_posix_shm(&write_req);
return rc;
@@ -1846,7 +1850,7 @@ uint32_t cpnd_ckpt_hdr_update(CPND_CKPT_
   * Return Values : Success / Error
  
***********************************************************************************/
-uint32_t cpnd_sec_hdr_update(CPND_CKPT_SECTION_INFO *sec_info, CPND_CKPT_NODE *cp_node)
+uint32_t cpnd_sec_hdr_update(CPND_CB *cb, CPND_CKPT_SECTION_INFO *sec_info, 
CPND_CKPT_NODE *cp_node)
  {
        CPSV_SECT_HDR sec_hdr;
        uint32_t rc = NCSCC_RC_SUCCESS;
@@ -1872,6 +1876,7 @@ uint32_t cpnd_sec_hdr_update(CPND_CKPT_S
        write_req.info.write.i_offset =
            sec_info->lcl_sec_id * (sizeof(CPSV_SECT_HDR) + 
cp_node->create_attrib.maxSectionSize);
        write_req.info.write.i_write_size = sizeof(CPSV_SECT_HDR);
+       write_req.ensures_space = cb->shm_alloc_guaranteed;
        rc = ncs_os_posix_shm(&write_req);
return rc;
diff --git a/osaf/services/saf/cpsv/cpnd/cpnd_res.c 
b/osaf/services/saf/cpsv/cpnd/cpnd_res.c
--- a/osaf/services/saf/cpsv/cpnd/cpnd_res.c
+++ b/osaf/services/saf/cpsv/cpnd/cpnd_res.c
@@ -149,8 +149,8 @@ uint32_t cpnd_res_ckpt_sec_del(CPND_CKPT
   |-----------|----------|-----------|--------|----------|------------ 
|----------|---------|
  */
-uint32_t cpnd_ckpt_replica_create_res(NCS_OS_POSIX_SHM_REQ_INFO *open_req, char *buf, CPND_CKPT_NODE **cp_node,
-                                  uint32_t ref_cnt, CKPT_INFO *cp_info, bool 
shm_alloc_guaranteed)
+uint32_t cpnd_ckpt_replica_create_res(CPND_CB *cb, NCS_OS_POSIX_SHM_REQ_INFO 
*open_req, char *buf, CPND_CKPT_NODE **cp_node,
+                                  uint32_t ref_cnt, CKPT_INFO *cp_info)
  {
  /*   NCS_OS_POSIX_SHM_REQ_INFO read_req,shm_read; */
        CPSV_CKPT_HDR ckpt_hdr;
@@ -165,15 +165,12 @@ uint32_t cpnd_ckpt_replica_create_res(NC
        open_req->type = NCS_OS_POSIX_SHM_REQ_OPEN;
        open_req->info.open.i_size =
            sizeof(CPSV_CKPT_HDR) + (cp_info->maxSections * 
((sizeof(CPSV_SECT_HDR) + cp_info->maxSecSize)));
-       if (shm_alloc_guaranteed == true)
-               open_req->info.open.ensures_space = true;
-       else
-               open_req->info.open.ensures_space = false;
        open_req->info.open.i_offset = 0;
        open_req->info.open.i_name = buf;
        open_req->info.open.i_map_flags = MAP_SHARED;
        open_req->info.open.o_addr = NULL;
        open_req->info.open.i_flags = O_RDWR;
+       open_req->ensures_space = cb->shm_alloc_guaranteed;
        rc = ncs_os_posix_shm(open_req);
        if (rc != NCSCC_RC_SUCCESS) {
                LOG_ER("cpnd shm open request failed %s",buf);
@@ -362,10 +359,7 @@ void *cpnd_restart_shm_create(NCS_OS_POS
        cpnd_open_req->info.open.i_size = sizeof(CPND_SHM_VERSION) +
            sizeof(CLIENT_HDR) + (MAX_CLIENTS * sizeof(CLIENT_INFO)) + 
sizeof(CKPT_HDR) +
            (MAX_CKPTS * sizeof(CKPT_INFO));
-       if (cb->shm_alloc_guaranteed == true)
-               cpnd_open_req->info.open.ensures_space = true;
-       else
-               cpnd_open_req->info.open.ensures_space = false;
+       cpnd_open_req->ensures_space = cb->shm_alloc_guaranteed;
        cpnd_open_req->info.open.i_offset = 0;
        cpnd_open_req->info.open.i_name = buffer;
        cpnd_open_req->info.open.i_map_flags = MAP_SHARED;
@@ -529,7 +523,7 @@ void *cpnd_restart_shm_create(NCS_OS_POS
                                        memset(buf, '\0', 
CPND_MAX_REPLICA_NAME_LENGTH);
                                        strncpy(buf, cp_node->ckpt_name, 
CPND_REP_NAME_MAX_CKPT_NAME_LENGTH);
                                        sprintf(buf + strlen(buf) - 1, "_%u_%llu", 
(uint32_t)nodeid, cp_node->ckpt_id);
-                                       rc = cpnd_ckpt_replica_create_res(&ckpt_rep_open, 
buf, &cp_node, 0, &cp_info, cb->shm_alloc_guaranteed);
+                                       rc = cpnd_ckpt_replica_create_res(cb, 
&ckpt_rep_open, buf, &cp_node, 0, &cp_info);
                                        if (rc != NCSCC_RC_SUCCESS) {
                                                /*   assert(0); */
                                                TRACE_4("cpnd ckpt replica create 
failed with return value %d",rc);
@@ -1170,6 +1164,7 @@ uint32_t cpnd_restart_client_node_del(CP
        }
        clinfo_write.info.write.i_offset = cl_node->offset * 
sizeof(CLIENT_INFO);
        clinfo_write.info.write.i_write_size = sizeof(CLIENT_INFO);
+       clinfo_write.ensures_space = cb->shm_alloc_guaranteed;
        rc = ncs_os_posix_shm(&clinfo_write);
        if (rc != NCSCC_RC_SUCCESS) {
                LOG_ER("cpnd ckpt info write failed");
@@ -1582,10 +1577,7 @@ static uint32_t cpnd_shm_extended_open(C
cpnd_open_req.type = NCS_OS_POSIX_SHM_REQ_OPEN;
        cpnd_open_req.info.open.i_size = MAX_CKPTS * sizeof(CKPT_EXTENDED_INFO);
-       if (cb->shm_alloc_guaranteed == true)
-               cpnd_open_req.info.open.ensures_space = true;
-       else
-               cpnd_open_req.info.open.ensures_space = false;
+       cpnd_open_req.ensures_space = cb->shm_alloc_guaranteed;
        cpnd_open_req.info.open.i_offset = 0;
        cpnd_open_req.info.open.i_name = buffer;
        cpnd_open_req.info.open.i_map_flags = MAP_SHARED;
@@ -1738,4 +1730,4 @@ static void cpnd_destroy_shm(NCS_OS_POSI
        }
TRACE_LEAVE();
-}
\ No newline at end of file
+}
diff --git a/osaf/services/saf/cpsv/cpnd/cpnd_sec.cc 
b/osaf/services/saf/cpsv/cpnd/cpnd_sec.cc
--- a/osaf/services/saf/cpsv/cpnd/cpnd_sec.cc
+++ b/osaf/services/saf/cpsv/cpnd/cpnd_sec.cc
@@ -169,7 +169,7 @@ cpnd_ckpt_sec_find(const CPND_CKPT_NODE
   * Notes         : None.
   
*****************************************************************************/
  CPND_CKPT_SECTION_INFO *
-cpnd_ckpt_sec_del(CPND_CKPT_NODE *cp_node, SaCkptSectionIdT *id)
+cpnd_ckpt_sec_del(CPND_CB *cb, CPND_CKPT_NODE *cp_node, SaCkptSectionIdT *id)
  {
    CPND_CKPT_SECTION_INFO *sectionInfo(0);
@@ -211,17 +211,17 @@ cpnd_ckpt_sec_del(CPND_CKPT_NODE *cp_nod
      cp_node->replica_info.mem_used = cp_node->replica_info.mem_used - 
(sectionInfo->sec_size);
// UPDATE THE SECTION HEADER
-    uint32_t rc(cpnd_sec_hdr_update(sectionInfo, cp_node));
+    uint32_t rc(cpnd_sec_hdr_update(cb, sectionInfo, cp_node));
[Ramesh]: Not able to follow the flow, why a sec_hdr write is happening in cpnd_ckpt_sec_del() flow?, it suppose to delete the entry right?
[AVM] #2207 addressed this issue
      if (rc == NCSCC_RC_FAILURE) {
-      TRACE_4("cpnd sect hdr update failed");
+           LOG_ER("cpnd sect hdr update failed");
      }
// UPDATE THE CHECKPOINT HEADER
-    rc = cpnd_ckpt_hdr_update(cp_node);
+    rc = cpnd_ckpt_hdr_update(cb, cp_node);
[Ramesh]: Similarly.. why a ckpt_hdr write is happening in cpnd_ckpt_sec_del() flow?, it suppose to delete the entry right?
[AVM] #2207 addressed this issue
      if (rc == NCSCC_RC_FAILURE) {
-      TRACE_4("cpnd ckpt hdr update failed");
+           LOG_ER("cpnd ckpt hdr update failed");
      }
-  }
+    }
TRACE_LEAVE();


diff --git a/osaf/libs/common/cpsv/include/cpnd_cb.h b/osaf/libs/common/cpsv/include/cpnd_cb.h
--- a/osaf/libs/common/cpsv/include/cpnd_cb.h
+++ b/osaf/libs/common/cpsv/include/cpnd_cb.h
@@ -341,8 +341,8 @@ uint32_t cpnd_amf_register(CPND_CB *cpnd
 uint32_t cpnd_amf_deregister(CPND_CB *cpnd_cb);
 uint32_t cpnd_client_extract_bits(uint32_t bitmap_value, uint32_t *bit_position);
 uint32_t cpnd_res_ckpt_sec_del(CPND_CKPT_NODE *cp_node);
-uint32_t cpnd_ckpt_replica_create_res(NCS_OS_POSIX_SHM_REQ_INFO *open_req, char *buf, CPND_CKPT_NODE **cp_node,
-					    uint32_t ref_cnt, CKPT_INFO *cp_info, bool shm_alloc_guaranteed);
+uint32_t cpnd_ckpt_replica_create_res(CPND_CB *cb, NCS_OS_POSIX_SHM_REQ_INFO *open_req, char *buf, CPND_CKPT_NODE **cp_node,
+					    uint32_t ref_cnt, CKPT_INFO *cp_info);
 int32_t cpnd_find_free_loc(CPND_CB *cb, CPND_TYPE_INFO type);
 uint32_t cpnd_ckpt_write_header(CPND_CB *cb, uint32_t nckpts);
 uint32_t cpnd_cli_info_write_header(CPND_CB *cb, int32_t n_clients);
diff --git a/osaf/libs/common/cpsv/include/cpnd_init.h b/osaf/libs/common/cpsv/include/cpnd_init.h
--- a/osaf/libs/common/cpsv/include/cpnd_init.h
+++ b/osaf/libs/common/cpsv/include/cpnd_init.h
@@ -90,7 +90,7 @@ uint32_t cpnd_ckpt_replica_create(CPND_C
 uint32_t cpnd_ckpt_remote_cpnd_add(CPND_CKPT_NODE *cp_node, MDS_DEST mds_info);
 uint32_t cpnd_ckpt_remote_cpnd_del(CPND_CKPT_NODE *cp_node, MDS_DEST mds_info);
 int32_t cpnd_ckpt_get_lck_sec_id(CPND_CKPT_NODE *cp_node);
-uint32_t cpnd_ckpt_sec_write(CPND_CKPT_NODE *cp_node, CPND_CKPT_SECTION_INFO
+uint32_t cpnd_ckpt_sec_write(CPND_CB *cb, CPND_CKPT_NODE *cp_node, CPND_CKPT_SECTION_INFO
 			  *sec_info, const void *data, uint64_t size, uint64_t offset, uint32_t type);
 uint32_t cpnd_ckpt_sec_read(CPND_CKPT_NODE *cp_node, CPND_CKPT_SECTION_INFO
 			 *sec_info, void *data, uint64_t size, uint64_t offset);
@@ -164,7 +164,7 @@ void cpnd_evt_node_getnext(CPND_CB *cb, 
 uint32_t cpnd_evt_node_add(CPND_CB *cb, CPSV_CPND_ALL_REPL_EVT_NODE *evt_node);
 uint32_t cpnd_evt_node_del(CPND_CB *cb, CPSV_CPND_ALL_REPL_EVT_NODE *evt_node);
 CPND_CKPT_NODE *cpnd_ckpt_node_find_by_name(CPND_CB *cpnd_cb, SaConstStringT ckpt_name);
-CPND_CKPT_SECTION_INFO *cpnd_ckpt_sec_add(CPND_CKPT_NODE *cp_node, SaCkptSectionIdT *id, SaTimeT exp_time,
+CPND_CKPT_SECTION_INFO *cpnd_ckpt_sec_add(CPND_CB *cb, CPND_CKPT_NODE *cp_node, SaCkptSectionIdT *id, SaTimeT exp_time,
 					  uint32_t gen_flag);
 void cpnd_evt_backup_queue_add(CPND_CKPT_NODE *cp_node, CPND_EVT *evt);
 uint32_t cpnd_ckpt_node_tree_init(CPND_CB *cb);
@@ -176,8 +176,8 @@ void cpnd_client_node_tree_cleanup(CPND_
 void cpnd_client_node_tree_destroy(CPND_CB *cb);
 void cpnd_allrepl_write_evt_node_tree_cleanup(CPND_CB *cb);
 void cpnd_allrepl_write_evt_node_tree_destroy(CPND_CB *cb);
-uint32_t cpnd_sec_hdr_update(CPND_CKPT_SECTION_INFO *pSecPtr, CPND_CKPT_NODE *cp_node);
-uint32_t cpnd_ckpt_hdr_update(CPND_CKPT_NODE *cp_node);
+uint32_t cpnd_sec_hdr_update(CPND_CB *cb, CPND_CKPT_SECTION_INFO *pSecPtr, CPND_CKPT_NODE *cp_node);
+uint32_t cpnd_ckpt_hdr_update(CPND_CB *cb, CPND_CKPT_NODE *cp_node);
 void cpnd_ckpt_node_destroy(CPND_CB *cb, CPND_CKPT_NODE *cp_node);
 uint32_t cpnd_get_slot_sub_slot_id_from_mds_dest(MDS_DEST dest);
 uint32_t cpnd_get_slot_sub_slot_id_from_node_id(NCS_NODE_ID i_node_id);
diff --git a/osaf/libs/common/cpsv/include/cpnd_sec.h b/osaf/libs/common/cpsv/include/cpnd_sec.h
--- a/osaf/libs/common/cpsv/include/cpnd_sec.h
+++ b/osaf/libs/common/cpsv/include/cpnd_sec.h
@@ -39,7 +39,7 @@ CPND_CKPT_SECTION_INFO *
 cpnd_ckpt_sec_get_create(const CPND_CKPT_NODE *, const SaCkptSectionIdT *);
 
 CPND_CKPT_SECTION_INFO *
-cpnd_ckpt_sec_del(CPND_CKPT_NODE *, SaCkptSectionIdT *);
+cpnd_ckpt_sec_del(CPND_CB *cb, CPND_CKPT_NODE *, SaCkptSectionIdT *);
 
 CPND_CKPT_SECTION_INFO *
 cpnd_get_sect_with_id(const CPND_CKPT_NODE *, uint32_t lcl_sec_id);
diff --git a/osaf/libs/core/include/ncs_osprm.h b/osaf/libs/core/include/ncs_osprm.h
--- a/osaf/libs/core/include/ncs_osprm.h
+++ b/osaf/libs/core/include/ncs_osprm.h
@@ -564,7 +564,6 @@ typedef struct ncs_os_posix_shm_req_open
   uint32_t i_flags;
   uint32_t i_map_flags;
   uint64_t i_size;
-  bool ensures_space;
   uint64_t i_offset;
   void *o_addr;
   int32_t o_fd;
@@ -600,6 +599,7 @@ typedef struct ncs_os_posix_shm_req_writ
 
 typedef struct ncs_shm_req_info {
   NCS_OS_POSIX_SHM_REQ_TYPE type;
+  bool ensures_space;
 
   union {
     NCS_OS_POSIX_SHM_REQ_OPEN_INFO open;
diff --git a/osaf/services/saf/cpsv/cpnd/cpnd_db.c b/osaf/services/saf/cpsv/cpnd/cpnd_db.c
--- a/osaf/services/saf/cpsv/cpnd/cpnd_db.c
+++ b/osaf/services/saf/cpsv/cpnd/cpnd_db.c
@@ -384,7 +384,7 @@ uint32_t cpnd_evt_node_del(CPND_CB *cb, 
  *
  * Notes         : None.
  *****************************************************************************/
-CPND_CKPT_SECTION_INFO *cpnd_ckpt_sec_add(CPND_CKPT_NODE *cp_node, SaCkptSectionIdT *id,
+CPND_CKPT_SECTION_INFO *cpnd_ckpt_sec_add(CPND_CB *cb, CPND_CKPT_NODE *cp_node, SaCkptSectionIdT *id,
 					  SaTimeT exp_time, uint32_t gen_flag)
 {
 	CPND_CKPT_SECTION_INFO *pSecPtr = NULL;
@@ -453,15 +453,15 @@ CPND_CKPT_SECTION_INFO *cpnd_ckpt_sec_ad
 	cp_node->replica_info.n_secs++;
 
 	/* UPDATE THE SECTION HEADER */
-	rc = cpnd_sec_hdr_update(pSecPtr, cp_node);
+	rc = cpnd_sec_hdr_update(cb, pSecPtr, cp_node);
 	if (rc == NCSCC_RC_FAILURE) {
-		LOG_NO("cpnd sect hdr update failed");
+		LOG_ER("cpnd sect hdr update failed");
 		goto section_hdr_update_fails;
 	}
 	/* UPDATE THE CHECKPOINT HEADER */
-	rc = cpnd_ckpt_hdr_update(cp_node);
+	rc = cpnd_ckpt_hdr_update(cb, cp_node);
 	if (rc == NCSCC_RC_FAILURE) {
-		LOG_NO("cpnd ckpt hdr update failed");
+		LOG_ER("cpnd ckpt hdr update failed");
 		goto ckpt_hdr_update_fails;
 	}
 
@@ -470,7 +470,7 @@ CPND_CKPT_SECTION_INFO *cpnd_ckpt_sec_ad
 
  section_hdr_update_fails:
  ckpt_hdr_update_fails:
-	cpnd_ckpt_sec_del(cp_node, id);
+	cpnd_ckpt_sec_del(cb, cp_node, id);
 
  section_add_fails:
 	if (pSecPtr->sec_id.id != NULL) 
diff --git a/osaf/services/saf/cpsv/cpnd/cpnd_evt.c b/osaf/services/saf/cpsv/cpnd/cpnd_evt.c
--- a/osaf/services/saf/cpsv/cpnd/cpnd_evt.c
+++ b/osaf/services/saf/cpsv/cpnd/cpnd_evt.c
@@ -834,10 +834,12 @@ static uint32_t cpnd_evt_proc_ckpt_open(
 			}
 
 			/* UPDATE THE CHECKPOINT HEADER */
-			rc = cpnd_ckpt_hdr_update(cp_node);
+			rc = cpnd_ckpt_hdr_update(cb, cp_node);
 			if (rc == NCSCC_RC_FAILURE) {
-				TRACE_4("cpnd ckpt hdr update failed ckpt_name:%s,client_hdl:%llx",
+				LOG_ER("cpnd ckpt hdr update failed ckpt_name:%s,client_hdl:%llx",
 						ckpt_name, client_hdl);
+				send_evt.info.cpa.info.openRsp.error = SA_AIS_ERR_NO_RESOURCES;
+				goto ckpt_shm_node_free_error;
 			}
 		}
 
@@ -861,7 +863,7 @@ static uint32_t cpnd_evt_proc_ckpt_open(
 		    cp_node->create_attrib.maxSections == 1) {
 
 			SaCkptSectionIdT sec_id = SA_CKPT_DEFAULT_SECTION_ID;
-			if(cpnd_ckpt_sec_add(cp_node, &sec_id, 0, 0) == NULL) {
+			if(cpnd_ckpt_sec_add(cb, cp_node, &sec_id, 0, 0) == NULL) {
 				TRACE_4("cpnd ckpt rep create failed with rc:%d",rc);
 				goto ckpt_shm_node_free_error;
 			}
@@ -1275,7 +1277,12 @@ static uint32_t cpnd_evt_proc_ckpt_unlin
 		cp_node->ckpt_name = strdup("");
 
 		if (cp_node->cpnd_rep_create) {
-			rc = cpnd_ckpt_hdr_update(cp_node);
+			rc = cpnd_ckpt_hdr_update(cb, cp_node);
+			if (rc == NCSCC_RC_FAILURE) {
+				error = SA_AIS_ERR_NO_RESOURCES;
+				LOG_ER("cpnd ckpt hdr update failed for ckpt_id:%llx,rc:%d",cp_node->ckpt_id, rc);
+				goto agent_rsp;
+                        }
 
 		}
 		TRACE_4("cpnd proc ckpt unlink set for ckpt_id:%llx",cp_node->ckpt_id);
@@ -1484,7 +1491,11 @@ static uint32_t cpnd_evt_proc_ckpt_rdset
 	cp_node->is_rdset = true;
 	/*Non-collocated which does not have replica */
 	if (cp_node->cpnd_rep_create)
-		cpnd_ckpt_hdr_update(cp_node);
+		 if (cpnd_ckpt_hdr_update(cb, cp_node) == NCSCC_RC_FAILURE) {
+			 LOG_ER("cpnd sect hdr update failed");
+			 send_evt.info.cpa.info.rdsetRsp.error = SA_AIS_ERR_NO_RESOURCES;
+			 goto out_evt_free;
+		 }
 
 	send_evt.info.cpa.info.rdsetRsp.error = SA_AIS_OK;
 
@@ -1631,10 +1642,13 @@ static uint32_t cpnd_evt_proc_ckpt_arep_
 		}
 	}
 
-	rc = cpnd_ckpt_hdr_update(cp_node);
-
+	rc = cpnd_ckpt_hdr_update(cb, cp_node);
+	if (rc == NCSCC_RC_FAILURE) {
+		LOG_ER("cpnd  ckpt hdr update failed");
+		send_evt.info.cpa.info.arsetRsp.error = SA_AIS_ERR_NO_RESOURCES;
+		goto agent_rsp;
+	} 
 	send_evt.info.cpa.info.arsetRsp.error = SA_AIS_OK;
-	goto agent_rsp;
 
  agent_rsp:
 	send_evt.type = CPSV_EVT_TYPE_CPA;
@@ -2082,7 +2096,11 @@ static uint32_t cpnd_evt_proc_ckpt_sect_
 			sec_info->ckpt_sec_exptmr.uarg = cb->cpnd_cb_hdl_id;
 			sec_info->ckpt_sec_exptmr.lcl_sec_id = sec_info->lcl_sec_id;
 
-			cpnd_sec_hdr_update(sec_info, cp_node);
+			if (cpnd_sec_hdr_update(cb, sec_info, cp_node) == NCSCC_RC_FAILURE) {
+				LOG_ER("cpnd sect hdr update failed");
+				send_evt.info.cpa.info.sec_exptmr_rsp.error = SA_AIS_ERR_NO_RESOURCES;
+				goto agent_rsp;
+			}
 
 			cpnd_tmr_start(&sec_info->ckpt_sec_exptmr,
 				       m_CPSV_CONVERT_SATIME_TEN_MILLI_SEC(sec_info->exp_tmr));
@@ -2108,7 +2126,11 @@ static uint32_t cpnd_evt_proc_ckpt_sect_
 		}
 		if (cp_node->cpnd_rep_create) {
 			sec_info->exp_tmr = evt->info.sec_expset.exp_time;
-			cpnd_sec_hdr_update(sec_info, cp_node);
+			if (cpnd_sec_hdr_update(cb, sec_info, cp_node) == NCSCC_RC_FAILURE) {
+				LOG_ER("cpnd sect hdr update failed");
+				send_evt.info.cpa.info.sec_exptmr_rsp.error = SA_AIS_ERR_NO_RESOURCES;
+				goto agent_rsp;
+			}
 		}
 	}
 
@@ -2237,11 +2259,11 @@ static uint32_t cpnd_evt_proc_ckpt_sect_
 
 	if (cp_node->cpnd_rep_create) {
 		if (gen_sec_id)
-			sec_info = cpnd_ckpt_sec_add(cp_node, evt->info.sec_creatReq.sec_attri.sectionId,
+			sec_info = cpnd_ckpt_sec_add(cb, cp_node, evt->info.sec_creatReq.sec_attri.sectionId,
 						     evt->info.sec_creatReq.sec_attri.expirationTime, 1);
 
 		else
-			sec_info = cpnd_ckpt_sec_add(cp_node, evt->info.sec_creatReq.sec_attri.sectionId,
+			sec_info = cpnd_ckpt_sec_add(cb, cp_node, evt->info.sec_creatReq.sec_attri.sectionId,
 						     evt->info.sec_creatReq.sec_attri.expirationTime, 0);
 
 		if (sec_info == NULL) {
@@ -2255,10 +2277,11 @@ static uint32_t cpnd_evt_proc_ckpt_sect_
 
 		if ((evt->info.sec_creatReq.init_data != NULL) && (evt->info.sec_creatReq.init_size != 0)) {
 
-			rc = cpnd_ckpt_sec_write(cp_node, sec_info, evt->info.sec_creatReq.init_data,
+			rc = cpnd_ckpt_sec_write(cb, cp_node, sec_info, evt->info.sec_creatReq.init_data,
 						 evt->info.sec_creatReq.init_size, 0, 1);
 			if (rc == NCSCC_RC_FAILURE) {
-				TRACE_4("cpnd ckpt sect write failed for section_is:%s,ckpt_id:%llx",sec_info->sec_id.id, cp_node->ckpt_id);
+				TRACE_4("cpnd ckpt sect write failed for section_is:%s,ckpt_id:%llx",
+						sec_info->sec_id.id, cp_node->ckpt_id);
 				send_evt.type = CPSV_EVT_TYPE_CPA;
 				send_evt.info.cpa.type = CPA_EVT_ND2A_SEC_CREATE_RSP;
 				send_evt.info.cpa.info.sec_creat_rsp.error = SA_AIS_ERR_NO_RESOURCES;
@@ -2357,10 +2380,10 @@ static uint32_t cpnd_evt_proc_ckpt_sect_
 								/* delete the section */
 								if (gen_sec_id)
 									tmp_sec_info =
-								    	cpnd_ckpt_sec_del(cp_node, &sec_info->sec_id);
+								    	cpnd_ckpt_sec_del(cb, cp_node, &sec_info->sec_id);
 								else
 									tmp_sec_info =
-								    	cpnd_ckpt_sec_del(cp_node,
+								    	cpnd_ckpt_sec_del(cb, cp_node,
 										      	evt->info.sec_creatReq.
 										      	sec_attri.sectionId);
 
@@ -2494,7 +2517,7 @@ static uint32_t cpnd_evt_proc_ckpt_sect_
 	rc = cpnd_ckpt_sec_find(cp_node, &evt->info.sec_delReq.sec_id);
 	if (rc == NCSCC_RC_SUCCESS) {
 
-		sec_info = cpnd_ckpt_sec_del(cp_node, &evt->info.sec_delReq.sec_id);
+		sec_info = cpnd_ckpt_sec_del(cb, cp_node, &evt->info.sec_delReq.sec_id);
 		/* resetting lcl_sec_id mapping */
 		if (sec_info == NULL) {
 			rc = NCSCC_RC_FAILURE;
@@ -2639,7 +2662,7 @@ static uint32_t cpnd_evt_proc_nd2nd_ckpt
 	}
 
 	if (cp_node->cpnd_rep_create) {
-		sec_info = cpnd_ckpt_sec_add(cp_node, evt->info.active_sec_creat.sec_attri.sectionId,
+		sec_info = cpnd_ckpt_sec_add(cb, cp_node, evt->info.active_sec_creat.sec_attri.sectionId,
 					     evt->info.active_sec_creat.sec_attri.expirationTime, 0);
 		if (sec_info == NULL) {
 			TRACE_4("cpnd ckpt sect add failed for sect_id:%s,ckpt_id:%llx",
@@ -2649,7 +2672,7 @@ static uint32_t cpnd_evt_proc_nd2nd_ckpt
 		}
 
 		if (evt->info.active_sec_creat.init_data != NULL) {
-			rc = cpnd_ckpt_sec_write(cp_node, sec_info, evt->info.active_sec_creat.init_data,
+			rc = cpnd_ckpt_sec_write(cb, cp_node, sec_info, evt->info.active_sec_creat.init_data,
 						 evt->info.active_sec_creat.init_size, 0, 1);
 			if (rc == NCSCC_RC_FAILURE) {
 				TRACE_4("cpnd ckpt sect write failed ");
@@ -2774,7 +2797,7 @@ static uint32_t cpnd_evt_proc_nd2nd_ckpt
 		send_evt.info.cpnd.info.sec_delete_rsp.error = SA_AIS_ERR_TRY_AGAIN;
 		goto nd_rsp;
 	}
-	sec_info = cpnd_ckpt_sec_del(cp_node, &evt->info.sec_delete_req.sec_id);
+	sec_info = cpnd_ckpt_sec_del(cb, cp_node, &evt->info.sec_delete_req.sec_id);
 	if (sec_info == NULL) {
 		if (m_CPND_IS_COLLOCATED_ATTR_SET(cp_node->create_attrib.creationFlags)) {
 			TRACE_4("cpnd ckpt sect del failed for sec_id:%s,ckpt_id:%llx",
@@ -2883,7 +2906,13 @@ static uint32_t cpnd_evt_proc_nd2nd_ckpt
 			sec_info->ckpt_sec_exptmr.ckpt_id = cp_node->ckpt_id;
 
 			if (cp_node->cpnd_rep_create) {
-				cpnd_sec_hdr_update(sec_info, cp_node);
+				if ((cpnd_sec_hdr_update(cb, sec_info, cp_node)) == NCSCC_RC_FAILURE) {
+					LOG_ER("cpnd sect hdr update failed");
+					send_evt.type = CPSV_EVT_TYPE_CPND;
+					send_evt.info.cpnd.type = CPSV_EVT_ND2ND_CKPT_SECT_EXPTMR_RSP;
+					send_evt.info.cpnd.info.sec_exp_rsp.error = SA_AIS_ERR_NO_RESOURCES;
+					goto nd_rsp;
+				}
 			}
 			cpnd_tmr_start(&sec_info->ckpt_sec_exptmr, sec_info->exp_tmr);
 		}
@@ -4144,17 +4173,18 @@ static uint32_t cpnd_evt_proc_ckpt_creat
 				TRACE_4("cpnd ckpt rep create failed for ckpt_id:%llx,rc:%d",cp_node->ckpt_id, rc);
 				goto ckpt_replica_create_failed;
 			}
-			rc = cpnd_ckpt_hdr_update(cp_node);
+			rc = cpnd_ckpt_hdr_update(cb, cp_node);
 			if (rc == NCSCC_RC_FAILURE) {
-				TRACE_4("cpnd ckpt hdr update failed for ckpt_id:%llx,rc:%d",cp_node->ckpt_id, rc);
+				LOG_ER("cpnd ckpt hdr update failed for ckpt_id:%llx,rc:%d",cp_node->ckpt_id, rc);
+				goto cpnd_ckpt_replica_destroy;
 			}
 
 		}
 		if (evt->info.ckpt_create.ckpt_info.ckpt_rep_create == true && cp_node->create_attrib.maxSections == 1) {
 			SaCkptSectionIdT sec_id = SA_CKPT_DEFAULT_SECTION_ID;
-			if (cpnd_ckpt_sec_add(cp_node, &sec_id, 0, 0) == NULL) {
+			if (cpnd_ckpt_sec_add(cb, cp_node, &sec_id, 0, 0) == NULL) {
 				TRACE_4("cpnd ckpt rep create failed with rc:%d",rc);
-				goto ckpt_replica_create_failed;
+				goto cpnd_ckpt_replica_destroy;
 			}
 				
 		}
@@ -4167,9 +4197,10 @@ static uint32_t cpnd_evt_proc_ckpt_creat
 			TRACE_4("cpnd ckpt rep create failed with rc:%d",rc);
 			goto ckpt_replica_create_failed;
 		}
-		rc = cpnd_ckpt_hdr_update(cp_node);
+		rc = cpnd_ckpt_hdr_update(cb, cp_node);
 		if (rc == NCSCC_RC_FAILURE) {
 			TRACE_4("CPND - Ckpt Header Update Failed with rc:%d",rc);
+			goto cpnd_ckpt_replica_destroy;
 		}
 	}
 
@@ -4185,7 +4216,8 @@ static uint32_t cpnd_evt_proc_ckpt_creat
 	rc = cpnd_mds_msg_send(cb, NCSMDS_SVC_ID_CPND, cp_node->active_mds_dest, &send_evt);
 
 	if (rc != NCSCC_RC_SUCCESS) {
-		TRACE_4("cpnd remote to active mds send failed for cpnd_mdest_id:%"PRIu64",active_mds_dest:%"PRIu64",ckpt_id:%llx,rc%d",cb->cpnd_mdest_id, cp_node->active_mds_dest, cp_node->ckpt_id, rc);
+		TRACE_4("cpnd remote to active mds send failed for :%"PRIu64",active_mds_dest:%"PRIu64",ckpt_id:%llx,rc%d",
+				cb->cpnd_mdest_id, cp_node->active_mds_dest, cp_node->ckpt_id, rc);
 
 		goto ckpt_replica_create_failed;
 	}
@@ -4194,6 +4226,10 @@ static uint32_t cpnd_evt_proc_ckpt_creat
 	TRACE_LEAVE();
 	return rc;
 
+ cpnd_ckpt_replica_destroy:
+	SaAisErrorT error;
+	cpnd_ckpt_replica_destroy(cb, cp_node, &error);
+	TRACE_4("cpnd ckpt rep destroy  failed with rc:%d", error);
  ckpt_replica_create_failed:
 	cpnd_ckpt_node_destroy(cb, cp_node);
 
diff --git a/osaf/services/saf/cpsv/cpnd/cpnd_proc.c b/osaf/services/saf/cpsv/cpnd/cpnd_proc.c
--- a/osaf/services/saf/cpsv/cpnd/cpnd_proc.c
+++ b/osaf/services/saf/cpsv/cpnd/cpnd_proc.c
@@ -478,10 +478,7 @@ uint32_t cpnd_ckpt_replica_create(CPND_C
 	cp_node->replica_info.open.info.open.i_size =
 	    sizeof(CPSV_CKPT_HDR) + cp_node->create_attrib.maxSections * (sizeof(CPSV_SECT_HDR) +
 									  cp_node->create_attrib.maxSectionSize);
-	if (cb->shm_alloc_guaranteed == true)
-		cp_node->replica_info.open.info.open.ensures_space = true;
-	else
-		cp_node->replica_info.open.info.open.ensures_space = false;
+	cp_node->replica_info.open.ensures_space = cb->shm_alloc_guaranteed;
 
 	cp_node->replica_info.open.info.open.i_offset = 0;
 	cp_node->replica_info.open.info.open.i_name = buf;
@@ -642,7 +639,7 @@ int32_t cpnd_ckpt_get_lck_sec_id(CPND_CK
  *
  * Notes         : None.
  *****************************************************************************/
-uint32_t cpnd_ckpt_sec_write(CPND_CKPT_NODE *cp_node, CPND_CKPT_SECTION_INFO
+uint32_t cpnd_ckpt_sec_write(CPND_CB *cb, CPND_CKPT_NODE *cp_node, CPND_CKPT_SECTION_INFO
 			  *sec_info, const void *data, uint64_t size, uint64_t offset, uint32_t type)
 {				/* for sync type=2 */
 	uint32_t rc = NCSCC_RC_SUCCESS;
@@ -674,8 +671,11 @@ uint32_t cpnd_ckpt_sec_write(CPND_CKPT_N
 	write_req.info.write.i_offset = offset;
 
 	write_req.info.write.i_write_size = size;
-
-	ncs_os_posix_shm(&write_req);
+	write_req.ensures_space = cb->shm_alloc_guaranteed;
+	if (ncs_os_posix_shm(&write_req) == NCSCC_RC_FAILURE) {
+		LOG_ER("shm write failed for cpnd_ckpt_sec_write");
+		return NCSCC_RC_FAILURE;
+	}
 
 	m_GET_TIME_STAMP(sec_info->lastUpdate);
 
@@ -687,13 +687,19 @@ uint32_t cpnd_ckpt_sec_write(CPND_CKPT_N
 		}
 
 		/* SECTION HEADER UPDATE */
-		cpnd_sec_hdr_update(sec_info, cp_node);
+		if (cpnd_sec_hdr_update(cb, sec_info, cp_node) == NCSCC_RC_FAILURE) {
+                    LOG_ER("cpnd sect hdr update failed");
+		    rc = NCSCC_RC_FAILURE;
+                }
 
 	} else if ((type == 1) || (type == 3)) {
 		cp_node->replica_info.mem_used -= sec_info->sec_size;
 		sec_info->sec_size = size;
 		cp_node->replica_info.mem_used += size;
-		cpnd_sec_hdr_update(sec_info, cp_node);
+		if ((cpnd_sec_hdr_update(cb, sec_info, cp_node)) == NCSCC_RC_FAILURE) {
+			LOG_ER("cpnd sect hdr update failed");
+			rc = NCSCC_RC_FAILURE;
+		}
 	}
 	TRACE_LEAVE();
 	return rc;
@@ -958,7 +964,7 @@ uint32_t cpnd_ckpt_update_replica(CPND_C
 		sec_info = cpnd_ckpt_sec_get_create(cp_node, &data->sec_id);
 		if (sec_info == NULL) {
 			if (type == CPSV_CKPT_ACCESS_SYNC) {
-				sec_info = cpnd_ckpt_sec_add(cp_node, &data->sec_id, data->expirationTime, 0);
+				sec_info = cpnd_ckpt_sec_add(cb, cp_node, &data->sec_id, data->expirationTime, 0);
 
 				if (sec_info == NULL) {
 					TRACE_4("cpnd - ckpt sect add failed , sec_id:%s ckpt_id:%llx",data->sec_id.id,cp_node->ckpt_id);
@@ -975,7 +981,7 @@ uint32_t cpnd_ckpt_update_replica(CPND_C
 			}
 		}
 
-		rc = cpnd_ckpt_sec_write(cp_node, sec_info, data->data, data->dataSize,
+		rc = cpnd_ckpt_sec_write(cb, cp_node, sec_info, data->data, data->dataSize,
 					 data->dataOffset, write_data->type);
 		if (rc == NCSCC_RC_FAILURE) {
 			TRACE("cpnd ckpt sect write failed for sec_id:%s",data->sec_id.id);
@@ -1544,7 +1550,7 @@ uint32_t cpnd_proc_sec_expiry(CPND_CB *c
 		return NCSCC_RC_FAILURE;
 	}
 
-	cpnd_ckpt_sec_del(cp_node, &pSec_info->sec_id);
+	cpnd_ckpt_sec_del(cb, cp_node, &pSec_info->sec_id);
 	cp_node->replica_info.shm_sec_mapping[pSec_info->lcl_sec_id] = 1;
 
 	/* send out destory to all cpnd's maintaining this ckpt */
@@ -1804,7 +1810,7 @@ cpnd_proc_getnext_section(CPND_CKPT_NODE
  * Return Values : Success / Error
 ****************************************************************************/
 
-uint32_t cpnd_ckpt_hdr_update(CPND_CKPT_NODE *cp_node)
+uint32_t cpnd_ckpt_hdr_update(CPND_CB *cb, CPND_CKPT_NODE *cp_node)
 {
 	CPSV_CKPT_HDR ckpt_hdr;
 	uint32_t rc = NCSCC_RC_SUCCESS;
@@ -1830,6 +1836,7 @@ uint32_t cpnd_ckpt_hdr_update(CPND_CKPT_
 	write_req.info.write.i_from_buff = (CPSV_CKPT_HDR *)&ckpt_hdr;
 	write_req.info.write.i_offset = 0;
 	write_req.info.write.i_write_size = sizeof(CPSV_CKPT_HDR);
+	write_req.ensures_space = cb->shm_alloc_guaranteed;
 	rc = ncs_os_posix_shm(&write_req);
 
 	return rc;
@@ -1846,7 +1853,7 @@ uint32_t cpnd_ckpt_hdr_update(CPND_CKPT_
  * Return Values : Success / Error
 ***********************************************************************************/
 
-uint32_t cpnd_sec_hdr_update(CPND_CKPT_SECTION_INFO *sec_info, CPND_CKPT_NODE *cp_node)
+uint32_t cpnd_sec_hdr_update(CPND_CB *cb, CPND_CKPT_SECTION_INFO *sec_info, CPND_CKPT_NODE *cp_node)
 {
 	CPSV_SECT_HDR sec_hdr;
 	uint32_t rc = NCSCC_RC_SUCCESS;
@@ -1872,6 +1879,7 @@ uint32_t cpnd_sec_hdr_update(CPND_CKPT_S
 	write_req.info.write.i_offset =
 	    sec_info->lcl_sec_id * (sizeof(CPSV_SECT_HDR) + cp_node->create_attrib.maxSectionSize);
 	write_req.info.write.i_write_size = sizeof(CPSV_SECT_HDR);
+	write_req.ensures_space = cb->shm_alloc_guaranteed;
 	rc = ncs_os_posix_shm(&write_req);
 
 	return rc;
diff --git a/osaf/services/saf/cpsv/cpnd/cpnd_res.c b/osaf/services/saf/cpsv/cpnd/cpnd_res.c
--- a/osaf/services/saf/cpsv/cpnd/cpnd_res.c
+++ b/osaf/services/saf/cpsv/cpnd/cpnd_res.c
@@ -149,8 +149,8 @@ uint32_t cpnd_res_ckpt_sec_del(CPND_CKPT
  |-----------|----------|-----------|--------|----------|------------ |----------|---------|        
 */
 
-uint32_t cpnd_ckpt_replica_create_res(NCS_OS_POSIX_SHM_REQ_INFO *open_req, char *buf, CPND_CKPT_NODE **cp_node,
-				   uint32_t ref_cnt, CKPT_INFO *cp_info, bool shm_alloc_guaranteed)
+uint32_t cpnd_ckpt_replica_create_res(CPND_CB *cb, NCS_OS_POSIX_SHM_REQ_INFO *open_req, char *buf, CPND_CKPT_NODE **cp_node,
+				   uint32_t ref_cnt, CKPT_INFO *cp_info)
 {
 /*   NCS_OS_POSIX_SHM_REQ_INFO read_req,shm_read; */
 	CPSV_CKPT_HDR ckpt_hdr;
@@ -165,15 +165,12 @@ uint32_t cpnd_ckpt_replica_create_res(NC
 	open_req->type = NCS_OS_POSIX_SHM_REQ_OPEN;
 	open_req->info.open.i_size =
 	    sizeof(CPSV_CKPT_HDR) + (cp_info->maxSections * ((sizeof(CPSV_SECT_HDR) + cp_info->maxSecSize)));
-	if (shm_alloc_guaranteed == true)
-		open_req->info.open.ensures_space = true;
-	else
-		open_req->info.open.ensures_space = false;
 	open_req->info.open.i_offset = 0;
 	open_req->info.open.i_name = buf;
 	open_req->info.open.i_map_flags = MAP_SHARED;
 	open_req->info.open.o_addr = NULL;
 	open_req->info.open.i_flags = O_RDWR;
+	open_req->ensures_space = cb->shm_alloc_guaranteed;
 	rc = ncs_os_posix_shm(open_req);
 	if (rc != NCSCC_RC_SUCCESS) {
 		LOG_ER("cpnd shm open request failed %s",buf);
@@ -362,10 +359,7 @@ void *cpnd_restart_shm_create(NCS_OS_POS
 	cpnd_open_req->info.open.i_size = sizeof(CPND_SHM_VERSION) +
 	    sizeof(CLIENT_HDR) + (MAX_CLIENTS * sizeof(CLIENT_INFO)) + sizeof(CKPT_HDR) +
 	    (MAX_CKPTS * sizeof(CKPT_INFO));
-	if (cb->shm_alloc_guaranteed == true)
-		cpnd_open_req->info.open.ensures_space = true;
-	else
-		cpnd_open_req->info.open.ensures_space = false; 
+	cpnd_open_req->ensures_space = cb->shm_alloc_guaranteed; 
 	cpnd_open_req->info.open.i_offset = 0;
 	cpnd_open_req->info.open.i_name = buffer;
 	cpnd_open_req->info.open.i_map_flags = MAP_SHARED;
@@ -529,7 +523,7 @@ void *cpnd_restart_shm_create(NCS_OS_POS
 					memset(buf, '\0', CPND_MAX_REPLICA_NAME_LENGTH);
 					strncpy(buf, cp_node->ckpt_name, CPND_REP_NAME_MAX_CKPT_NAME_LENGTH);
 					sprintf(buf + strlen(buf) - 1, "_%u_%llu", (uint32_t)nodeid, cp_node->ckpt_id);
-					rc = cpnd_ckpt_replica_create_res(&ckpt_rep_open, buf, &cp_node, 0, &cp_info, cb->shm_alloc_guaranteed);
+					rc = cpnd_ckpt_replica_create_res(cb, &ckpt_rep_open, buf, &cp_node, 0, &cp_info);
 					if (rc != NCSCC_RC_SUCCESS) {
 						/*   assert(0); */
 						TRACE_4("cpnd ckpt replica create failed with return value %d",rc);
@@ -1170,6 +1164,7 @@ uint32_t cpnd_restart_client_node_del(CP
 	}
 	clinfo_write.info.write.i_offset = cl_node->offset * sizeof(CLIENT_INFO);
 	clinfo_write.info.write.i_write_size = sizeof(CLIENT_INFO);
+	clinfo_write.ensures_space = cb->shm_alloc_guaranteed;
 	rc = ncs_os_posix_shm(&clinfo_write);
 	if (rc != NCSCC_RC_SUCCESS) {
 		LOG_ER("cpnd ckpt info write failed"); 
@@ -1582,10 +1577,7 @@ static uint32_t cpnd_shm_extended_open(C
 
 	cpnd_open_req.type = NCS_OS_POSIX_SHM_REQ_OPEN;
 	cpnd_open_req.info.open.i_size = MAX_CKPTS * sizeof(CKPT_EXTENDED_INFO);
-	if (cb->shm_alloc_guaranteed == true)
-		cpnd_open_req.info.open.ensures_space = true;
-	else
-		cpnd_open_req.info.open.ensures_space = false;
+	cpnd_open_req.ensures_space = cb->shm_alloc_guaranteed;
 	cpnd_open_req.info.open.i_offset = 0;
 	cpnd_open_req.info.open.i_name = buffer;
 	cpnd_open_req.info.open.i_map_flags = MAP_SHARED;
@@ -1738,4 +1730,5 @@ static void cpnd_destroy_shm(NCS_OS_POSI
 	}
 
 	TRACE_LEAVE();
-}
\ No newline at end of file
+}
+
diff --git a/osaf/services/saf/cpsv/cpnd/cpnd_sec.cc b/osaf/services/saf/cpsv/cpnd/cpnd_sec.cc
--- a/osaf/services/saf/cpsv/cpnd/cpnd_sec.cc
+++ b/osaf/services/saf/cpsv/cpnd/cpnd_sec.cc
@@ -169,7 +169,7 @@ cpnd_ckpt_sec_find(const CPND_CKPT_NODE 
  * Notes         : None.
  *****************************************************************************/
 CPND_CKPT_SECTION_INFO *
-cpnd_ckpt_sec_del(CPND_CKPT_NODE *cp_node, SaCkptSectionIdT *id)
+cpnd_ckpt_sec_del(CPND_CB *cb, CPND_CKPT_NODE *cp_node, SaCkptSectionIdT *id)
 {
   CPND_CKPT_SECTION_INFO *sectionInfo(0);
 
@@ -211,15 +211,15 @@ cpnd_ckpt_sec_del(CPND_CKPT_NODE *cp_nod
     cp_node->replica_info.mem_used = cp_node->replica_info.mem_used - (sectionInfo->sec_size);
 
     // UPDATE THE SECTION HEADER
-    uint32_t rc(cpnd_sec_hdr_update(sectionInfo, cp_node));
+    uint32_t rc(cpnd_sec_hdr_update(cb, sectionInfo, cp_node));
     if (rc == NCSCC_RC_FAILURE) {
-      TRACE_4("cpnd sect hdr update failed");
+	    LOG_ER("cpnd sect hdr update failed");
     }
 
     // UPDATE THE CHECKPOINT HEADER
-    rc = cpnd_ckpt_hdr_update(cp_node);
+    rc = cpnd_ckpt_hdr_update(cb, cp_node);
     if (rc == NCSCC_RC_FAILURE) {
-      TRACE_4("cpnd ckpt hdr update failed");
+	    LOG_ER("cpnd ckpt hdr update failed");
     }
   }
 
------------------------------------------------------------------------------
_______________________________________________
Opensaf-devel mailing list
Opensaf-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensaf-devel

Reply via email to