[vlc-devel] [PATCH] Win32: dispatch thread messages while waiting or leeping
Rémi Denis-Courmont
remi at remlab.net
Sat Jul 23 14:32:08 CEST 2011
This change was requested to fix deadlocks in some LibVLC applications
(see http://forum.videolan.org/viewtopic.php?f=32&t=87932 ) that do
create windows from any thread that calls LibVLC.
Then again, this change may introduce some interesting reentrancy
problems. I am a bit skeptic. A middle ground could consist of
dispatching messages only for threads _not_ created by LibVLC.
---
src/win32/thread.c | 14 +++++++++++++-
1 files changed, 13 insertions(+), 1 deletions(-)
diff --git a/src/win32/thread.c b/src/win32/thread.c
index 00c2781..f4521b1 100644
--- a/src/win32/thread.c
+++ b/src/win32/thread.c
@@ -125,7 +125,19 @@ BOOL WINAPI DllMain (HINSTANCE hinstDll, DWORD fdwReason, LPVOID lpvReserved)
static DWORD vlc_WaitForMultipleObjects (DWORD count, const HANDLE *handles,
DWORD delay)
{
- DWORD ret = WaitForMultipleObjectsEx (count, handle, FALSE, delay, TRUE);
+ DWORD ret = MsgWaitForMultipleObjectsEx (count, handle, delay,
+ QS_ALLINPUT, MWMO_ALTERTABLE);
+ if (ret == WAIT_OBJECT_0 + count)
+ {
+ MSG msg;
+
+ while (PeekMessage (&msg, NULL, 0, 0, PM_REMOVE))
+ {
+ TranslateMessage (&msg);
+ DispatchMessage (&msg);
+ }
+ ret = WAIT_IO_COMPLETION;
+ }
/* We do not abandon objects... this would be a bug */
assert (ret < WAIT_ABANDONED_0 || WAIT_ABONDONED_0 + count - 1 < ret);
--
1.7.5.4
More information about the vlc-devel
mailing list