Another crash removed. Patch by Mike Nordell.

svn path=/trunk/; revision=7010
This commit is contained in:
Thomas Bluemel 2003-12-14 00:45:39 +00:00
parent b295839f98
commit 78f6e71be8

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
/* $Id: msgqueue.c,v 1.42 2003/12/12 14:22:37 gvg Exp $ /* $Id: msgqueue.c,v 1.43 2003/12/14 00:45:39 weiden Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -58,7 +58,7 @@ static ULONG SystemMessageQueueCount = 0;
static ULONG SystemMessageQueueMouseMove = -1; static ULONG SystemMessageQueueMouseMove = -1;
static KSPIN_LOCK SystemMessageQueueLock; static KSPIN_LOCK SystemMessageQueueLock;
static ULONG HardwareMessageQueueStamp = 0; static ULONG volatile HardwareMessageQueueStamp = 0;
static LIST_ENTRY HardwareMessageQueueHead; static LIST_ENTRY HardwareMessageQueueHead;
static FAST_MUTEX HardwareMessageQueueLock; static FAST_MUTEX HardwareMessageQueueLock;
@ -150,6 +150,8 @@ MsqInsertSystemMessage(MSG* Msg, BOOL RemMouseMoveMsg)
while (mmov != SystemMessageQueueHead ) while (mmov != SystemMessageQueueHead )
{ {
ULONG prev = mmov ? mmov - 1 : SYSTEM_MESSAGE_QUEUE_SIZE - 1; ULONG prev = mmov ? mmov - 1 : SYSTEM_MESSAGE_QUEUE_SIZE - 1;
ASSERT(mmov >= 0);
ASSERT(mmov < SYSTEM_MESSAGE_QUEUE_SIZE);
SystemMessageQueue[mmov] = SystemMessageQueue[prev]; SystemMessageQueue[mmov] = SystemMessageQueue[prev];
mmov = prev; mmov = prev;
} }
@ -355,12 +357,14 @@ MsqPeekHardwareMessage(PUSER_MESSAGE_QUEUE MessageQueue, HWND hWnd,
BOOL Accept; BOOL Accept;
BOOL MouseClick; BOOL MouseClick;
PLIST_ENTRY CurrentEntry; PLIST_ENTRY CurrentEntry;
ULONG ActiveStamp;
PWINDOW_OBJECT DesktopWindow; PWINDOW_OBJECT DesktopWindow;
if( !IntGetScreenDC() || if( !IntGetScreenDC() ||
PsGetWin32Thread()->MessageQueue == W32kGetPrimitiveMessageQueue() ) PsGetWin32Thread()->MessageQueue == W32kGetPrimitiveMessageQueue() )
{
return FALSE; return FALSE;
}
DesktopWindow = IntGetWindowObject(IntGetDesktopWindow()); DesktopWindow = IntGetWindowObject(IntGetDesktopWindow());
/* Process messages in the message queue itself. */ /* Process messages in the message queue itself. */
@ -402,12 +406,15 @@ MsqPeekHardwareMessage(PUSER_MESSAGE_QUEUE MessageQueue, HWND hWnd,
PUSER_MESSAGE UserMsg; PUSER_MESSAGE UserMsg;
MSG Msg; MSG Msg;
ASSERT(SystemMessageQueueHead < SYSTEM_MESSAGE_QUEUE_SIZE);
Msg = SystemMessageQueue[SystemMessageQueueHead]; Msg = SystemMessageQueue[SystemMessageQueueHead];
SystemMessageQueueHead = SystemMessageQueueHead =
(SystemMessageQueueHead + 1) % SYSTEM_MESSAGE_QUEUE_SIZE; (SystemMessageQueueHead + 1) % SYSTEM_MESSAGE_QUEUE_SIZE;
SystemMessageQueueCount--; SystemMessageQueueCount--;
KeReleaseSpinLock(&SystemMessageQueueLock, OldIrql); KeReleaseSpinLock(&SystemMessageQueueLock, OldIrql);
UserMsg = ExAllocateFromPagedLookasideList(&MessageLookasideList); UserMsg = ExAllocateFromPagedLookasideList(&MessageLookasideList);
/* What to do if out of memory? For now we just panic a bit in debug */
ASSERT(UserMsg);
UserMsg->Msg = Msg; UserMsg->Msg = Msg;
InsertTailList(&HardwareMessageQueueHead, &UserMsg->ListEntry); InsertTailList(&HardwareMessageQueueHead, &UserMsg->ListEntry);
KeAcquireSpinLock(&SystemMessageQueueLock, &OldIrql); KeAcquireSpinLock(&SystemMessageQueueLock, &OldIrql);
@ -417,8 +424,8 @@ MsqPeekHardwareMessage(PUSER_MESSAGE_QUEUE MessageQueue, HWND hWnd,
* this is more efficient and just as effective. * this is more efficient and just as effective.
*/ */
SystemMessageQueueMouseMove = -1; SystemMessageQueueMouseMove = -1;
KeReleaseSpinLock(&SystemMessageQueueLock, OldIrql);
HardwareMessageQueueStamp++; HardwareMessageQueueStamp++;
KeReleaseSpinLock(&SystemMessageQueueLock, OldIrql);
/* Process messages in the queue until we find one to return. */ /* Process messages in the queue until we find one to return. */
CurrentEntry = HardwareMessageQueueHead.Flink; CurrentEntry = HardwareMessageQueueHead.Flink;
@ -428,10 +435,11 @@ MsqPeekHardwareMessage(PUSER_MESSAGE_QUEUE MessageQueue, HWND hWnd,
CONTAINING_RECORD(CurrentEntry, USER_MESSAGE, ListEntry); CONTAINING_RECORD(CurrentEntry, USER_MESSAGE, ListEntry);
CurrentEntry = CurrentEntry->Flink; CurrentEntry = CurrentEntry->Flink;
RemoveEntryList(&Current->ListEntry); RemoveEntryList(&Current->ListEntry);
HardwareMessageQueueStamp++;
if (Current->Msg.message >= WM_MOUSEFIRST && if (Current->Msg.message >= WM_MOUSEFIRST &&
Current->Msg.message <= WM_MOUSELAST) Current->Msg.message <= WM_MOUSELAST)
{ {
ActiveStamp = HardwareMessageQueueStamp; const ULONG ActiveStamp = HardwareMessageQueueStamp;
ExReleaseFastMutex(&HardwareMessageQueueLock); ExReleaseFastMutex(&HardwareMessageQueueLock);
/* Translate the message. */ /* Translate the message. */
Accept = MsqTranslateMouseMessage(hWnd, FilterLow, FilterHigh, Accept = MsqTranslateMouseMessage(hWnd, FilterLow, FilterHigh,