Hi Hung,

Reviewed the patch.
Ack.

/Neel.

On 2017/05/17 01:23 PM, Hung Nguyen wrote:
> During cold-sync, standby IMMD may receive info of dead IMMND.
> Before switching to active, the IMMD should clear those dead IMMND info.
> ---
>   src/imm/immd/immd_amf.c |  5 +++++
>   src/imm/immd/immd_cb.h  |  2 +-
>   src/imm/immd/immd_db.c  | 25 +++++++++++++++----------
>   src/imm/immd/immd_evt.c |  3 +++
>   4 files changed, 24 insertions(+), 11 deletions(-)
>
> diff --git a/src/imm/immd/immd_amf.c b/src/imm/immd/immd_amf.c
> index 82b933f..bd29faf 100644
> --- a/src/imm/immd/immd_amf.c
> +++ b/src/imm/immd/immd_amf.c
> @@ -250,6 +250,11 @@ static void immd_saf_csi_set_cb(SaInvocationT invocation,
>       }
>   
>       if (role_change) {
> +             if (new_haState == SA_AMF_HA_ACTIVE) {
> +                     /* Cleanup dead IMMND nodes during coldsync */
> +                     immd_immnd_info_tree_cleanup(cb, true);
> +             }
> +
>               if (was_fully_initialized == true) {
>                       if ((rc = immd_mds_change_role(cb)) !=
>                           NCSCC_RC_SUCCESS) {
> diff --git a/src/imm/immd/immd_cb.h b/src/imm/immd/immd_cb.h
> index 2fc6264..3295e54 100644
> --- a/src/imm/immd/immd_cb.h
> +++ b/src/imm/immd/immd_cb.h
> @@ -171,7 +171,7 @@ void immd_immnd_info_node_getnext(NCS_PATRICIA_TREE 
> *immnd_tree, MDS_DEST *dest,
>   uint32_t immd_immnd_info_node_delete(IMMD_CB *cb,
>                                        IMMD_IMMND_INFO_NODE *immnd_info_node);
>   
> -void immd_immnd_info_tree_cleanup(IMMD_CB *cb);
> +void immd_immnd_info_tree_cleanup(IMMD_CB *cb, bool dead_only);
>   
>   void immd_immnd_info_tree_destroy(IMMD_CB *cb);
>   
> diff --git a/src/imm/immd/immd_db.c b/src/imm/immd/immd_db.c
> index d914c9c..81a8fdd 100644
> --- a/src/imm/immd/immd_db.c
> +++ b/src/imm/immd/immd_db.c
> @@ -218,24 +218,29 @@ uint32_t immd_immnd_info_node_delete(IMMD_CB *cb,
>     Arguments     : IMMD_CB *cb - IMMD Control Block.
>     Return Values : None
>   
> ****************************************************************************/
> -void immd_immnd_info_tree_cleanup(IMMD_CB *cb)
> +void immd_immnd_info_tree_cleanup(IMMD_CB *cb, bool dead_only)
>   {
>       IMMD_IMMND_INFO_NODE *immnd_info_node;
> -     NODE_ID key;
> -
> -     memset(&key, 0, sizeof(NODE_ID));
>   
>       /* Get the First Node */
>       immnd_info_node = (IMMD_IMMND_INFO_NODE *)ncs_patricia_tree_getnext(
> -         &cb->immnd_tree, (uint8_t *)&key);
> +         &cb->immnd_tree, (uint8_t *)NULL);
>       while (immnd_info_node) {
> -             key = m_NCS_NODE_ID_FROM_MDS_DEST(immnd_info_node->immnd_dest);
> -
> -             immd_immnd_info_node_delete(cb, immnd_info_node);
> +             NODE_ID key = m_NCS_NODE_ID_FROM_MDS_DEST(
> +                             immnd_info_node->immnd_dest);
> +             NODE_ID* key_pointer = &key;
> +
> +             if (!dead_only || !immnd_info_node->isUp) {
> +                     LOG_NO("Deleting IMMND dest:%" PRIu64,
> +                            immnd_info_node->immnd_dest);
> +                     immd_immnd_info_node_delete(cb, immnd_info_node);
> +                     /* Reset iteration */
> +                     key_pointer = NULL;
> +             }
>   
>               immnd_info_node =
>                   (IMMD_IMMND_INFO_NODE *)ncs_patricia_tree_getnext(
> -                     &cb->immnd_tree, (uint8_t *)&key);
> +                     &cb->immnd_tree, (uint8_t *)key_pointer);
>       }
>   
>       return;
> @@ -253,7 +258,7 @@ void immd_immnd_info_tree_destroy(IMMD_CB *cb)
>               return;
>   
>       /* cleanup the client tree */
> -     immd_immnd_info_tree_cleanup(cb);
> +     immd_immnd_info_tree_cleanup(cb, false);
>   
>       /* destroy the tree */
>       ncs_patricia_tree_destroy(&cb->immnd_tree);
> diff --git a/src/imm/immd/immd_evt.c b/src/imm/immd/immd_evt.c
> index adac747..24a4185 100644
> --- a/src/imm/immd/immd_evt.c
> +++ b/src/imm/immd/immd_evt.c
> @@ -2966,6 +2966,9 @@ static uint32_t immd_evt_proc_rda_callback(IMMD_CB *cb, 
> IMMD_EVT *evt)
>   
>               LOG_NO("ACTIVE request");
>   
> +             /* Cleanup dead IMMND nodes during coldsync */
> +             immd_immnd_info_tree_cleanup(cb, true);
> +
>               if (was_fully_initialized == true) {
>                       if ((rc = immd_mds_change_role(cb)) !=
>                           NCSCC_RC_SUCCESS) {


------------------------------------------------------------------------------
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
Opensaf-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensaf-devel

Reply via email to