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_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.avsv_ext = 
> static_cast<AVSV_ERR_RCVR>(comp->err_info.def_rec);
>               rc = avnd_err_process(cb, comp, &err_info);
>       }
>   
> +done:
>       /* pg tracking may be started by this ava... delete those traces */
>       avnd_pg_finalize(cb, 0, &mds_evt->mds_dest);
>   
> @@ -673,7 +685,7 @@ uint32_t avnd_comp_reg_prc(AVND_CB *cb,
>       bool su_is_enabled;
>       uint32_t rc = NCSCC_RC_SUCCESS;
>       TRACE_ENTER2("comp: '%s'", comp->name.value);
> -     
> +
>       if (pxy_comp)
>               TRACE("proxy comp = '%s'", pxy_comp->name.value);
>   
> diff --git a/osaf/services/saf/amf/amfnd/err.cc 
> b/osaf/services/saf/amf/amfnd/err.cc
> --- a/osaf/services/saf/amf/amfnd/err.cc
> +++ b/osaf/services/saf/amf/amfnd/err.cc
> @@ -320,6 +320,18 @@ uint32_t avnd_err_process(AVND_CB *cb, A
>       
>       const uint32_t previous_esc_rcvr = esc_rcvr;
>   
> +     /* If Amf was waiting for down event to come regarding term cbq, but
> +        error has occurred, so reset the variable (irrespective of Sa-Aware
> +        PI or Proxied PI)*/
> +     if (comp->term_cbq_inv_value != 0) {
> +             AVND_COMP_CBK *cbk_rec;
> +             /* get the matching entry from the cbk list */
> +             m_AVND_COMP_CBQ_INV_GET(comp, comp->term_cbq_inv_value, 
> cbk_rec);
> +             comp->term_cbq_inv_value = 0;
> +             if (cbk_rec)
> +                     avnd_comp_cbq_rec_pop_and_del(cb, comp, cbk_rec, false);
> +     }
> +
>       // Handle errors differently when shutdown has started
>       if (AVND_TERM_STATE_OPENSAF_SHUTDOWN_STARTED == cb->term_state) {
>               LOG_NO("'%s' faulted due to '%s'", comp->name.value, 
> g_comp_err[err_info->src]);
> diff --git a/osaf/services/saf/amf/amfnd/include/avnd_comp.h 
> b/osaf/services/saf/amf/amfnd/include/avnd_comp.h
> --- a/osaf/services/saf/amf/amfnd/include/avnd_comp.h
> +++ b/osaf/services/saf/amf/amfnd/include/avnd_comp.h
> @@ -390,6 +390,7 @@ typedef struct avnd_comp_tag {
>                                  saAmfComponentErrorReport() or 
> saAmfComponentErrorReport_4()*/
>   
>       std::bitset<NumAttrs> *use_comptype_attr;
> +     SaInvocationT term_cbq_inv_value; /* invocation value for termination 
> callback. */
>   
>   } AVND_COMP;
>   


------------------------------------------------------------------------------
_______________________________________________
Opensaf-devel mailing list
Opensaf-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensaf-devel

Reply via email to