- Christoph von Wittich spotted a condition when co_MsqPostKeyboardMessage was called from KeyboardThreadMain, the thread was unlocked when waiting in co_MsqSendMessage. The problem; UserLeave was called before waiting on an event. I added checks to verify locking and if not, lock the thread. I'm not sure ATM if co_MsqPostKeyboardMessage should have full locking since it is only used by input.c.

- Added IdlePing to wakeup process threads before waiting on events, it look like the right place to put them.

svn path=/trunk/; revision=34430
This commit is contained in:
James Tabor 2008-07-11 23:07:31 +00:00
parent f25ac715b0
commit f7a34846ba

View file

@ -64,6 +64,17 @@ static PAGED_LOOKASIDE_LIST TimerLookasideList;
/* FUNCTIONS *****************************************************************/
//
// Wakeup any thread/process waiting on idle input.
//
static VOID FASTCALL
IdlePing(VOID)
{
PW32PROCESS W32d = PsGetCurrentProcessWin32Process();
if (W32d && W32d->InputIdleEvent)
KePulseEvent( W32d->InputIdleEvent, EVENT_INCREMENT, TRUE);
}
HANDLE FASTCALL
IntMsqSetWakeMask(DWORD WakeMask)
{
@ -490,6 +501,8 @@ co_MsqPeekHardwareMessage(PUSER_MESSAGE_QUEUE MessageQueue, HWND hWnd,
WaitObjects[0] = &HardwareMessageQueueLock;
do
{
IdlePing();
UserLeaveCo();
WaitStatus = KeWaitForMultipleObjects(2, WaitObjects, WaitAny, UserRequest,
@ -690,6 +703,9 @@ CLEANUP:
END_CLEANUP;
}
//
// Note: Only called from input.c.
//
VOID FASTCALL
co_MsqPostKeyboardMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
@ -698,6 +714,9 @@ co_MsqPostKeyboardMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
LARGE_INTEGER LargeTickCount;
KBDLLHOOKSTRUCT KbdHookData;
// Condition may arise when calling MsqPostMessage and waiting for an event.
if (!UserIsEntered()) UserEnterExclusive(); // Fixme: Not sure ATM if this thread is locked.
DPRINT("MsqPostKeyboardMessage(uMsg 0x%x, wParam 0x%x, lParam 0x%x)\n",
uMsg, wParam, lParam);
@ -747,6 +766,7 @@ co_MsqPostKeyboardMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
DPRINT("Invalid focus window handle\n");
}
if (UserIsEntered()) UserLeave();
}
VOID FASTCALL
@ -1087,6 +1107,7 @@ co_MsqSendMessage(PUSER_MESSAGE_QUEUE MessageQueue,
if(Block)
{
IdlePing();
UserLeaveCo();
@ -1149,6 +1170,7 @@ co_MsqSendMessage(PUSER_MESSAGE_QUEUE MessageQueue,
WaitObjects[1] = ThreadQueue->NewMessages;
do
{
IdlePing();
UserLeaveCo();
@ -1304,6 +1326,8 @@ co_MsqWaitForNewMessages(PUSER_MESSAGE_QUEUE MessageQueue, HWND WndFilter,
Timeout = NULL;
}
IdlePing(); // Going to wait so send Idle ping.
UserLeaveCo();
ret = KeWaitForMultipleObjects(2,