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 ) ...@@ -69,13 +69,9 @@ void VLCMetadataService::run( std::shared_ptr<Media> file, void* data )
ctx->media.eventManager().onParsedChanged([this, ctx, &status](bool parsed) mutable { ctx->media.eventManager().onParsedChanged([this, ctx, &status](bool parsed) mutable {
if ( parsed == false ) if ( parsed == false )
return; return;
// We are parsing the metadata from a locked context, but the parser thread is waiting for us auto s = handleMediaMeta( ctx->file, ctx->media );
// anyway, so contention isn't really an issue here, since there are only 2 threads involved with std::lock_guard<std::mutex> lock( m_mutex );
// this mutex. status = s;
{
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
m_cond.notify_all(); m_cond.notify_all();
}); });
ctx->media.parseAsync(); ctx->media.parseAsync();
......
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