[devel] [PATCH 1 of 1] amfnd: wait for applcation exit during its termimation [#1375]
osaf/services/saf/amf/amfnd/cbq.cc | 31 +--- osaf/services/saf/amf/amfnd/comp.cc | 14 ++- osaf/services/saf/amf/amfnd/err.cc | 12 + osaf/services/saf/amf/amfnd/include/avnd_comp.h | 1 + 4 files changed, 53 insertions(+), 5 deletions(-) During appl termination, amf issues instantiate cmd immediately after it receives appl termination resp. There is possibility that application may not have exited before Amf issues instantiate cmd and instantiate command may hang. So, Amf need to wait till appl exit after Amf receives termination response. If appl doesnot exit within termination cbk timeout, then Amf sends cleanup command. If there is some fault(like error report) happened after appl sends term resp and before application exits, Amf will take actions accordingly. diff --git a/osaf/services/saf/amf/amfnd/cbq.cc b/osaf/services/saf/amf/amfnd/cbq.cc --- a/osaf/services/saf/amf/amfnd/cbq.cc +++ b/osaf/services/saf/amf/amfnd/cbq.cc @@ -376,10 +376,22 @@ uint32_t avnd_evt_ava_resp_evh(AVND_CB * m_AVND_COMP_TERM_FAIL_SET(comp); m_AVND_SEND_CKPT_UPDT_ASYNC_UPDT(cb, comp, AVND_CKPT_COMP_FLAG_CHANGE); } - - rc = avnd_comp_clc_fsm_run(cb, comp, (SA_AIS_OK == resp->err) ? - AVND_COMP_CLC_PRES_FSM_EV_TERM_SUCC : AVND_COMP_CLC_PRES_FSM_EV_CLEANUP); - avnd_comp_cbq_rec_pop_and_del(cb, comp, cbk_rec, false); + /* For successful response from (1.) Sa-Aware PI component, wait + for down event to come, don't run clc here, run clc when down + event comes. (2.) proxied PI, no down event + expected, so run clc here. In case of failure response from + any body, follow the clc. No need to check for PI along with + proxied, because in case of PI only, term response will come + back from component. */ + if((SA_AIS_OK == resp->err) && (!m_AVND_COMP_TYPE_IS_PROXIED(comp))) { + /* Save invocation value to delete cbq record when + down event comes. */ + comp->term_cbq_inv_value = resp->inv; + } else { + rc = avnd_comp_clc_fsm_run(cb, comp, (SA_AIS_OK == resp->err) ? + AVND_COMP_CLC_PRES_FSM_EV_TERM_SUCC : AVND_COMP_CLC_PRES_FSM_EV_CLEANUP); + avnd_comp_cbq_rec_pop_and_del(cb, comp, cbk_rec, false); + } // if all OK send a response to the client if ((rc == NCSCC_RC_SUCCESS) && (resp->err == SA_AIS_OK)) { @@ -563,6 +575,17 @@ uint32_t avnd_evt_tmr_cbk_resp_evh(AVND_ } else if (AVSV_AMF_COMP_TERM == rec->cbk_info->type) { m_AVND_COMP_TERM_FAIL_SET(rec->comp); m_AVND_SEND_CKPT_UPDT_ASYNC_UPDT(cb, rec->comp, AVND_CKPT_COMP_FLAG_CHANGE); + if (rec->comp->term_cbq_inv_value != 0) { + AVND_COMP_CBK *cbk_rec; + /* Since, the cbq timer has expired and no down event + came, get the matching entry from the cbk list and + delete the cbq. */ + m_AVND_COMP_CBQ_INV_GET(rec->comp, rec->comp->term_cbq_inv_value, cbk_rec); + rec->comp->term_cbq_inv_value = 0; + if (cbk_rec) { + avnd_comp_cbq_rec_pop_and_del(cb, rec->comp, cbk_rec, false); + } + } rc = avnd_comp_clc_fsm_run(cb, rec->comp, AVND_COMP_CLC_PRES_FSM_EV_CLEANUP); } else { switch (rec->cbk_info->type) { diff --git a/osaf/services/saf/amf/amfnd/comp.cc b/osaf/services/saf/amf/amfnd/comp.cc --- a/osaf/services/saf/amf/amfnd/comp.cc +++ b/osaf/services/saf/amf/amfnd/comp.cc @@ -381,12 +381,24 @@ uint32_t avnd_evt_mds_ava_dn_evh(AVND_CB } /* for */ if (comp) { + if (comp->term_cbq_inv_value != 0) { + AVND_COMP_CBK *cbk_rec; + /* Amf was waiting for this down event. Get the matching + entry from the cbk list and delete the cbq */ + m_AVND_COMP_CBQ_INV_GET(comp, comp->term_cbq_inv_value, cbk_rec); + comp->term_cbq_inv_value = 0; + rc = avnd_comp_clc_fsm_run(cb, comp, AVND_COMP_CLC_PRES_FSM_EV_TERM_SUCC); + if (cbk_rec) + avnd_comp_cbq_rec_pop_and_del(cb, comp, cbk_rec, false); + goto done; + } /* found the matching comp; trigger error processing */ err_info.src = AVND_ERR_SRC_AVA_DN; err_info.rec_rcvr.av
Re: [devel] [PATCH 1 of 1] amfnd: wait for applcation exit during its termimation [#1375]
ack, code review and tested with amf demo app changed to delay exit at termination callback. /Thanks HansN On 06/09/2015 03:47 PM, nagendr...@oracle.com wrote: > osaf/services/saf/amf/amfnd/cbq.cc | 31 > +--- > osaf/services/saf/amf/amfnd/comp.cc | 14 ++- > osaf/services/saf/amf/amfnd/err.cc | 12 + > osaf/services/saf/amf/amfnd/include/avnd_comp.h | 1 + > 4 files changed, 53 insertions(+), 5 deletions(-) > > > During appl termination, amf issues instantiate cmd immediately after > it receives appl termination resp. There is possibility that application > may not have exited before Amf issues instantiate cmd and instantiate command > may hang. > So, Amf need to wait till appl exit after Amf receives termination response. > If appl doesnot exit within termination cbk timeout, then Amf > sends cleanup command. > If there is some fault(like error report) happened after appl sends > term resp and before application exits, Amf will take actions > accordingly. > > diff --git a/osaf/services/saf/amf/amfnd/cbq.cc > b/osaf/services/saf/amf/amfnd/cbq.cc > --- a/osaf/services/saf/amf/amfnd/cbq.cc > +++ b/osaf/services/saf/amf/amfnd/cbq.cc > @@ -376,10 +376,22 @@ uint32_t avnd_evt_ava_resp_evh(AVND_CB * > m_AVND_COMP_TERM_FAIL_SET(comp); > m_AVND_SEND_CKPT_UPDT_ASYNC_UPDT(cb, comp, > AVND_CKPT_COMP_FLAG_CHANGE); > } > - > - rc = avnd_comp_clc_fsm_run(cb, comp, (SA_AIS_OK == resp->err) ? > -AVND_COMP_CLC_PRES_FSM_EV_TERM_SUCC > : AVND_COMP_CLC_PRES_FSM_EV_CLEANUP); > - avnd_comp_cbq_rec_pop_and_del(cb, comp, cbk_rec, false); > + /* For successful response from (1.) Sa-Aware PI component, wait > +for down event to come, don't run clc here, run clc when down > +event comes. (2.) proxied PI, no down event > +expected, so run clc here. In case of failure response from > +any body, follow the clc. No need to check for PI along with > +proxied, because in case of PI only, term response will come > +back from component. */ > + if((SA_AIS_OK == resp->err) && > (!m_AVND_COMP_TYPE_IS_PROXIED(comp))) { > + /* Save invocation value to delete cbq record when > +down event comes. */ > + comp->term_cbq_inv_value = resp->inv; > + } else { > + rc = avnd_comp_clc_fsm_run(cb, comp, (SA_AIS_OK == > resp->err) ? > + AVND_COMP_CLC_PRES_FSM_EV_TERM_SUCC : > AVND_COMP_CLC_PRES_FSM_EV_CLEANUP); > + avnd_comp_cbq_rec_pop_and_del(cb, comp, cbk_rec, false); > + } > > // if all OK send a response to the client > if ((rc == NCSCC_RC_SUCCESS) && (resp->err == SA_AIS_OK)) { > @@ -563,6 +575,17 @@ uint32_t avnd_evt_tmr_cbk_resp_evh(AVND_ > } else if (AVSV_AMF_COMP_TERM == rec->cbk_info->type) { > m_AVND_COMP_TERM_FAIL_SET(rec->comp); > m_AVND_SEND_CKPT_UPDT_ASYNC_UPDT(cb, rec->comp, > AVND_CKPT_COMP_FLAG_CHANGE); > + if (rec->comp->term_cbq_inv_value != 0) { > + AVND_COMP_CBK *cbk_rec; > + /* Since, the cbq timer has expired and no down event > +came, get the matching entry from the cbk list and > +delete the cbq. */ > + m_AVND_COMP_CBQ_INV_GET(rec->comp, > rec->comp->term_cbq_inv_value, cbk_rec); > + rec->comp->term_cbq_inv_value = 0; > + if (cbk_rec) { > + avnd_comp_cbq_rec_pop_and_del(cb, rec->comp, > cbk_rec, false); > + } > + } > rc = avnd_comp_clc_fsm_run(cb, rec->comp, > AVND_COMP_CLC_PRES_FSM_EV_CLEANUP); > } else { > switch (rec->cbk_info->type) { > diff --git a/osaf/services/saf/amf/amfnd/comp.cc > b/osaf/services/saf/amf/amfnd/comp.cc > --- a/osaf/services/saf/amf/amfnd/comp.cc > +++ b/osaf/services/saf/amf/amfnd/comp.cc > @@ -381,12 +381,24 @@ uint32_t avnd_evt_mds_ava_dn_evh(AVND_CB > } /* for */ > > if (comp) { > + if (comp->term_cbq_inv_value != 0) { > + AVND_COMP_CBK *cbk_rec; > + /* Amf was waiting for this down event. Get the matching > +entry from the cbk list and delete the cbq */ > + m_AVND_COMP_CBQ_INV_GET(comp, comp->term_cbq_inv_value, > cbk_rec); > + comp->term_cbq_inv_value = 0; > + rc = avnd_comp_clc_fsm_run(cb, comp, > AVND_COMP_CLC_PRES_FSM_EV_TERM_SUCC); > + if (cbk_rec) > + avnd_comp_cbq_re