Hi Hung,

Ack with a minor inline comment.


-----Original Message-----
From: Hung Nguyen [mailto:[email protected]] 
Sent: den 13 april 2017 10:52
To: Zoran Milinkovic <[email protected]>
Cc: [email protected]; Hung Duc Nguyen 
<[email protected]>
Subject: [PATCH 1/1] imm: Ignore the sync'ed IMMND nodes that are not up [#2418]

Add new 'isUp' flag to IMMD_IMMND_INFO_NODE.
If a new IMMND node is added during MDS UP event or intro message,
the flag is set to true.
If a new IMMND node is added during coldsync, the flag is set to false.
The flag will be set to true when MDS UP event comes.
---
 src/imm/immd/immd_cb.h    |  1 +
 src/imm/immd/immd_db.c    | 34 +++++++++++++++++++++-------------
 src/imm/immd/immd_evt.c   |  2 ++
 src/imm/immd/immd_mbcsv.c |  5 +++++
 4 files changed, 29 insertions(+), 13 deletions(-)

diff --git a/src/imm/immd/immd_cb.h b/src/imm/immd/immd_cb.h
index af63a98..09a9c2c 100644
--- a/src/imm/immd/immd_cb.h
+++ b/src/imm/immd/immd_cb.h
@@ -59,6 +59,7 @@ typedef struct immd_immnd_info_node {
   bool isCoord;
   bool syncStarted;
   bool pbeConfigured; /* Pbe-file-name configured. Pbe may still be disabled. 
*/
+  bool isUp; /* True if received the MDS UP event */
 } IMMD_IMMND_INFO_NODE;
 
 typedef struct immd_immnd_detached_node { /* IMMD SBY tracking of departed
diff --git a/src/imm/immd/immd_db.c b/src/imm/immd/immd_db.c
index 7968b07..ec005d9 100644
--- a/src/imm/immd/immd_db.c
+++ b/src/imm/immd/immd_db.c
@@ -80,20 +80,28 @@ uint32_t immd_immnd_info_node_get(NCS_PATRICIA_TREE 
*immnd_tree, MDS_DEST *dest,
 void immd_immnd_info_node_getnext(NCS_PATRICIA_TREE *immnd_tree, MDS_DEST 
*dest,
                                  IMMD_IMMND_INFO_NODE **immnd_info_node)
 {
-       NODE_ID key;
-       memset(&key, 0, sizeof(NODE_ID));
-       /* Fill the Key */
-
-       if (dest) {
-               key = m_NCS_NODE_ID_FROM_MDS_DEST((*dest));
+       IMMD_IMMND_INFO_NODE* next_node = NULL;
+       MDS_DEST* current_dest = dest;
+       do {
+               if (current_dest) {
+                       NODE_ID key;
+                       memset(&key, 0, sizeof(NODE_ID));
+                       key = m_NCS_NODE_ID_FROM_MDS_DEST((*current_dest));
+
+                       next_node =
+                           (IMMD_IMMND_INFO_NODE *)ncs_patricia_tree_getnext(
+                               immnd_tree, (uint8_t *)&key);
+                       if (next_node) {
+                               current_dest = &next_node->immnd_dest;
+                       }

[Zoran] "if(next_node)..." block can be moved down.

+               } else {
+                       next_node =
+                           (IMMD_IMMND_INFO_NODE *)ncs_patricia_tree_getnext(
+                               immnd_tree, (uint8_t *)NULL);
+               }

[Zoran] If the first node result is not NULL and "isUp" is false, the code will 
end up in an endless loop.
The "IF" block from upper comment can be moved here, and it will ensure that 
the iteration goes through the whole list of nodes in patricia tree.

This is a minor fix, and you don't need to send the patch for another review.

Thanks,
Zoran

+       } while (next_node && !next_node->isUp);
 
-               *immnd_info_node =
-                   (IMMD_IMMND_INFO_NODE *)ncs_patricia_tree_getnext(
-                       immnd_tree, (uint8_t *)&key);
-       } else
-               *immnd_info_node =
-                   (IMMD_IMMND_INFO_NODE *)ncs_patricia_tree_getnext(
-                       immnd_tree, (uint8_t *)NULL);
+       *immnd_info_node = next_node;
 
        return;
 }
diff --git a/src/imm/immd/immd_evt.c b/src/imm/immd/immd_evt.c
index 49ac7c3..c1371fc 100644
--- a/src/imm/immd/immd_evt.c
+++ b/src/imm/immd/immd_evt.c
@@ -1054,6 +1054,8 @@ static IMMD_IMMND_INFO_NODE *immd_add_immnd_node(IMMD_CB 
*cb, MDS_DEST dest)
                return NULL;
        }
 
+       node_info->isUp = true;
+
        if (add_flag) {
                TRACE("IMMND node has already been added, dest %" PRIu64, dest);
        }
diff --git a/src/imm/immd/immd_mbcsv.c b/src/imm/immd/immd_mbcsv.c
index 8ccadd1..bed2c28 100644
--- a/src/imm/immd/immd_mbcsv.c
+++ b/src/imm/immd/immd_mbcsv.c
@@ -1243,6 +1243,11 @@ static uint32_t mbcsv_dec_sync_resp(IMMD_CB *cb, 
NCS_MBCSV_CB_ARG *arg)
                immd_immnd_info_node_find_add(&cb->immnd_tree, &dest,
                                              &node_info, &add_flag);
                osafassert(node_info);
+               if (!add_flag) {
+                       /* New node is added to the list,
+                        * MDS UP event is not received */
+                       node_info->isUp = false;
+               }
 
                ptr = ncs_dec_flatten_space(&arg->info.decode.i_uba, data,
                                            sizeof(uint32_t));
-- 
1.9.1


------------------------------------------------------------------------------
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

Reply via email to