If a mutex already exist, open it instead of create.

svn path=/trunk/; revision=16901
This commit is contained in:
Hartmut Birr 2005-07-30 19:03:34 +00:00
parent 65c8fe4c15
commit 2e4f8bfdb1

View file

@ -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;