Commit c13e5fe4 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen
Browse files

Fix potential deadlock

If handleMediaMeta is blocking, the timeout will try to acquire the sync
mutex, but won't manage to do so.
However, this only allows the parser to continue, but my guess would be
that there will still be a thread blocked somewhere
parent be714f51
......@@ -69,13 +69,9 @@ void VLCMetadataService::run( std::shared_ptr<Media> file, void* data )
ctx->media.eventManager().onParsedChanged([this, ctx, &status](bool parsed) mutable {
if ( parsed == false )
// We are parsing the metadata from a locked context, but the parser thread is waiting for us
// anyway, so contention isn't really an issue here, since there are only 2 threads involved with
// this mutex.
std::unique_lock<std::mutex> lock( m_mutex );
status = handleMediaMeta( ctx->file, ctx->media );
} // unlock early to avoid the waiting thread to be blocked again
auto s = handleMediaMeta( ctx->file, ctx->media );
std::lock_guard<std::mutex> lock( m_mutex );
status = s;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment