mirror of
https://github.com/reactos/reactos.git
synced 2026-10-20 09:41:49 +08:00
[KERNEL32] Make creation of a default timer queue thread safe
This commit is contained in:
committed by
George Bișoc
parent
3f14a78b4f
commit
73e69a62d3
@@ -19,15 +19,19 @@ HANDLE BasepDefaultTimerQueue = NULL;
|
||||
|
||||
/* PRIVATE FUNCTIONS **********************************************************/
|
||||
|
||||
/* FIXME - make this thread safe */
|
||||
BOOL
|
||||
WINAPI
|
||||
BasepCreateDefaultTimerQueue(VOID)
|
||||
{
|
||||
NTSTATUS Status;
|
||||
HANDLE TimerQueue;
|
||||
|
||||
/* Already initialized */
|
||||
if (BasepDefaultTimerQueue != NULL)
|
||||
return TRUE;
|
||||
|
||||
/* Create the timer queue */
|
||||
Status = RtlCreateTimerQueue(&BasepDefaultTimerQueue);
|
||||
Status = RtlCreateTimerQueue(&TimerQueue);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
BaseSetLastNTError(Status);
|
||||
@@ -35,6 +39,14 @@ BasepCreateDefaultTimerQueue(VOID)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Try to publish it. If another thread already did, throw ours away */
|
||||
if (InterlockedCompareExchangePointer((PVOID *)&BasepDefaultTimerQueue,
|
||||
TimerQueue,
|
||||
NULL) != NULL)
|
||||
{
|
||||
RtlDeleteTimerQueueEx(TimerQueue, NULL);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user