fixing double locking issue (#637)

This commit is contained in:
pan-wang 2018-03-07 12:02:04 -08:00 committed by GitHub
parent f32addd408
commit 419ae06935
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 3 deletions

View File

@ -150,13 +150,17 @@ IN_PROCESS_APPLICATION::Recycle(
VOID VOID
) )
{ {
BOOL fLockAcquired = FALSE;
// We need to guarantee that recycle is only called once, as calling pHttpServer->RecycleProcess // We need to guarantee that recycle is only called once, as calling pHttpServer->RecycleProcess
// multiple times can lead to AVs. // multiple times can lead to AVs.
if (m_fRecycleCalled) if (m_fRecycleCalled)
{ {
return; goto Finished;
} }
AcquireSRWLockExclusive(&m_srwLock); AcquireSRWLockExclusive(&m_srwLock);
fLockAcquired = TRUE;
if (m_fRecycleCalled) if (m_fRecycleCalled)
{ {
goto Finished; goto Finished;
@ -170,12 +174,20 @@ IN_PROCESS_APPLICATION::Recycle(
else else
{ {
// IISExpress scenario // IISExpress scenario
// Can only call exit to terminate current process // Release the lock first as Shutdown will acquire lock later
ReleaseSRWLockExclusive(&m_srwLock);
fLockAcquired = FALSE;
// Shutdown the managed application and call exit to terminate current process
ShutDown(); ShutDown();
exit(0); exit(0);
} }
Finished: Finished:
ReleaseSRWLockExclusive(&m_srwLock); if (fLockAcquired)
{
ReleaseSRWLockExclusive(&m_srwLock);
}
} }
REQUEST_NOTIFICATION_STATUS REQUEST_NOTIFICATION_STATUS