mirror of
https://github.com/reactos/reactos.git
synced 2024-08-04 18:40:59 +00:00
[NTVDM]
Fix race conditions. svn path=/branches/ntvdm/; revision=61230
This commit is contained in:
parent
1b784a5b7b
commit
0f83939238
|
@ -32,10 +32,10 @@ static HANDLE InputThread = NULL;
|
||||||
static BOOLEAN KeyboardQueuePush(BYTE ScanCode)
|
static BOOLEAN KeyboardQueuePush(BYTE ScanCode)
|
||||||
{
|
{
|
||||||
/* Check if the keyboard queue is full */
|
/* Check if the keyboard queue is full */
|
||||||
if (!KeyboardQueueEmpty && (KeyboardQueueStart == KeyboardQueueEnd)) return FALSE;
|
|
||||||
|
|
||||||
WaitForSingleObject(QueueMutex, INFINITE);
|
WaitForSingleObject(QueueMutex, INFINITE);
|
||||||
|
|
||||||
|
if (!KeyboardQueueEmpty && (KeyboardQueueStart == KeyboardQueueEnd)) return FALSE;
|
||||||
|
|
||||||
/* Insert the value in the queue */
|
/* Insert the value in the queue */
|
||||||
KeyboardQueue[KeyboardQueueEnd] = ScanCode;
|
KeyboardQueue[KeyboardQueueEnd] = ScanCode;
|
||||||
KeyboardQueueEnd++;
|
KeyboardQueueEnd++;
|
||||||
|
@ -50,11 +50,19 @@ static BOOLEAN KeyboardQueuePush(BYTE ScanCode)
|
||||||
|
|
||||||
static BOOLEAN KeyboardQueuePop(BYTE *ScanCode)
|
static BOOLEAN KeyboardQueuePop(BYTE *ScanCode)
|
||||||
{
|
{
|
||||||
|
BOOLEAN Result = TRUE;
|
||||||
|
|
||||||
/* Make sure the keyboard queue is not empty */
|
/* Make sure the keyboard queue is not empty */
|
||||||
if (KeyboardQueueEmpty) return FALSE;
|
if (KeyboardQueueEmpty) return FALSE;
|
||||||
|
|
||||||
WaitForSingleObject(QueueMutex, INFINITE);
|
WaitForSingleObject(QueueMutex, INFINITE);
|
||||||
|
|
||||||
|
if (KeyboardQueueEmpty)
|
||||||
|
{
|
||||||
|
Result = FALSE;
|
||||||
|
goto Done;
|
||||||
|
}
|
||||||
|
|
||||||
/* Get the scan code */
|
/* Get the scan code */
|
||||||
*ScanCode = KeyboardQueue[KeyboardQueueStart];
|
*ScanCode = KeyboardQueue[KeyboardQueueStart];
|
||||||
|
|
||||||
|
@ -68,8 +76,9 @@ static BOOLEAN KeyboardQueuePop(BYTE *ScanCode)
|
||||||
KeyboardQueueEmpty = TRUE;
|
KeyboardQueueEmpty = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Done:
|
||||||
ReleaseMutex(QueueMutex);
|
ReleaseMutex(QueueMutex);
|
||||||
return TRUE;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* PUBLIC FUNCTIONS ***********************************************************/
|
/* PUBLIC FUNCTIONS ***********************************************************/
|
||||||
|
|
Loading…
Reference in a new issue