critical section blocking
Aric Stewart
aric at codeweavers.com
Thu May 24 16:08:24 CDT 2001
Working with QuickTime5 I found a situation where mouse messages could
lockup wine. This leaving and entering the critical section resolves
that bug.
-aric
-------------- next part --------------
Index: windows/message.c
===================================================================
RCS file: /home/wine/wine/windows/message.c,v
retrieving revision 1.106
diff -u -u -r1.106 message.c
--- windows/message.c 2001/05/22 19:55:20 1.106
+++ windows/message.c 2001/05/24 20:46:27
@@ -603,12 +603,32 @@
HWND hWndScope = (HWND)qmsg->extraInfo;
WND *tmpWnd = IsWindow(hWndScope) ? WIN_FindWndPtr(hWndScope) : WIN_GetDesktop();
+ /*
+ * We cannot hold onto the critical section during translation
+ * of the mouse message because it includes a call that have
+ * then call sendmessage into other threads and we can deadlock
+ */
+ LeaveCriticalSection(&sysMsgQueue->cSection);
status = MSG_TranslateMouseMsg(hwnd, first, last, msg, remove, tmpWnd,
&hittest, &screen_pt, &mouseClick );
- msgType = MOUSE_MSG;
+ EnterCriticalSection(&sysMsgQueue->cSection);
+ /*
+ * If the message was removed earlier set up nextqmsg so that
+ * we start
+ * at the top of the queue again. We need to do this since
+ * our next pointer
+ * could be invalid due to us unlocking the system message Q
+ * to process the message.
+ * If not removed just refresh nextqmsg to point to the next msg.
+ */
+ if (remove)
+ nextqmsg = sysMsgQueue->firstMsg;
+ else
+ nextqmsg = qmsg->nextMsg;
+
+ msgType = MOUSE_MSG;
WIN_ReleaseWndPtr(tmpWnd);
-
}
else if ((msg->message >= WM_KEYFIRST) && (msg->message <= WM_KEYLAST))
{
More information about the wine-patches
mailing list