Hi Praveen Yes, thanks for picking that up. I will send another patch.
Thanks Gary On 17/8/17, 6:24 pm, "praveen malviya" <[email protected]> wrote: Hi Gary, Please find one comment inline with [Praveen]. Thanks Praveen On 05-Jul-17 2:15 PM, Gary Lee wrote: > --- > src/amf/amfnd/avnd_cb.h | 3 +- > src/amf/amfnd/avnd_di.h | 36 ------ > src/amf/amfnd/avnd_mds.h | 11 +- > src/amf/amfnd/di.cc | 321 +++++++++++++++++++++-------------------------- > src/amf/amfnd/proxy.cc | 19 ++- > src/amf/amfnd/verify.cc | 14 +-- > 6 files changed, 167 insertions(+), 237 deletions(-) > > diff --git a/src/amf/amfnd/avnd_cb.h b/src/amf/amfnd/avnd_cb.h > index 2d642c752..ff21e3108 100644 > --- a/src/amf/amfnd/avnd_cb.h > +++ b/src/amf/amfnd/avnd_cb.h > @@ -33,6 +33,7 @@ > #ifndef AMF_AMFND_AVND_CB_H_ > #define AMF_AMFND_AVND_CB_H_ > #include <map> > +#include <vector> > > typedef struct avnd_cb_tag { > SYSF_MBX mbx; /* mailbox on which AvND waits */ > @@ -99,7 +100,7 @@ typedef struct avnd_cb_tag { > * Messages are removed when acked with the ACK message. > * At director failover the list is scanned handling the > * VERIFY message from the director and possibly resent again */ > - AVND_DND_LIST dnd_list; > + std::vector<AVND_DND_MSG_LIST*> dnd_list; > > AVND_TERM_STATE term_state; > AVND_LED_STATE led_state; > diff --git a/src/amf/amfnd/avnd_di.h b/src/amf/amfnd/avnd_di.h > index d7ccd68fd..9870ad774 100644 > --- a/src/amf/amfnd/avnd_di.h > +++ b/src/amf/amfnd/avnd_di.h > @@ -33,42 +33,6 @@ > > #include "amf/common/amf_si_assign.h" > > -/* macro to find the matching record (based on the msg-id) */ > -/* > - * Caution!!! It is assumed that the msg-id is the 1st element in the message > - * structure. Ensure it. Else move the msg id to the common portion of the > - * message structure (outside the msg type specific contents). > - */ > -#define m_AVND_DIQ_REC_FIND(cb, mid, o_rec) \ > - { \ > - AVND_DND_LIST *list = &((cb)->dnd_list); \ > - for ((o_rec) = list->head; \ > - (o_rec) && \ > - !(*((uint32_t *)(&((o_rec)->msg.info.avd->msg_info))) == (mid)); \ > - (o_rec) = (o_rec)->next) \ > - ; \ > - } > - > -/* macro to find & pop a given record */ > -#define m_AVND_DIQ_REC_FIND_POP(cb, rec) \ > - { \ > - AVND_DND_LIST *list = &((cb)->dnd_list); \ > - AVND_DND_MSG_LIST *prv = list->head, *curr; \ > - for (curr = list->head; curr && !(curr == (rec)); \ > - prv = curr, curr = curr->next) \ > - ; \ > - if (curr) { \ > - if (curr == list->head) { \ > - list->head = curr->next; \ > - if (list->tail == curr) list->tail = list->head; \ > - } else { \ > - prv->next = curr->next; \ > - if (list->tail == curr) list->tail = prv; \ > - } \ > - curr->next = 0; \ > - } \ > - } > - > struct avnd_cb_tag; > > uint32_t avnd_di_oper_send(struct avnd_cb_tag *, const AVND_SU *, uint32_t); > diff --git a/src/amf/amfnd/avnd_mds.h b/src/amf/amfnd/avnd_mds.h > index 70173acaa..8c81f7bb1 100644 > --- a/src/amf/amfnd/avnd_mds.h > +++ b/src/amf/amfnd/avnd_mds.h > @@ -63,18 +63,13 @@ typedef struct avnd_msg { > } info; > } AVND_MSG; > > -typedef struct avnd_dnd_msg_list_tag { > +class AVND_DND_MSG_LIST { > +public: > AVND_MSG msg; > AVND_TMR resp_tmr; > uint32_t opq_hdl; > uint16_t no_retries; > - struct avnd_dnd_msg_list_tag *next; > -} AVND_DND_MSG_LIST; > - > -typedef struct avnd_dnd_list_tag { > - AVND_DND_MSG_LIST *head; > - AVND_DND_MSG_LIST *tail; > -} AVND_DND_LIST; > +}; > > /***************************************************************************** > Macros to fill the MDS message structure > diff --git a/src/amf/amfnd/di.cc b/src/amf/amfnd/di.cc > index 6f0a76cda..93350e62a 100644 > --- a/src/amf/amfnd/di.cc > +++ b/src/amf/amfnd/di.cc > @@ -39,30 +39,7 @@ > > #include "base/logtrace.h" > #include "amf/amfnd/avnd.h" > - > -/* macro to push the AvD msg parameters (to the end of the list) */ > -#define m_AVND_DIQ_REC_PUSH(cb, rec) \ > - { \ > - AVND_DND_LIST *list = &((cb)->dnd_list); \ > - if (!(list->head)) \ > - list->head = (rec); \ > - else \ > - list->tail->next = (rec); \ > - list->tail = (rec); \ > - } > - > -/* macro to pop the record (from the beginning of the list) */ > -#define m_AVND_DIQ_REC_POP(cb, o_rec) \ > - { \ > - AVND_DND_LIST *list = &((cb)->dnd_list); \ > - if (list->head) { \ > - (o_rec) = list->head; \ > - list->head = (o_rec)->next; \ > - (o_rec)->next = 0; \ > - if (list->tail == (o_rec)) list->tail = 0; \ > - } else \ > - (o_rec) = 0; \ > - } > +#include <algorithm> > > static uint32_t avnd_node_oper_req(AVND_CB *cb, AVSV_PARAM_INFO *param) { > uint32_t rc = NCSCC_RC_FAILURE; > @@ -460,7 +437,9 @@ uint32_t avnd_evt_tmr_rcv_msg_rsp_evh(AVND_CB *cb, AVND_EVT *evt) { > > ncshm_give_hdl(tmr->opq_hdl); > if (rec_tobe_deleted) { > - m_AVND_DIQ_REC_FIND_POP(cb, rec); > + auto position = std::find(cb->dnd_list.begin(), cb->dnd_list.end(), rec); > + osafassert(position != cb->dnd_list.end()); > + cb->dnd_list.erase(position); > avnd_diq_rec_del(cb, rec); > } > done: > @@ -471,7 +450,6 @@ done: > void avnd_send_node_up_msg(void) { > AVND_CB *cb = avnd_cb; > AVND_MSG msg = {}; > - AVND_DND_MSG_LIST *pending_rec = 0; > uint32_t rc; > > TRACE_ENTER(); > @@ -487,8 +465,7 @@ void avnd_send_node_up_msg(void) { > } > > // We don't send node_up if it has already been sent and waiting for ACK > - for (pending_rec = cb->dnd_list.head; pending_rec != nullptr; > - pending_rec = pending_rec->next) { > + for (auto pending_rec : cb->dnd_list) { > if (pending_rec->msg.info.avd->msg_type == AVSV_N2D_NODE_UP_MSG) { > TRACE( > "Don't send another node_up since it has been sent and waiting for ack"); > @@ -677,12 +654,11 @@ uint32_t avnd_evt_mds_avd_dn_evh(AVND_CB *cb, AVND_EVT *evt) { > > if (cb->scs_absence_max_duration == 0) { > // check for pending messages TO director > - if ((cb->dnd_list.head != nullptr)) { > + if ((cb->dnd_list.empty() == false)) { > uint32_t no_pending_msg = 0; > - AVND_DND_MSG_LIST *rec = 0; > - for (rec = cb->dnd_list.head; rec != nullptr; > - rec = rec->next, no_pending_msg++) { > + for (auto rec : cb->dnd_list) { > osafassert(rec->msg.type == AVND_MSG_AVD); > + no_pending_msg++; > } > > /* Don't issue reboot if it has been already issued.*/ > @@ -1115,7 +1091,9 @@ uint32_t avnd_di_msg_send(AVND_CB *cb, AVND_MSG *msg) { > done: > if (NCSCC_RC_SUCCESS != rc && rec) { > /* pop & delete */ > - m_AVND_DIQ_REC_FIND_POP(cb, rec); > + auto position = std::find(cb->dnd_list.begin(), cb->dnd_list.end(), rec); > + osafassert(position != cb->dnd_list.end()); > + cb->dnd_list.erase(position); > avnd_diq_rec_del(cb, rec); > } > TRACE_LEAVE2("%u", rc); > @@ -1252,21 +1230,29 @@ uint32_t avnd_di_node_down_msg_send(AVND_CB *cb) > Notes : None. > ******************************************************************************/ > void avnd_di_msg_ack_process(AVND_CB *cb, uint32_t mid) { > - AVND_DND_MSG_LIST *rec = 0; > - > - /* find & pop the matching record */ > - m_AVND_DIQ_REC_FIND(cb, mid, rec); > - if (rec) { > - if (rec->msg.info.avd->msg_type == AVSV_N2D_NODE_DOWN_MSG) { > - // first to stop timer to avoid processing timeout event > - // then perform last step clean up > - avnd_stop_tmr(cb, &rec->resp_tmr); > - avnd_last_step_clean(cb); > + TRACE_ENTER2("%u", mid); > + > + for (auto iter = cb->dnd_list.begin(); iter != cb->dnd_list.end(); ++iter) { > + auto rec = *iter; > + osafassert(rec->msg.type == AVND_MSG_AVD); > + const uint32_t msg_id = *(reinterpret_cast<uint32_t*>(&(rec->msg.info.avd->msg_info))); > + > + // matching record > + if (msg_id == mid) { > + if (rec->msg.info.avd->msg_type == AVSV_N2D_NODE_DOWN_MSG) { > + // first to stop timer to avoid processing timeout event > + // then perform last step clean up > + avnd_stop_tmr(cb, &rec->resp_tmr); > + avnd_last_step_clean(cb); > + } > + cb->dnd_list.erase(iter); > + TRACE("remove msg %u from queue", msg_id); > + avnd_diq_rec_del(cb, rec); > + break; > } > - m_AVND_DIQ_REC_FIND_POP(cb, rec); > - avnd_diq_rec_del(cb, rec); > } > > + TRACE_LEAVE2(); > return; > } > > @@ -1288,62 +1274,55 @@ void avnd_di_msg_ack_process(AVND_CB *cb, uint32_t mid) { > Notes : None. > ******************************************************************************/ > void avnd_diq_rec_check_buffered_msg(AVND_CB *cb) { > - if ((cb->dnd_list.head != nullptr)) { > - AVND_DND_MSG_LIST *rec = 0; > - bool found = true; > - while (found) { > - found = false; > - for (rec = cb->dnd_list.head; rec != nullptr;) { > - osafassert(rec->msg.type == AVND_MSG_AVD); > - m_AVND_DIQ_REC_POP(cb, rec); > - // Assignment response had been sent, but not ack because > - // last controller go down, reset msg_id and will be resent later > - if (rec->msg.info.avd->msg_type == AVSV_N2D_INFO_SU_SI_ASSIGN_MSG) { > - if (rec->msg.info.avd->msg_info.n2d_su_si_assign.msg_id != 0) { > - rec->msg.info.avd->msg_info.n2d_su_si_assign.msg_id = 0; > - found = true; > - LOG_NO( > - "Found not-ack su_si_assign msg for SU:'%s', " > - "SI:'%s', ha_state:'%u', msg_act:'%u', single_csi:'%u', " > - "error:'%u', msg_id:'%u'", > - osaf_extended_name_borrow(&rec->msg.info.avd->msg_info > - .n2d_su_si_assign.su_name), > - osaf_extended_name_borrow(&rec->msg.info.avd->msg_info > - .n2d_su_si_assign.si_name), > - rec->msg.info.avd->msg_info.n2d_su_si_assign.ha_state, > - rec->msg.info.avd->msg_info.n2d_su_si_assign.msg_act, > - rec->msg.info.avd->msg_info.n2d_su_si_assign > - .single_csi, > - rec->msg.info.avd->msg_info.n2d_su_si_assign.error, > - rec->msg.info.avd->msg_info.n2d_su_si_assign.msg_id); > - } > - m_AVND_DIQ_REC_PUSH(cb, rec); > - break; > - } else if (rec->msg.info.avd->msg_type == > - AVSV_N2D_OPERATION_STATE_MSG) { > - if (rec->msg.info.avd->msg_info.n2d_opr_state.msg_id != 0) { > - rec->msg.info.avd->msg_info.n2d_opr_state.msg_id = 0; > - found = true; > - LOG_NO( > - "Found not-ack oper_state msg for SU:'%s', " > - "su_oper_state:'%u', node_oper_state:'%u', recovery:'%u'", > - osaf_extended_name_borrow(&rec->msg.info.avd->msg_info > - .n2d_opr_state.su_name), > - rec->msg.info.avd->msg_info.n2d_opr_state > - .su_oper_state, > - rec->msg.info.avd->msg_info.n2d_opr_state > - .node_oper_state, > - rec->msg.info.avd->msg_info.n2d_opr_state.rec_rcvr > - .raw); > - } > - m_AVND_DIQ_REC_PUSH(cb, rec); > - break; > - } else { > - // delete other messages for now > - avnd_diq_rec_del(cb, rec); > - rec = cb->dnd_list.head; > - } > + for (auto iter = cb->dnd_list.begin(); iter != cb->dnd_list.end();) { > + auto rec = *iter; > + osafassert(rec->msg.type == AVND_MSG_AVD); > + // Assignment response had been sent, but not ack because > + // last controller go down, reset msg_id and will be resent later > + if (rec->msg.info.avd->msg_type == AVSV_N2D_INFO_SU_SI_ASSIGN_MSG) { > + if (rec->msg.info.avd->msg_info.n2d_su_si_assign.msg_id != 0) { > + rec->msg.info.avd->msg_info.n2d_su_si_assign.msg_id = 0; > + LOG_NO( > + "Found not-ack su_si_assign msg for SU:'%s', " > + "SI:'%s', ha_state:'%u', msg_act:'%u', single_csi:'%u', " > + "error:'%u', msg_id:'%u'", > + osaf_extended_name_borrow(&rec->msg.info.avd->msg_info > + .n2d_su_si_assign.su_name), > + osaf_extended_name_borrow(&rec->msg.info.avd->msg_info > + .n2d_su_si_assign.si_name), > + rec->msg.info.avd->msg_info.n2d_su_si_assign.ha_state, > + rec->msg.info.avd->msg_info.n2d_su_si_assign.msg_act, > + rec->msg.info.avd->msg_info.n2d_su_si_assign > + .single_csi, > + rec->msg.info.avd->msg_info.n2d_su_si_assign.error, > + rec->msg.info.avd->msg_info.n2d_su_si_assign.msg_id); > } > + // leave in dnd_list > + ++rec; [Praveen] Should not it be ++iter? > + continue; > + } else if (rec->msg.info.avd->msg_type == > + AVSV_N2D_OPERATION_STATE_MSG) { > + if (rec->msg.info.avd->msg_info.n2d_opr_state.msg_id != 0) { > + rec->msg.info.avd->msg_info.n2d_opr_state.msg_id = 0; > + LOG_NO( > + "Found not-ack oper_state msg for SU:'%s', " > + "su_oper_state:'%u', node_oper_state:'%u', recovery:'%u'", > + osaf_extended_name_borrow(&rec->msg.info.avd->msg_info > + .n2d_opr_state.su_name), > + rec->msg.info.avd->msg_info.n2d_opr_state > + .su_oper_state, > + rec->msg.info.avd->msg_info.n2d_opr_state > + .node_oper_state, > + rec->msg.info.avd->msg_info.n2d_opr_state.rec_rcvr > + .raw); > + } > + // leave in dnd_list > + ++rec; > + continue; > + } else { > + // delete other messages for now > + iter = cb->dnd_list.erase(iter); > + avnd_diq_rec_del(cb, rec); > } > } > return; > @@ -1379,7 +1358,7 @@ AVND_DND_MSG_LIST *avnd_diq_rec_add(AVND_CB *cb, AVND_MSG *msg) { > msg->info.avd = 0; > > /* push the record to the AvD msg list */ > - m_AVND_DIQ_REC_PUSH(cb, rec); > + cb->dnd_list.push_back(rec); > TRACE_LEAVE(); > return rec; > > @@ -1437,87 +1416,69 @@ void avnd_diq_rec_send_buffered_msg(AVND_CB *cb) { > TRACE_ENTER(); > // Resend msgs from queue because amfnd dropped during headless > // or headless-synchronization > - if ((cb->dnd_list.head != nullptr)) { > - AVND_DND_MSG_LIST *pending_rec = 0; > - TRACE("Attach msg_id of buffered msg"); > - bool found = true; > - while (found) { > - found = false; > - for (pending_rec = cb->dnd_list.head; pending_rec != nullptr; > - pending_rec = pending_rec->next) { > - if (pending_rec->msg.type == AVND_MSG_AVD) { > - // Check su_si_assign message > - if (pending_rec->msg.info.avd->msg_type == > - AVSV_N2D_INFO_SU_SI_ASSIGN_MSG && > - pending_rec->msg.info.avd->msg_info.n2d_su_si_assign.msg_id == > - 0) { > - found = true; > - m_AVND_DIQ_REC_POP(cb, pending_rec); > -#if 1 > - // only resend if this SUSI does exist > - AVND_SU *su = cb->sudb.find(Amf::to_string( > - &pending_rec->msg.info.avd->msg_info.n2d_su_si_assign.su_name)); > - if (su != nullptr && su->si_list.n_nodes > 0) { > -#endif > - pending_rec->msg.info.avd->msg_info.n2d_su_si_assign.msg_id = > - ++(cb->snd_msg_id); > - m_AVND_DIQ_REC_PUSH(cb, pending_rec); > - LOG_NO( > - "Found and resend buffered su_si_assign msg for SU:'%s', " > - "SI:'%s', ha_state:'%u', msg_act:'%u', single_csi:'%u', " > - "error:'%u', msg_id:'%u'", > - osaf_extended_name_borrow(&pending_rec->msg.info.avd->msg_info > - .n2d_su_si_assign.su_name), > - osaf_extended_name_borrow(&pending_rec->msg.info.avd->msg_info > - .n2d_su_si_assign.si_name), > - pending_rec->msg.info.avd->msg_info.n2d_su_si_assign.ha_state, > - pending_rec->msg.info.avd->msg_info.n2d_su_si_assign.msg_act, > - pending_rec->msg.info.avd->msg_info.n2d_su_si_assign > - .single_csi, > - pending_rec->msg.info.avd->msg_info.n2d_su_si_assign.error, > - pending_rec->msg.info.avd->msg_info.n2d_su_si_assign.msg_id); > - > -#if 1 > - } else { > - avnd_msg_content_free(cb, &pending_rec->msg); > - delete pending_rec; > - break; > - } > -#endif > - } > - // Check oper_state message > - else if (pending_rec->msg.info.avd->msg_type == > - AVSV_N2D_OPERATION_STATE_MSG && > - pending_rec->msg.info.avd->msg_info.n2d_opr_state.msg_id == > - 0) { > - found = true; > - m_AVND_DIQ_REC_POP(cb, pending_rec); > - if (pending_rec != nullptr) { > - pending_rec->msg.info.avd->msg_info.n2d_opr_state.msg_id = > - ++(cb->snd_msg_id); > - > - m_AVND_DIQ_REC_PUSH(cb, pending_rec); > - LOG_NO( > - "Found and resend buffered oper_state msg for SU:'%s', " > - "su_oper_state:'%u', node_oper_state:'%u', recovery:'%u'", > - osaf_extended_name_borrow(&pending_rec->msg.info.avd->msg_info > - .n2d_opr_state.su_name), > - pending_rec->msg.info.avd->msg_info.n2d_opr_state > - .su_oper_state, > - pending_rec->msg.info.avd->msg_info.n2d_opr_state > - .node_oper_state, > - pending_rec->msg.info.avd->msg_info.n2d_opr_state.rec_rcvr > - .raw); > - } > - } > - } > + > + for (auto iter = cb->dnd_list.begin(); iter != cb->dnd_list.end();) { > + auto pending_rec = *iter; > + osafassert(pending_rec->msg.type == AVND_MSG_AVD); > + > + // Check su_si_assign message > + if (pending_rec->msg.info.avd->msg_type == > + AVSV_N2D_INFO_SU_SI_ASSIGN_MSG && > + pending_rec->msg.info.avd->msg_info.n2d_su_si_assign.msg_id == > + 0) { > + > + // only resend if this SUSI does exist > + AVND_SU *su = cb->sudb.find(Amf::to_string( > + &pending_rec->msg.info.avd->msg_info.n2d_su_si_assign.su_name)); > + if (su != nullptr && su->si_list.n_nodes > 0) { > + pending_rec->msg.info.avd->msg_info.n2d_su_si_assign.msg_id = > + ++(cb->snd_msg_id); > + LOG_NO( > + "Found and resend buffered su_si_assign msg for SU:'%s', " > + "SI:'%s', ha_state:'%u', msg_act:'%u', single_csi:'%u', " > + "error:'%u', msg_id:'%u'", > + osaf_extended_name_borrow(&pending_rec->msg.info.avd->msg_info > + .n2d_su_si_assign.su_name), > + osaf_extended_name_borrow(&pending_rec->msg.info.avd->msg_info > + .n2d_su_si_assign.si_name), > + pending_rec->msg.info.avd->msg_info.n2d_su_si_assign.ha_state, > + pending_rec->msg.info.avd->msg_info.n2d_su_si_assign.msg_act, > + pending_rec->msg.info.avd->msg_info.n2d_su_si_assign > + .single_csi, > + pending_rec->msg.info.avd->msg_info.n2d_su_si_assign.error, > + pending_rec->msg.info.avd->msg_info.n2d_su_si_assign.msg_id); > + ++iter; > + } else { > + iter = cb->dnd_list.erase(iter); > + avnd_msg_content_free(cb, &pending_rec->msg); > + delete pending_rec; > } > + } else if (pending_rec->msg.info.avd->msg_type == AVSV_N2D_OPERATION_STATE_MSG && > + pending_rec->msg.info.avd->msg_info.n2d_opr_state.msg_id == 0) { > + pending_rec->msg.info.avd->msg_info.n2d_opr_state.msg_id = > + ++(cb->snd_msg_id); > + > + LOG_NO( > + "Found and resend buffered oper_state msg for SU:'%s', " > + "su_oper_state:'%u', node_oper_state:'%u', recovery:'%u'", > + osaf_extended_name_borrow(&pending_rec->msg.info.avd->msg_info > + .n2d_opr_state.su_name), > + pending_rec->msg.info.avd->msg_info.n2d_opr_state > + .su_oper_state, > + pending_rec->msg.info.avd->msg_info.n2d_opr_state > + .node_oper_state, > + pending_rec->msg.info.avd->msg_info.n2d_opr_state.rec_rcvr > + .raw); > + ++iter; > + } else { > + // no other messages should be buffered > + osafassert(false); > } > - TRACE("retransmit message to amfd"); > - for (pending_rec = cb->dnd_list.head; pending_rec != nullptr; > - pending_rec = pending_rec->next) { > - avnd_diq_rec_send(cb, pending_rec); > - } > + } > + > + TRACE("retransmit message to amfd"); > + for (auto pending_rec : cb->dnd_list) { > + avnd_diq_rec_send(cb, pending_rec); > } > TRACE_LEAVE(); > return; > diff --git a/src/amf/amfnd/proxy.cc b/src/amf/amfnd/proxy.cc > index c314c280d..95d74b677 100644 > --- a/src/amf/amfnd/proxy.cc > +++ b/src/amf/amfnd/proxy.cc > @@ -25,6 +25,7 @@ > > ****************************************************************************/ > #include <cinttypes> > +#include <algorithm> > > #include "amf/amfnd/avnd.h" > #include "base/osaf_extended_name.h" > @@ -138,7 +139,9 @@ uint32_t avnd_evt_ava_comp_val_req(AVND_CB *cb, AVND_EVT *evt) { > LOG_ER("avnd_diq_rec_send:failed:%s,Type:%u and Hdl%llx", > comp_name.c_str(), api_info->type, reg->hdl); > /* pop & delete */ > - m_AVND_DIQ_REC_FIND_POP(cb, rec); > + auto position = std::find(cb->dnd_list.begin(), cb->dnd_list.end(), rec); > + osafassert(position != cb->dnd_list.end()); > + cb->dnd_list.erase(position); > avnd_diq_rec_del(cb, rec); > } > } else { > @@ -173,7 +176,7 @@ uint32_t avnd_evt_ava_comp_val_req(AVND_CB *cb, AVND_EVT *evt) { > ******************************************************************************/ > uint32_t avnd_evt_avd_comp_validation_resp_evh(AVND_CB *cb, AVND_EVT *evt) { > uint32_t rc = NCSCC_RC_SUCCESS; > - AVND_DND_MSG_LIST *rec = 0; > + AVND_DND_MSG_LIST *rec = nullptr; > AVSV_D2N_COMP_VALIDATION_RESP_INFO *info = nullptr; > SaAisErrorT amf_rc = SA_AIS_OK; > AVND_COMP *comp = nullptr, *pxy_comp = nullptr; > @@ -192,7 +195,13 @@ uint32_t avnd_evt_avd_comp_validation_resp_evh(AVND_CB *cb, AVND_EVT *evt) { > TRACE("%s:MsgId=%u,NodeId=%u,result:%u", info_comp_name.c_str(), info->msg_id, > info->node_id, info->result); > > - m_AVND_DIQ_REC_FIND(cb, info->msg_id, rec); > + for (auto temp_rec : cb->dnd_list) { > + osafassert(temp_rec->msg.type == AVND_MSG_AVD); > + if (*(reinterpret_cast<uint32_t*>(&(temp_rec->msg.info.avd->msg_info))) == info->msg_id) { > + rec = temp_rec; > + break; > + } > + } > > if ((nullptr == rec) || > (memcmp(osaf_extended_name_borrow(&info->comp_name), > @@ -301,7 +310,9 @@ send_resp: > > done: > if (rec) { > - m_AVND_DIQ_REC_FIND_POP(cb, rec); > + auto position = std::find(cb->dnd_list.begin(), cb->dnd_list.end(), rec); > + osafassert(position != cb->dnd_list.end()); > + cb->dnd_list.erase(position); > avnd_diq_rec_del(cb, rec); > } > > diff --git a/src/amf/amfnd/verify.cc b/src/amf/amfnd/verify.cc > index d5ddcea7f..5726ad93f 100644 > --- a/src/amf/amfnd/verify.cc > +++ b/src/amf/amfnd/verify.cc > @@ -33,6 +33,7 @@ > */ > > #include "amf/amfnd/avnd.h" > +#include <algorithm> > > /**************************************************************************** > Name : avnd_evt_avd_verify_message > @@ -48,8 +49,6 @@ > Notes : None. > ******************************************************************************/ > uint32_t avnd_evt_avd_verify_evh(AVND_CB *cb, AVND_EVT *evt) { > - AVND_DND_LIST *list = &((cb)->dnd_list); > - AVND_DND_MSG_LIST *rec = 0, t_rec; > AVSV_D2N_DATA_VERIFY_MSG_INFO *info; > uint32_t rcv_id; > bool msg_found = false; > @@ -100,9 +99,8 @@ uint32_t avnd_evt_avd_verify_evh(AVND_CB *cb, AVND_EVT *evt) { > * Otherwise this exercise also helps us in cleaning all the messages > * currently pending in the Queue and are not acked. > */ > - for (rec = list->head; nullptr != rec;) { > - t_rec = *rec; > - > + for (auto iter = cb->dnd_list.begin(); iter != cb->dnd_list.end();) { > + auto rec = *iter; > /* > * Since AVD is telling us that he has received till recv_id, we should > * always find msg with ID (rcv_id + 1). Delete and remove all the > @@ -112,10 +110,11 @@ uint32_t avnd_evt_avd_verify_evh(AVND_CB *cb, AVND_EVT *evt) { > */ > if ((rcv_id + 1) > (*((uint32_t *)(&rec->msg.info.avd->msg_info)))) { > /* pop & delete */ > - m_AVND_DIQ_REC_FIND_POP(cb, rec); > + iter = cb->dnd_list.erase(iter); > TRACE_1("AVND record %u deleted, upon fail-over", > *((uint32_t *)(&rec->msg.info.avd->msg_info))); > avnd_diq_rec_del(cb, rec); > + continue; > } else { > avnd_diq_rec_send(cb, rec); > > @@ -124,8 +123,7 @@ uint32_t avnd_evt_avd_verify_evh(AVND_CB *cb, AVND_EVT *evt) { > > msg_found = true; > } > - > - rec = t_rec.next; > + ++iter; > } > > if ((cb->snd_msg_id != info->rcv_id_cnt) && (msg_found == false)) { > ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ Opensaf-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/opensaf-devel
