From ef1b964826ba47105ef9338dc72a7881a77bf265 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bernhard=20K=C3=B6lbl?= Date: Wed, 2 Aug 2023 21:05:30 +0200 Subject: [PATCH] winegstreamer: Leave media source critical section before unlocking workqueue. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Today, if media_source_Shutdown is called around the same time as a work item is put on the async_commands_queue, we end up in a deadlock if Shutdown enters media source's cs first, as it waits for the queue's callback to finish, which, in turn, waits for the object's cs to be released. To avoid this leave the cs, before unlocking the workqueue, to let any callback on the queue finish running. Signed-off-by: Bernhard Kölbl --- dlls/winegstreamer/media_source.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dlls/winegstreamer/media_source.c b/dlls/winegstreamer/media_source.c index 7b0857158ae..8b9d42ea3f0 100644 --- a/dlls/winegstreamer/media_source.c +++ b/dlls/winegstreamer/media_source.c @@ -1570,10 +1570,10 @@ static HRESULT WINAPI media_source_Shutdown(IMFMediaSource *iface) free(source->descriptors); free(source->streams); - MFUnlockWorkQueue(source->async_commands_queue); - LeaveCriticalSection(&source->cs); + MFUnlockWorkQueue(source->async_commands_queue); + return S_OK; }