dpif-netdev: Fix race condition in pmd thread initialization.
authorDaniele Di Proietto <diproiettod@vmware.com>
Wed, 6 Apr 2016 01:02:14 +0000 (18:02 -0700)
committerDaniele Di Proietto <diproiettod@vmware.com>
Mon, 23 May 2016 17:10:23 +0000 (10:10 -0700)
commitd42f9307a08b97f2f5245ce3634843064a2e73e8
treef3d878df0b89a8cfc6d18b50d74b0010a8a04d55
parentb68872d8bbe72dbf97b375ef9a7970712d4ef82c
dpif-netdev: Fix race condition in pmd thread initialization.

The pmds and the main threads are synchronized using a condition
variable.  The main thread writes a new configuration, then it waits on
the condition variable.  A pmd thread reads the new configuration, then
it calls signal() on the condition variable. To make sure that the pmds
and the main thread have a consistent view, each signal() should be
backed by a wait().

Currently the first signal() doesn't have a corresponding wait().  If
the pmd thread takes a long time to start and the signal() is received
by a later wait, the threads will have an inconsistent view.

The commit fixes the problem by removing the first signal() from the
pmd thread.

This is hardly a problem on current master, because the main thread
will call the first wait() a long time after the creation of a pmd
thread.  It becomes a problem with the next commits.

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>
lib/dpif-netdev.c