mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-09-29 19:24:29 +03:00
Makes pm mutex optional via configuration flag
This commit is contained in:
@@ -40,7 +40,9 @@ Pm::~Pm() {
|
||||
|
||||
free(m_p);
|
||||
m_p = NULL;
|
||||
#ifdef MODSEC_MUTEX_ON_PM
|
||||
pthread_mutex_destroy(&m_lock);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -87,9 +89,13 @@ bool Pm::evaluate(Transaction *transaction, Rule *rule,
|
||||
pt.parser = m_p;
|
||||
pt.ptr = NULL;
|
||||
const char *match = NULL;
|
||||
#ifdef MODSEC_MUTEX_ON_PM
|
||||
pthread_mutex_lock(&m_lock);
|
||||
#endif
|
||||
rc = acmp_process_quick(&pt, &match, input.c_str(), input.length());
|
||||
#ifdef MODSEC_MUTEX_ON_PM
|
||||
pthread_mutex_unlock(&m_lock);
|
||||
#endif
|
||||
bool capture = rule && rule->getActionsByName("capture").size() > 0;
|
||||
|
||||
if (rc > 0 && transaction) {
|
||||
@@ -116,8 +122,9 @@ bool Pm::init(const std::string &file, std::string *error) {
|
||||
std::istringstream *iss;
|
||||
const char *err = NULL;
|
||||
|
||||
#ifdef MODSEC_MUTEX_ON_PM
|
||||
pthread_mutex_init(&m_lock, NULL);
|
||||
|
||||
#endif
|
||||
char *content = parse_pm_content(m_param.c_str(), m_param.length(), &err);
|
||||
if (content == NULL) {
|
||||
iss = new std::istringstream(m_param);
|
||||
|
@@ -56,8 +56,10 @@ class Pm : public Operator {
|
||||
protected:
|
||||
ACMP *m_p;
|
||||
|
||||
#ifdef MODSEC_MUTEX_ON_PM
|
||||
private:
|
||||
pthread_mutex_t m_lock;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user