mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 01:55:19 +00:00
If a mutex already exist, open it instead of create.
svn path=/trunk/; revision=16901
This commit is contained in:
parent
65c8fe4c15
commit
2e4f8bfdb1
1 changed files with 16 additions and 2 deletions
|
@ -92,10 +92,24 @@ CreateMutexW(LPSECURITY_ATTRIBUTES lpMutexAttributes,
|
||||||
MUTEX_ALL_ACCESS,
|
MUTEX_ALL_ACCESS,
|
||||||
&ObjectAttributes,
|
&ObjectAttributes,
|
||||||
(BOOLEAN)bInitialOwner);
|
(BOOLEAN)bInitialOwner);
|
||||||
|
if (Status == STATUS_OBJECT_NAME_COLLISION)
|
||||||
|
{
|
||||||
|
Status = NtOpenMutant(&MutantHandle,
|
||||||
|
MUTEX_ALL_ACCESS,
|
||||||
|
&ObjectAttributes);
|
||||||
|
if (NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
if(bInitialOwner)
|
||||||
|
{
|
||||||
|
WaitForSingleObject(MutantHandle, INFINITE);
|
||||||
|
}
|
||||||
|
SetLastError(ERROR_ALREADY_EXISTS);
|
||||||
|
}
|
||||||
|
}
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
SetLastErrorByStatus(Status);
|
SetLastErrorByStatus(Status);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return MutantHandle;
|
return MutantHandle;
|
||||||
|
|
Loading…
Reference in a new issue