Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3dfd46d

Browse files
committed
IIS: no lock on ProcessRequest. No reload of config. (microsoft#24)
IIS: no lock on ProcessRequest. No reload of config.
1 parent20c9086 commit3dfd46d

File tree

3 files changed

+26
-53
lines changed

3 files changed

+26
-53
lines changed

‎iis/moduleconfig.cpp‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -466,11 +466,8 @@ MODSECURITY_STORED_CONTEXT::~MODSECURITY_STORED_CONTEXT()
466466
MODSECURITY_STORED_CONTEXT::MODSECURITY_STORED_CONTEXT():
467467
m_bIsEnabled (FALSE ),
468468
m_pszPath(NULL ),
469-
m_Config(NULL ),
470-
m_dwLastCheck(0 )
469+
m_Config(NULL )
471470
{
472-
m_LastChange.dwLowDateTime =0;
473-
m_LastChange.dwHighDateTime =0;
474471
}
475472

476473
DWORD

‎iis/moduleconfig.h‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,6 @@ class MODSECURITY_STORED_CONTEXT : public IHttpStoredContext
6868
USHORT* pdwLengthDestination );
6969

7070
void* m_Config;
71-
DWORD m_dwLastCheck;
72-
FILETIME m_LastChange;
7371

7472
private:
7573
HRESULT

‎iis/mymodule.cpp‎

Lines changed: 25 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -810,19 +810,8 @@ CMyHttpModule::OnBeginRequest(
810810
}
811811
EnterCriticalSection(&m_csLock);
812812

813-
// Get the config again, in case it changed during the time we released the lock
814-
hr =MODSECURITY_STORED_CONTEXT::GetConfig(pHttpContext, &pConfig);
815-
if (FAILED(hr))
816-
{
817-
hr = S_OK;
818-
goto Finished;
819-
}
820813

821-
// every 3 seconds we check for changes in config file
822-
//
823-
DWORD ctime =GetTickCount();
824-
825-
if(pConfig->m_Config ==NULL || (ctime - pConfig->m_dwLastCheck) >3000)
814+
if(pConfig->m_Config ==NULL)
826815
{
827816
char *path;
828817
USHORT pathlen;
@@ -835,55 +824,42 @@ CMyHttpModule::OnBeginRequest(
835824
goto Finished;
836825
}
837826

838-
WIN32_FILE_ATTRIBUTE_DATA fdata;
839-
BOOL ret;
827+
pConfig->m_Config =modsecGetDefaultConfig();
840828

841-
ret =GetFileAttributesEx(path, GetFileExInfoStandard, &fdata);
829+
PCWSTR servpath = pHttpContext->GetApplication()->GetApplicationPhysicalPath();
830+
char *apppath;
831+
USHORT apppathlen;
842832

843-
pConfig->m_dwLastCheck = ctime;
833+
hr =pConfig->GlobalWideCharToMultiByte((WCHAR *)servpath,wcslen(servpath), &apppath, &apppathlen);
844834

845-
if(pConfig->m_Config ==NULL || (ret !=0 && (pConfig->m_LastChange.dwLowDateTime != fdata.ftLastWriteTime.dwLowDateTime ||
846-
pConfig->m_LastChange.dwHighDateTime != fdata.ftLastWriteTime.dwHighDateTime)))
835+
if (FAILED( hr ) )
847836
{
848-
pConfig->m_LastChange.dwLowDateTime = fdata.ftLastWriteTime.dwLowDateTime;
849-
pConfig->m_LastChange.dwHighDateTime = fdata.ftLastWriteTime.dwHighDateTime;
850-
851-
pConfig->m_Config =modsecGetDefaultConfig();
852-
853-
PCWSTR servpath = pHttpContext->GetApplication()->GetApplicationPhysicalPath();
854-
char *apppath;
855-
USHORT apppathlen;
837+
delete path;
838+
hr = E_UNEXPECTED;
839+
goto Finished;
840+
}
856841

857-
hr = pConfig->GlobalWideCharToMultiByte((WCHAR *)servpath,wcslen(servpath), &apppath, &apppathlen);
842+
if(path[0] !=0)
843+
{
844+
constchar * err =modsecProcessConfig((directory_config *)pConfig->m_Config, path, apppath);
858845

859-
if (FAILED( hr ))
846+
if(err !=NULL)
860847
{
848+
WriteEventViewerLog(err, EVENTLOG_ERROR_TYPE);
849+
delete apppath;
861850
delete path;
862-
hr = E_UNEXPECTED;
863851
goto Finished;
864852
}
865853

866-
if(path[0] !=0)
854+
modsecReportRemoteLoadedRules();
855+
if (this->status_call_already_sent ==false)
867856
{
868-
constchar * err =modsecProcessConfig((directory_config *)pConfig->m_Config, path, apppath);
869-
870-
if(err !=NULL)
871-
{
872-
WriteEventViewerLog(err, EVENTLOG_ERROR_TYPE);
873-
delete apppath;
874-
delete path;
875-
goto Finished;
876-
}
877-
878-
modsecReportRemoteLoadedRules();
879-
if (this->status_call_already_sent ==false)
880-
{
881-
this->status_call_already_sent =true;
882-
modsecStatusEngineCall();
883-
}
857+
this->status_call_already_sent =true;
858+
modsecStatusEngineCall();
884859
}
885-
delete apppath;
886860
}
861+
862+
delete apppath;
887863
delete path;
888864
}
889865

@@ -1140,7 +1116,9 @@ CMyHttpModule::OnBeginRequest(
11401116
#endif
11411117
c->remote_host =NULL;
11421118

1119+
LeaveCriticalSection(&m_csLock);
11431120
int status =modsecProcessRequest(r);
1121+
EnterCriticalSection(&m_csLock);
11441122

11451123
if(status != DECLINED)
11461124
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp