Fixed two crashing bugs: race condition when module was initialized and failing config commands in libapr.

This commit is contained in:
Greg Wroblewski
2013-03-23 23:01:26 -07:00
parent 1ead2f6312
commit a47a4ce4f9
4 changed files with 169 additions and 105 deletions

View File

@@ -20,14 +20,17 @@
// of CMyHttpModule for each request.
class CMyHttpModuleFactory : public IHttpModuleFactory
{
CMyHttpModule * m_pModule;
CMyHttpModule * m_pModule;
CRITICAL_SECTION m_csLock;
public:
CMyHttpModuleFactory()
{
m_pModule = NULL;
InitializeCriticalSection(&m_csLock);
}
virtual
HRESULT
GetHttpModule(
@@ -43,6 +46,8 @@ public:
goto Finished;
}
EnterCriticalSection(&m_csLock);
if(m_pModule == NULL)
{
m_pModule = new CMyHttpModule();
@@ -54,6 +59,8 @@ public:
}
}
LeaveCriticalSection(&m_csLock);
*ppModule = m_pModule;
Finished: