Skip to content

Commit

Permalink
[1.8>1.9] [MERGE #4643 @MikeHolman] fix race condition where multiple…
Browse files Browse the repository at this point in the history
… threads simultaneously connect

Merge pull request #4643 from MikeHolman:connectrace
  • Loading branch information
MikeHolman committed Feb 6, 2018
2 parents a92d32a + dbce2eb commit e4493a2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
13 changes: 5 additions & 8 deletions lib/JITClient/JITManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,20 +226,17 @@ JITManager::IsOOPJITEnabled() const
HRESULT
JITManager::ConnectRpcServer(__in HANDLE jitProcessHandle, __in_opt void* serverSecurityDescriptor, __in UUID connectionUuid)
{
// We might be trying to connect from multiple threads simultaneously
AutoCriticalSection cs(&m_cs);

Assert(IsOOPJITEnabled());
if(m_rpcBindingHandle != nullptr)
if (m_rpcBindingHandle != nullptr)
{
// TODO: change this to allow connecting a new JIT process to new ThreadContexts
return E_FAIL;
return S_OK;
}

HRESULT hr = E_FAIL;

if (IsConnected())
{
Assert(UNREACHED);
return E_FAIL;
}

hr = CreateBinding(jitProcessHandle, serverSecurityDescriptor, &connectionUuid, &m_rpcBindingHandle);
if (FAILED(hr))
Expand Down
1 change: 1 addition & 0 deletions lib/JITClient/JITManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ class JITManager
bool m_oopJitEnabled;
bool m_isJITServer;
HRESULT m_failingHRESULT;
CriticalSection m_cs;

static JITManager s_jitManager;

Expand Down

0 comments on commit e4493a2

Please sign in to comment.