mirror of
https://github.com/reactos/reactos.git
synced 2024-12-27 09:34:43 +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,
|
||||
&ObjectAttributes,
|
||||
(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))
|
||||
{
|
||||
SetLastErrorByStatus(Status);
|
||||
return NULL;
|
||||
SetLastErrorByStatus(Status);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return MutantHandle;
|
||||
|
|
Loading…
Reference in a new issue