--- mod_security-2.9.1/apache2/modsecurity.h +++ mod_security-2.9.1/apache2/modsecurity.h @@ -657,6 +657,7 @@ apr_pool_t *mp; apr_global_mutex_t *auditlog_lock; apr_global_mutex_t *geo_lock; + apr_thread_mutex_t *dbm_lock; msre_engine *msre; unsigned int processing_mode; }; --- mod_security-2.9.1/apache2/modsecurity.c +++ mod_security-2.9.1/apache2/modsecurity.c @@ -178,22 +178,30 @@ * Performs per-child (new process) initialisation. */ void modsecurity_child_init(msc_engine *msce) { + apr_status_t rc; /* Need to call this once per process before any other XML calls. */ xmlInitParser(); if (msce->auditlog_lock != NULL) { - apr_status_t rc = apr_global_mutex_child_init(&msce->auditlog_lock, NULL, msce->mp); + rc = apr_global_mutex_child_init(&msce->auditlog_lock, NULL, msce->mp); if (rc != APR_SUCCESS) { // ap_log_error(APLOG_MARK, APLOG_ERR, rs, s, "Failed to child-init auditlog mutex"); } } if (msce->geo_lock != NULL) { - apr_status_t rc = apr_global_mutex_child_init(&msce->geo_lock, NULL, msce->mp); + rc = apr_global_mutex_child_init(&msce->geo_lock, NULL, msce->mp); if (rc != APR_SUCCESS) { // ap_log_error(APLOG_MARK, APLOG_ERR, rs, s, "Failed to child-init geo mutex"); } } + + rc = apr_thread_mutex_create(&msce->dbm_lock, + APR_THREAD_MUTEX_DEFAULT, msce->mp); + if (rc != APR_SUCCESS) { + // ap_log_error(APLOG_MARK, APLOG_ERR, rs, s, "Failed to create dbm mutex"); + } + } @@ -213,6 +221,7 @@ apr_time_t time_before, time_after; int i; + apr_thread_mutex_lock(msr->modsecurity->dbm_lock); time_before = apr_time_now(); /* Collections, store & remove stale. */ @@ -251,6 +260,8 @@ " microseconds.", msr->time_gc); } } + apr_thread_mutex_unlock(msr->modsecurity->dbm_lock); + } /** --- mod_security-2.9.1/apache2/re_actions.c +++ mod_security-2.9.1/apache2/re_actions.c @@ -1951,6 +1951,7 @@ /* ENH Warn about this. */ return 0; } + apr_thread_mutex_lock(msr->modsecurity->dbm_lock); /* Init collection from storage. */ table = collection_retrieve(msr, real_col_name, col_key, col_key_len); @@ -1964,8 +1965,11 @@ } table = apr_table_make(msr->mp, 24); - if (table == NULL) return -1; - + if (table == NULL) { + + apr_thread_mutex_unlock(msr->modsecurity->dbm_lock); + return -1; + } /* IMP1 Is the timeout hard-coded to 3600? */ if(msr->txcfg->debuglog_level >= 4) { @@ -2063,6 +2067,7 @@ log_escape(msr->mp, real_col_name)); } } + apr_thread_mutex_unlock(msr->modsecurity->dbm_lock); return 1; }