mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-08-14 13:56:01 +03:00
Same for global_mutex_unlock
This commit is contained in:
parent
b52201010d
commit
449c080e63
@ -183,6 +183,22 @@ int msr_global_mutex_lock(modsec_rec* msr, apr_global_mutex_t* lock, const char*
|
||||
if (rc != APR_SUCCESS) msr_log(msr, 1, "Audit log: Failed to lock global mutex: %s", get_apr_error(msr->mp, rc));
|
||||
return rc;
|
||||
}
|
||||
/**
|
||||
* handle errors from apr_global_mutex_unlock
|
||||
*/
|
||||
int msr_global_mutex_unlock(modsec_rec* msr, apr_global_mutex_t* lock, const char* fct) {
|
||||
assert(msr);
|
||||
assert(msr->modsecurity); // lock is msr->modsecurity->..._lock
|
||||
assert(msr->mp);
|
||||
if (!lock) {
|
||||
msr_log(msr, 1, "%s: Global mutex was not created", fct);
|
||||
return -1;
|
||||
}
|
||||
|
||||
int rc = apr_global_mutex_unlock(msr->modsecurity->auditlog_lock);
|
||||
if (rc != APR_SUCCESS) msr_log(msr, 1, "Audit log: Failed to lock global mutex: %s", get_apr_error(msr->mp, rc));
|
||||
return rc;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialise the modsecurity engine. This function must be invoked
|
||||
|
@ -708,6 +708,7 @@ struct msc_parm {
|
||||
/* Reusable functions */
|
||||
int acquire_global_lock(apr_global_mutex_t **lock, apr_pool_t *mp);
|
||||
int msr_global_mutex_lock(modsec_rec* msr, apr_global_mutex_t* lock, const char* fct);
|
||||
int msr_global_mutex_unlock(modsec_rec* msr, apr_global_mutex_t* lock, const char* fct);
|
||||
|
||||
/* Engine functions */
|
||||
|
||||
|
@ -357,13 +357,7 @@ int geo_lookup(modsec_rec *msr, geo_rec *georec, const char *target, char **erro
|
||||
if (rec_val == geo->ctry_offset) {
|
||||
*error_msg = apr_psprintf(msr->mp, "No geo data for \"%s\").", log_escape(msr->mp, target));
|
||||
msr_log(msr, 4, "%s", *error_msg);
|
||||
|
||||
ret = apr_global_mutex_unlock(msr->modsecurity->geo_lock);
|
||||
if (ret != APR_SUCCESS) {
|
||||
msr_log(msr, 1, "Geo Lookup: Failed to lock proc mutex: %s",
|
||||
get_apr_error(msr->mp, ret));
|
||||
}
|
||||
|
||||
msr_global_mutex_unlock(msr, msr->modsecurity->geo_lock, "Geo Lookup");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -373,13 +367,7 @@ int geo_lookup(modsec_rec *msr, geo_rec *georec, const char *target, char **erro
|
||||
if ((country <= 0) || (country > GEO_COUNTRY_LAST)) {
|
||||
*error_msg = apr_psprintf(msr->mp, "No geo data for \"%s\" (country %d).", log_escape(msr->mp, target), country);
|
||||
msr_log(msr, 4, "%s", *error_msg);
|
||||
|
||||
ret = apr_global_mutex_unlock(msr->modsecurity->geo_lock);
|
||||
if (ret != APR_SUCCESS) {
|
||||
msr_log(msr, 1, "Geo Lookup: Failed to lock proc mutex: %s",
|
||||
get_apr_error(msr->mp, ret));
|
||||
}
|
||||
|
||||
msr_global_mutex_unlock(msr, msr->modsecurity->geo_lock, "Geo Lookup");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -404,13 +392,7 @@ int geo_lookup(modsec_rec *msr, geo_rec *georec, const char *target, char **erro
|
||||
if ((country <= 0) || (country > GEO_COUNTRY_LAST)) {
|
||||
*error_msg = apr_psprintf(msr->mp, "No geo data for \"%s\" (country %d).", log_escape(msr->mp, target), country);
|
||||
msr_log(msr, 4, "%s", *error_msg);
|
||||
|
||||
ret = apr_global_mutex_unlock(msr->modsecurity->geo_lock);
|
||||
if (ret != APR_SUCCESS) {
|
||||
msr_log(msr, 1, "Geo Lookup: Failed to lock proc mutex: %s",
|
||||
get_apr_error(msr->mp, ret));
|
||||
}
|
||||
|
||||
msr_global_mutex_unlock(msr, msr->modsecurity->geo_lock, "Geo Lookup");
|
||||
return 0;
|
||||
}
|
||||
if (msr->txcfg->debuglog_level >= 9) {
|
||||
@ -499,13 +481,7 @@ int geo_lookup(modsec_rec *msr, geo_rec *georec, const char *target, char **erro
|
||||
}
|
||||
|
||||
*error_msg = apr_psprintf(msr->mp, "Geo lookup for \"%s\" succeeded.", log_escape(msr->mp, target));
|
||||
|
||||
ret = apr_global_mutex_unlock(msr->modsecurity->geo_lock);
|
||||
if (ret != APR_SUCCESS) {
|
||||
msr_log(msr, 1, "Geo Lookup: Failed to lock proc mutex: %s",
|
||||
get_apr_error(msr->mp, ret));
|
||||
}
|
||||
|
||||
msr_global_mutex_unlock(msr, msr->modsecurity->geo_lock, "Geo Lookup");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -133,7 +133,7 @@ static apr_table_t *collection_retrieve_ex(apr_sdbm_t *existing_dbm, modsec_rec
|
||||
if (rc != APR_SUCCESS) {
|
||||
dbm = NULL;
|
||||
#ifdef GLOBAL_COLLECTION_LOCK
|
||||
apr_global_mutex_unlock(msr->modsecurity->dbm_lock);
|
||||
msr_global_mutex_unlock(msr, msr->modsecurity->dbm_lock, "collection_retrieve_ex");
|
||||
#endif
|
||||
goto cleanup;
|
||||
}
|
||||
@ -169,7 +169,7 @@ static apr_table_t *collection_retrieve_ex(apr_sdbm_t *existing_dbm, modsec_rec
|
||||
if (existing_dbm == NULL) {
|
||||
apr_sdbm_close(dbm);
|
||||
#ifdef GLOBAL_COLLECTION_LOCK
|
||||
apr_global_mutex_unlock(msr->modsecurity->dbm_lock);
|
||||
msr_global_mutex_unlock(msr, msr->modsecurity->dbm_lock, "collection_retrieve_ex");
|
||||
#endif
|
||||
dbm = NULL;
|
||||
}
|
||||
@ -228,7 +228,7 @@ static apr_table_t *collection_retrieve_ex(apr_sdbm_t *existing_dbm, modsec_rec
|
||||
log_escape(msr->mp, dbm_filename), get_apr_error(msr->mp, rc));
|
||||
dbm = NULL;
|
||||
#ifdef GLOBAL_COLLECTION_LOCK
|
||||
apr_global_mutex_unlock(msr->modsecurity->dbm_lock);
|
||||
msr_global_mutex_unlock(msr, msr->modsecurity->dbm_lock, "collection_retrieve_ex");
|
||||
#endif
|
||||
goto cleanup;
|
||||
}
|
||||
@ -253,7 +253,7 @@ static apr_table_t *collection_retrieve_ex(apr_sdbm_t *existing_dbm, modsec_rec
|
||||
if (existing_dbm == NULL) {
|
||||
apr_sdbm_close(dbm);
|
||||
#ifdef GLOBAL_COLLECTION_LOCK
|
||||
apr_global_mutex_unlock(msr->modsecurity->dbm_lock);
|
||||
msr_global_mutex_unlock(msr, msr->modsecurity->dbm_lock, "collection_retrieve_ex");
|
||||
#endif
|
||||
dbm = NULL;
|
||||
}
|
||||
@ -318,7 +318,7 @@ static apr_table_t *collection_retrieve_ex(apr_sdbm_t *existing_dbm, modsec_rec
|
||||
|
||||
apr_sdbm_close(dbm);
|
||||
#ifdef GLOBAL_COLLECTION_LOCK
|
||||
apr_global_mutex_unlock(msr->modsecurity->dbm_lock);
|
||||
msr_global_mutex_unlock(msr, msr->modsecurity->dbm_lock, "collection_retrieve_ex");
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -329,7 +329,7 @@ cleanup:
|
||||
if ((existing_dbm == NULL) && dbm) {
|
||||
apr_sdbm_close(dbm);
|
||||
#ifdef GLOBAL_COLLECTION_LOCK
|
||||
apr_global_mutex_unlock(msr->modsecurity->dbm_lock);
|
||||
msr_global_mutex_unlock(msr, msr->modsecurity->dbm_lock, "collection_retrieve_ex");
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -461,7 +461,7 @@ int collection_store(modsec_rec *msr, apr_table_t *col) {
|
||||
CREATEMODE, msr->mp);
|
||||
if (rc != APR_SUCCESS) {
|
||||
#ifdef GLOBAL_COLLECTION_LOCK
|
||||
apr_global_mutex_unlock(msr->modsecurity->dbm_lock);
|
||||
msr_global_mutex_unlock(msr, msr->modsecurity->dbm_lock, "collection_store");
|
||||
#endif
|
||||
msr_log(msr, 1, "collection_store: Failed to access DBM file \"%s\": %s", log_escape(msr->mp, dbm_filename),
|
||||
get_apr_error(msr->mp, rc));
|
||||
@ -544,7 +544,7 @@ int collection_store(modsec_rec *msr, apr_table_t *col) {
|
||||
if (dbm != NULL) {
|
||||
#ifdef GLOBAL_COLLECTION_LOCK
|
||||
apr_sdbm_close(dbm);
|
||||
apr_global_mutex_unlock(msr->modsecurity->dbm_lock);
|
||||
msr_global_mutex_unlock(msr, msr->modsecurity->dbm_lock, "collection_store");
|
||||
#else
|
||||
apr_sdbm_unlock(dbm);
|
||||
apr_sdbm_close(dbm);
|
||||
@ -607,7 +607,7 @@ int collection_store(modsec_rec *msr, apr_table_t *col) {
|
||||
if (dbm != NULL) {
|
||||
#ifdef GLOBAL_COLLECTION_LOCK
|
||||
apr_sdbm_close(dbm);
|
||||
apr_global_mutex_unlock(msr->modsecurity->dbm_lock);
|
||||
msr_global_mutex_unlock(msr, msr->modsecurity->dbm_lock, "collection_store");
|
||||
#else
|
||||
apr_sdbm_unlock(dbm);
|
||||
apr_sdbm_close(dbm);
|
||||
@ -619,7 +619,7 @@ int collection_store(modsec_rec *msr, apr_table_t *col) {
|
||||
|
||||
#ifdef GLOBAL_COLLECTION_LOCK
|
||||
apr_sdbm_close(dbm);
|
||||
apr_global_mutex_unlock(msr->modsecurity->dbm_lock);
|
||||
msr_global_mutex_unlock(msr, msr->modsecurity->dbm_lock, "collection_store");
|
||||
#else
|
||||
apr_sdbm_unlock(dbm);
|
||||
apr_sdbm_close(dbm);
|
||||
@ -680,7 +680,7 @@ int collections_remove_stale(modsec_rec *msr, const char *col_name) {
|
||||
CREATEMODE, msr->mp);
|
||||
if (rc != APR_SUCCESS) {
|
||||
#ifdef GLOBAL_COLLECTION_LOCK
|
||||
apr_global_mutex_unlock(msr->modsecurity->dbm_lock);
|
||||
msr_global_mutex_unlock(msr, msr->modsecurity->dbm_lock, "collections_remove_stale");
|
||||
#endif
|
||||
msr_log(msr, 1, "collections_remove_stale: Failed to access DBM file \"%s\": %s", log_escape(msr->mp, dbm_filename),
|
||||
get_apr_error(msr->mp, rc));
|
||||
@ -783,7 +783,7 @@ int collections_remove_stale(modsec_rec *msr, const char *col_name) {
|
||||
|
||||
apr_sdbm_close(dbm);
|
||||
#ifdef GLOBAL_COLLECTION_LOCK
|
||||
apr_global_mutex_unlock(msr->modsecurity->dbm_lock);
|
||||
msr_global_mutex_unlock(msr, msr->modsecurity->dbm_lock, "collections_remove_stale");
|
||||
#endif
|
||||
return 1;
|
||||
|
||||
@ -792,7 +792,7 @@ error:
|
||||
if (dbm) {
|
||||
apr_sdbm_close(dbm);
|
||||
#ifdef GLOBAL_COLLECTION_LOCK
|
||||
apr_global_mutex_unlock(msr->modsecurity->dbm_lock);
|
||||
msr_global_mutex_unlock(msr, msr->modsecurity->dbm_lock, "collections_remove_stale");
|
||||
#endif
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user