Move writing to collections and GC earlier so that the results can be logged.

This commit is contained in:
ivanr
2010-02-03 08:59:33 +00:00
parent 0ecfe86c3c
commit e0f1608408

View File

@@ -160,16 +160,12 @@ void modsecurity_shutdown(msc_engine *msce) {
/** /**
* *
*/ */
static apr_status_t modsecurity_tx_cleanup(void *data) { static void modsecurity_persist_data(modsec_rec *msr) {
modsec_rec *msr = (modsec_rec *)data;
const apr_array_header_t *arr; const apr_array_header_t *arr;
apr_table_entry_t *te; apr_table_entry_t *te;
char *my_error_msg = NULL;
apr_time_t time_before, time_after; apr_time_t time_before, time_after;
int i; int i;
if (msr == NULL) return APR_SUCCESS;
time_before = apr_time_now(); time_before = apr_time_now();
/* Collections, store & remove stale. */ /* Collections, store & remove stale. */
@@ -188,6 +184,11 @@ static apr_status_t modsecurity_tx_cleanup(void *data) {
msr->time_storage_write += time_after - time_before; msr->time_storage_write += time_after - time_before;
if (msr->txcfg->debuglog_level >= 3) {
msr_log(msr, 3, "Recording persistent data took %" APR_TIME_T_FMT
" microseconds.", msr->time_gc);
}
/* Remove stale collections. */ /* Remove stale collections. */
if (rand() < RAND_MAX/100) { if (rand() < RAND_MAX/100) {
arr = apr_table_elts(msr->collections); arr = apr_table_elts(msr->collections);
@@ -203,6 +204,16 @@ static apr_status_t modsecurity_tx_cleanup(void *data) {
" microseconds.", msr->time_gc); " microseconds.", msr->time_gc);
} }
} }
}
/**
*
*/
static apr_status_t modsecurity_tx_cleanup(void *data) {
modsec_rec *msr = (modsec_rec *)data;
char *my_error_msg = NULL;
if (msr == NULL) return APR_SUCCESS;
/* Multipart processor cleanup. */ /* Multipart processor cleanup. */
if (msr->mpd != NULL) multipart_cleanup(msr); if (msr->mpd != NULL) multipart_cleanup(msr);
@@ -529,6 +540,8 @@ static apr_status_t modsecurity_process_phase_logging(modsec_rec *msr) {
msre_ruleset_process_phase(msr->txcfg->ruleset, msr); msre_ruleset_process_phase(msr->txcfg->ruleset, msr);
} }
modsecurity_persist_data(msr);
time_after = apr_time_now(); time_after = apr_time_now();
msr->time_phase5 = time_after - time_before; msr->time_phase5 = time_after - time_before;