From f2d16aafe9d2ef5b09e4efdb5bed27c8243d93c7 Mon Sep 17 00:00:00 2001 From: brectanus Date: Thu, 14 Jun 2007 17:39:49 +0000 Subject: [PATCH] Add rule temporary memory pool fix from trunk. --- CHANGES | 2 ++ apache2/re.c | 16 ++++++++++------ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/CHANGES b/CHANGES index 4c92c404..0df1314b 100644 --- a/CHANGES +++ b/CHANGES @@ -21,6 +21,8 @@ * Added SecAuditLog2 directive to allow redundent concurrent audit log index files. This will allow sending audit data to two consoles, etc. + * Small performance improvement in memory management for rule execution. + 11 Apr 2007 - 2.1.1 ------------------- diff --git a/apache2/re.c b/apache2/re.c index c877e672..08bc70b8 100644 --- a/apache2/re.c +++ b/apache2/re.c @@ -1251,12 +1251,16 @@ apr_status_t msre_rule_process(msre_rule *rule, modsec_rec *msr) { multi_match = 1; } - /* Create a memory pool that will be used during the - * processing of this rule only. - */ - /* IMP1 Why not have one pool and just clear it between rules? */ - if (apr_pool_create(&mptmp, NULL) != APR_SUCCESS) { - return -1; + /* Use a fresh memory sub-pool for processing each rule */ + if (msr->msc_rule_mptmp == NULL) { + if (apr_pool_create(&msr->msc_rule_mptmp, msr->mp) != APR_SUCCESS) { + return -1; + } + mptmp = msr->msc_rule_mptmp; + } + else { + mptmp = msr->msc_rule_mptmp; + apr_pool_clear(mptmp); } tartab = apr_table_make(mptmp, 24);