After adding the read callback the state is WATCHER_QUEUED and it is
switched to WATCHER_RUNNING only later by an asynchronous job. This means
that a thread that sent a Netlink message shortly after registration
might see the state as WATCHER_QUEUED. If it then tries to read the
response and the watcher thread is quicker to actually read the message
from the socket, it could block on recv() while still holding the lock.
And the asynchronous job that actually read the message and tries to queue
it will block while trying to acquire the lock, so we'd end up in a deadlock.
This is probably mostly a problem in the unit tests.
while (!entry->complete)
{
if (this->parallel &&
- lib->watcher->get_state(lib->watcher) == WATCHER_RUNNING)
+ lib->watcher->get_state(lib->watcher) != WATCHER_STOPPED)
{
if (this->timeout)
{