input/Open: use ScopeLock

This commit is contained in:
Max Kellermann 2016-09-09 16:11:51 +02:00
parent 38d587aaeb
commit 3143dbf3dc

View File

@ -67,10 +67,13 @@ InputStream::OpenReady(const char *uri,
if (is == nullptr) if (is == nullptr)
return nullptr; return nullptr;
mutex.lock(); bool success;
is->WaitReady();
bool success = is->Check(error); {
mutex.unlock(); const ScopeLock protect(mutex);
is->WaitReady();
success = is->Check(error);
}
if (!success) if (!success)
is.reset(); is.reset();