storage/nfs: fix deadlock when connecting

The Connect method can be called between Schedule and lock. In that case, when
locked, the state is already set to CONNECTING of READY and the condition won't
be signaled anymore.
This commit is contained in:
Thomas Guillem
2015-05-09 15:59:31 +02:00
committed by Max Kellermann
parent aed0af1e00
commit 3436a646b5
2 changed files with 4 additions and 2 deletions

View File

@@ -177,6 +177,8 @@ private:
mutex.unlock();
DeferredMonitor::Schedule();
mutex.lock();
if (state == State::INITIAL)
cond.wait(mutex);
break;
case State::CONNECTING:
@@ -188,8 +190,6 @@ private:
error.Set(last_error);
return false;
}
cond.wait(mutex);
}
}