libmultipath:fix loop traversed partly
authorzhang.kai <zhang.kai16@zte.com.cn>
Thu, 14 Jul 2016 12:09:33 +0000 (20:09 +0800)
committerChristophe Varoqui <christophe.varoqui@opensvc.com>
Fri, 22 Jul 2016 09:09:50 +0000 (11:09 +0200)
Problem:
With each iteration of the vector_foreach_slot() loop statement,
some slots couldn't be traversed when a slot is deleted from vector.

Reasons:
Currently,loop's index 'i' is not decremented correspondingly when a slot is
deleted from vector.Meanwhile, in the vector_foreach_slot() loop, mpp is assigned
from vector newmp directly, so find_slot() could be omitted.

Signed-off-by: zhang.kai <zhang.kai16@zte.com.cn>
libmultipath/configure.c

index a9b9cf0..c06a3df 100644 (file)
@@ -924,16 +924,14 @@ coalesce_paths (struct vectors * vecs, vector newmp, char * refwwid, int force_r
        if (newmp) {
                vector_foreach_slot (newmp, mpp, i) {
                        char alias[WWID_SIZE];
-                       int j;
 
                        if (!deadmap(mpp))
                                continue;
 
                        strncpy(alias, mpp->alias, WWID_SIZE - 1);
 
-                       if ((j = find_slot(newmp, (void *)mpp)) != -1)
-                               vector_del_slot(newmp, j);
-
+                       vector_del_slot(newmp, i);
+                       i--;
                        remove_map(mpp, vecs, 0);
 
                        if (dm_flush_map(alias))