mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-09-29 19:24:29 +03:00
test-only: Placing a mutex while evaluating the pm operator
Performing an earlier optimization of the tree (before threads creation)
This commit is contained in:
@@ -40,6 +40,7 @@ Pm::~Pm() {
|
||||
|
||||
free(m_p);
|
||||
m_p = NULL;
|
||||
pthread_mutex_destroy(&m_lock);
|
||||
}
|
||||
|
||||
|
||||
@@ -86,8 +87,9 @@ bool Pm::evaluate(Transaction *transaction, Rule *rule,
|
||||
pt.parser = m_p;
|
||||
pt.ptr = NULL;
|
||||
const char *match = NULL;
|
||||
|
||||
pthread_mutex_lock(&m_lock);
|
||||
rc = acmp_process_quick(&pt, &match, input.c_str(), input.length());
|
||||
pthread_mutex_unlock(&m_lock);
|
||||
bool capture = rule && rule->getActionsByName("capture").size() > 0;
|
||||
|
||||
if (rc > 0 && transaction) {
|
||||
@@ -114,6 +116,8 @@ bool Pm::init(const std::string &file, std::string *error) {
|
||||
std::istringstream *iss;
|
||||
const char *err = NULL;
|
||||
|
||||
pthread_mutex_init(&m_lock, NULL);
|
||||
|
||||
char *content = parse_pm_content(m_param.c_str(), m_param.length(), &err);
|
||||
if (content == NULL) {
|
||||
iss = new std::istringstream(m_param);
|
||||
@@ -129,7 +133,9 @@ bool Pm::init(const std::string &file, std::string *error) {
|
||||
acmp_add_pattern(m_p, a.c_str(), NULL, NULL, a.length());
|
||||
}
|
||||
|
||||
acmp_prepare(m_p);
|
||||
while (m_p->is_failtree_done == 0) {
|
||||
acmp_prepare(m_p);
|
||||
}
|
||||
|
||||
if (content) {
|
||||
free(content);
|
||||
|
@@ -55,6 +55,9 @@ class Pm : public Operator {
|
||||
|
||||
protected:
|
||||
ACMP *m_p;
|
||||
|
||||
private:
|
||||
pthread_mutex_t m_lock;
|
||||
};
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user