When calling CreateMutex() handle the case when the mutex is already
created in another process.
This commit is contained in:
parent
f6d3d0172d
commit
8b37dbb75c
@ -379,14 +379,15 @@ DWORD IncrementInstanceId( DDE_HANDLE_ENTRY *this_instance)
|
|||||||
s_attrib.bInheritHandle = TRUE;
|
s_attrib.bInheritHandle = TRUE;
|
||||||
s_attrib.lpSecurityDescriptor = NULL;
|
s_attrib.lpSecurityDescriptor = NULL;
|
||||||
s_attrib.nLength = sizeof(s_attrib);
|
s_attrib.nLength = sizeof(s_attrib);
|
||||||
inst_count_mutex = CreateMutexA(&s_attrib,1,DDEInstanceAccess); /* 1st time through */
|
inst_count_mutex = CreateMutexA(&s_attrib,0,DDEInstanceAccess); /* 1st time through */
|
||||||
} else {
|
}
|
||||||
|
if ( inst_count_mutex )
|
||||||
|
{
|
||||||
if ( !WaitForMutex(inst_count_mutex) )
|
if ( !WaitForMutex(inst_count_mutex) )
|
||||||
{
|
{
|
||||||
return DMLERR_SYS_ERROR;
|
return DMLERR_SYS_ERROR;
|
||||||
}
|
}
|
||||||
}
|
} else
|
||||||
if ( !inst_count_mutex )
|
|
||||||
{
|
{
|
||||||
ERR("CreateMutex failed - inst_count %li\n",GetLastError());
|
ERR("CreateMutex failed - inst_count %li\n",GetLastError());
|
||||||
Release_reserved_mutex (handle_mutex,"handle_mutex",0,1,this_instance);
|
Release_reserved_mutex (handle_mutex,"handle_mutex",0,1,this_instance);
|
||||||
@ -606,23 +607,22 @@ UINT WINAPI DdeInitializeW( LPDWORD pidInst, PFNCALLBACK pfnCallback,
|
|||||||
TRACE("new instance, callback %p flags %lX\n",pfnCallback,afCmd);
|
TRACE("new instance, callback %p flags %lX\n",pfnCallback,afCmd);
|
||||||
if ( DDE_Max_Assigned_Instance == 0 )
|
if ( DDE_Max_Assigned_Instance == 0 )
|
||||||
{
|
{
|
||||||
/* Nothing has been initialised - exit now ! can return TRUE since effect is the same */
|
/* Nothing has been initialised - exit now ! can return TRUE since effect is the same */
|
||||||
/* Need to set up Mutex in case it is not already present */
|
/* Need to set up Mutex in case it is not already present */
|
||||||
s_att->bInheritHandle = TRUE;
|
s_att->bInheritHandle = TRUE;
|
||||||
s_att->lpSecurityDescriptor = NULL;
|
s_att->lpSecurityDescriptor = NULL;
|
||||||
s_att->nLength = sizeof(s_att);
|
s_att->nLength = sizeof(s_att);
|
||||||
handle_mutex = CreateMutexA(s_att,1,DDEHandleAccess);
|
handle_mutex = CreateMutexA(s_att,0,DDEHandleAccess);
|
||||||
if ( !handle_mutex ) {
|
if ( !handle_mutex ) {
|
||||||
ERR("CreateMutex failed - handle list %li\n",GetLastError());
|
ERR("CreateMutex failed - handle list %li\n",GetLastError());
|
||||||
HeapFree(GetProcessHeap(), 0, this_instance);
|
HeapFree(GetProcessHeap(), 0, this_instance);
|
||||||
return DMLERR_SYS_ERROR;
|
return DMLERR_SYS_ERROR;
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
if ( !WaitForMutex(handle_mutex) )
|
if ( !WaitForMutex(handle_mutex) )
|
||||||
{
|
{
|
||||||
return DMLERR_SYS_ERROR;
|
return DMLERR_SYS_ERROR;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
TRACE("Handle Mutex created/reserved\n");
|
TRACE("Handle Mutex created/reserved\n");
|
||||||
if (DDE_Handle_Table_Base == NULL )
|
if (DDE_Handle_Table_Base == NULL )
|
||||||
|
Loading…
x
Reference in New Issue
Block a user