dpif-netdev: Fix improper use of CMAP_FOR_EACH.
authorDaniele Di Proietto <diproiettod@vmware.com>
Wed, 27 Jan 2016 02:53:52 +0000 (18:53 -0800)
committerDaniele Di Proietto <diproiettod@vmware.com>
Wed, 3 Feb 2016 04:58:37 +0000 (20:58 -0800)
commitc0e327583c133acf6bdaa3cbbdcb154d92c08f31
treec775bcb0ae01b52df9baed26169ca4bcf1557131
parentc649a3c51edb76926e7f76a49f869395e8ce7200
dpif-netdev: Fix improper use of CMAP_FOR_EACH.

It is ok to iterate a cmap with CMAP_FOR_EACH and remove elements with
cmap_remove(), but having quiescent states inside the loop might create
problems, since some of the postponed cleanup done inside the cmap might
be executed, freeing the memory that the iterator is using.

We had several of these errors in dpif-netdev, because when we rearrange
ports or threads we often need to wait on a condition variable (which
implies a quiescent state).

This problem caused iterations to skip elements or to list them twice,
resulting in the main thread waiting on a condition without anyone else
to signal.

Fix these cases by moving the possible quiescent states outside
CMAP_FOR_EACH loops.

Signed-off-by: Daniele Di Proietto <diproiettod@vmware.com>
Tested-by: Ilya Maximets <i.maximets@samsung.com>
Acked-by: Ilya Maximets <i.maximets@samsung.com>
Acked-by: Jarno Rajahalme <jarno@ovn.org>
lib/dpif-netdev.c