@@ -125,19 +125,15 @@ static apr_table_t *collection_retrieve_ex(apr_sdbm_t *existing_dbm, modsec_rec
125125
126126 if (existing_dbm == NULL ) {
127127#ifdef GLOBAL_COLLECTION_LOCK
128- rc = apr_global_mutex_lock (msr -> modsecurity -> dbm_lock );
129- if (rc != APR_SUCCESS ) {
130- msr_log (msr , 1 , "collection_retrieve_ex: Failed to lock proc mutex: %s" ,
131- get_apr_error (msr -> mp , rc ));
132- goto cleanup ;
133- }
128+ rc = msr_global_mutex_lock (msr , msr -> modsecurity -> dbm_lock , "collection_retrieve_ex" );
129+ if (rc != APR_SUCCESS ) goto cleanup ;
134130#endif
135131 rc = apr_sdbm_open (& dbm , dbm_filename , APR_READ | APR_SHARELOCK ,
136132 CREATEMODE , msr -> mp );
137133 if (rc != APR_SUCCESS ) {
138134 dbm = NULL ;
139135#ifdef GLOBAL_COLLECTION_LOCK
140- apr_global_mutex_unlock (msr -> modsecurity -> dbm_lock );
136+ msr_global_mutex_unlock (msr , msr -> modsecurity -> dbm_lock , "collection_retrieve_ex" );
141137#endif
142138 goto cleanup ;
143139 }
@@ -173,7 +169,7 @@ static apr_table_t *collection_retrieve_ex(apr_sdbm_t *existing_dbm, modsec_rec
173169 if (existing_dbm == NULL ) {
174170 apr_sdbm_close (dbm );
175171#ifdef GLOBAL_COLLECTION_LOCK
176- apr_global_mutex_unlock (msr -> modsecurity -> dbm_lock );
172+ msr_global_mutex_unlock (msr , msr -> modsecurity -> dbm_lock , "collection_retrieve_ex" );
177173#endif
178174 dbm = NULL ;
179175 }
@@ -222,12 +218,8 @@ static apr_table_t *collection_retrieve_ex(apr_sdbm_t *existing_dbm, modsec_rec
222218 if (apr_table_get (col , "KEY" ) == NULL ) {
223219 if (existing_dbm == NULL ) {
224220#ifdef GLOBAL_COLLECTION_LOCK
225- rc = apr_global_mutex_lock (msr -> modsecurity -> dbm_lock );
226- if (rc != APR_SUCCESS ) {
227- msr_log (msr , 1 , "collection_retrieve_ex: Failed to lock proc mutex: %s" ,
228- get_apr_error (msr -> mp , rc ));
229- goto cleanup ;
230- }
221+ rc = msr_global_mutex_lock (msr , msr -> modsecurity -> dbm_lock , "collection_retrieve_ex" );
222+ if (rc != APR_SUCCESS ) goto cleanup ;
231223#endif
232224 rc = apr_sdbm_open (& dbm , dbm_filename , APR_CREATE | APR_WRITE | APR_SHARELOCK ,
233225 CREATEMODE , msr -> mp );
@@ -236,7 +228,7 @@ static apr_table_t *collection_retrieve_ex(apr_sdbm_t *existing_dbm, modsec_rec
236228 log_escape (msr -> mp , dbm_filename ), get_apr_error (msr -> mp , rc ));
237229 dbm = NULL ;
238230#ifdef GLOBAL_COLLECTION_LOCK
239- apr_global_mutex_unlock (msr -> modsecurity -> dbm_lock );
231+ msr_global_mutex_unlock (msr , msr -> modsecurity -> dbm_lock , "collection_retrieve_ex" );
240232#endif
241233 goto cleanup ;
242234 }
@@ -261,7 +253,7 @@ static apr_table_t *collection_retrieve_ex(apr_sdbm_t *existing_dbm, modsec_rec
261253 if (existing_dbm == NULL ) {
262254 apr_sdbm_close (dbm );
263255#ifdef GLOBAL_COLLECTION_LOCK
264- apr_global_mutex_unlock (msr -> modsecurity -> dbm_lock );
256+ msr_global_mutex_unlock (msr , msr -> modsecurity -> dbm_lock , "collection_retrieve_ex" );
265257#endif
266258 dbm = NULL ;
267259 }
@@ -326,7 +318,7 @@ static apr_table_t *collection_retrieve_ex(apr_sdbm_t *existing_dbm, modsec_rec
326318
327319 apr_sdbm_close (dbm );
328320#ifdef GLOBAL_COLLECTION_LOCK
329- apr_global_mutex_unlock (msr -> modsecurity -> dbm_lock );
321+ msr_global_mutex_unlock (msr , msr -> modsecurity -> dbm_lock , "collection_retrieve_ex" );
330322#endif
331323 }
332324
@@ -337,7 +329,7 @@ static apr_table_t *collection_retrieve_ex(apr_sdbm_t *existing_dbm, modsec_rec
337329 if ((existing_dbm == NULL ) && dbm ) {
338330 apr_sdbm_close (dbm );
339331#ifdef GLOBAL_COLLECTION_LOCK
340- apr_global_mutex_unlock (msr -> modsecurity -> dbm_lock );
332+ msr_global_mutex_unlock (msr , msr -> modsecurity -> dbm_lock , "collection_retrieve_ex" );
341333#endif
342334 }
343335
@@ -408,12 +400,8 @@ int collection_store(modsec_rec *msr, apr_table_t *col) {
408400
409401#ifdef GLOBAL_COLLECTION_LOCK
410402 /* Need to lock to pull in the stored data again and apply deltas. */
411- rc = apr_global_mutex_lock (msr -> modsecurity -> dbm_lock );
412- if (rc != APR_SUCCESS ) {
413- msr_log (msr , 1 , "collection_store: Failed to lock proc mutex: %s" ,
414- get_apr_error (msr -> mp , rc ));
415- goto error ;
416- }
403+ int ret = msr_global_mutex_lock (msr , msr -> modsecurity -> dbm_lock , "collection_store" );
404+ if (ret != APR_SUCCESS ) goto error ;
417405#endif
418406
419407 /* Delete IS_NEW on store. */
@@ -473,7 +461,7 @@ int collection_store(modsec_rec *msr, apr_table_t *col) {
473461 CREATEMODE , msr -> mp );
474462 if (rc != APR_SUCCESS ) {
475463#ifdef GLOBAL_COLLECTION_LOCK
476- apr_global_mutex_unlock (msr -> modsecurity -> dbm_lock );
464+ msr_global_mutex_unlock (msr , msr -> modsecurity -> dbm_lock , "collection_store" );
477465#endif
478466 msr_log (msr , 1 , "collection_store: Failed to access DBM file \"%s\": %s" , log_escape (msr -> mp , dbm_filename ),
479467 get_apr_error (msr -> mp , rc ));
@@ -556,7 +544,7 @@ int collection_store(modsec_rec *msr, apr_table_t *col) {
556544 if (dbm != NULL ) {
557545#ifdef GLOBAL_COLLECTION_LOCK
558546 apr_sdbm_close (dbm );
559- apr_global_mutex_unlock (msr -> modsecurity -> dbm_lock );
547+ msr_global_mutex_unlock (msr , msr -> modsecurity -> dbm_lock , "collection_store" );
560548#else
561549 apr_sdbm_unlock (dbm );
562550 apr_sdbm_close (dbm );
@@ -619,7 +607,7 @@ int collection_store(modsec_rec *msr, apr_table_t *col) {
619607 if (dbm != NULL ) {
620608#ifdef GLOBAL_COLLECTION_LOCK
621609 apr_sdbm_close (dbm );
622- apr_global_mutex_unlock (msr -> modsecurity -> dbm_lock );
610+ msr_global_mutex_unlock (msr , msr -> modsecurity -> dbm_lock , "collection_store" );
623611#else
624612 apr_sdbm_unlock (dbm );
625613 apr_sdbm_close (dbm );
@@ -631,7 +619,7 @@ int collection_store(modsec_rec *msr, apr_table_t *col) {
631619
632620#ifdef GLOBAL_COLLECTION_LOCK
633621 apr_sdbm_close (dbm );
634- apr_global_mutex_unlock (msr -> modsecurity -> dbm_lock );
622+ msr_global_mutex_unlock (msr , msr -> modsecurity -> dbm_lock , "collection_store" );
635623#else
636624 apr_sdbm_unlock (dbm );
637625 apr_sdbm_close (dbm );
@@ -684,19 +672,15 @@ int collections_remove_stale(modsec_rec *msr, const char *col_name) {
684672 }
685673
686674#ifdef GLOBAL_COLLECTION_LOCK
687- rc = apr_global_mutex_lock (msr -> modsecurity -> dbm_lock );
688- if (rc != APR_SUCCESS ) {
689- msr_log (msr , 1 , "collections_remove_stale: Failed to lock proc mutex: %s" ,
690- get_apr_error (msr -> mp , rc ));
691- goto error ;
692- }
675+ rc = msr_global_mutex_lock (msr , msr -> modsecurity -> dbm_lock , "collections_remove_stale" );
676+ if (rc != APR_SUCCESS ) goto error ;
693677#endif
694678
695679 rc = apr_sdbm_open (& dbm , dbm_filename , APR_CREATE | APR_WRITE | APR_SHARELOCK ,
696680 CREATEMODE , msr -> mp );
697681 if (rc != APR_SUCCESS ) {
698682#ifdef GLOBAL_COLLECTION_LOCK
699- apr_global_mutex_unlock (msr -> modsecurity -> dbm_lock );
683+ msr_global_mutex_unlock (msr , msr -> modsecurity -> dbm_lock , "collections_remove_stale" );
700684#endif
701685 msr_log (msr , 1 , "collections_remove_stale: Failed to access DBM file \"%s\": %s" , log_escape (msr -> mp , dbm_filename ),
702686 get_apr_error (msr -> mp , rc ));
@@ -799,7 +783,7 @@ int collections_remove_stale(modsec_rec *msr, const char *col_name) {
799783
800784 apr_sdbm_close (dbm );
801785#ifdef GLOBAL_COLLECTION_LOCK
802- apr_global_mutex_unlock (msr -> modsecurity -> dbm_lock );
786+ msr_global_mutex_unlock (msr , msr -> modsecurity -> dbm_lock , "collections_remove_stale" );
803787#endif
804788 return 1 ;
805789
@@ -808,7 +792,7 @@ int collections_remove_stale(modsec_rec *msr, const char *col_name) {
808792 if (dbm ) {
809793 apr_sdbm_close (dbm );
810794#ifdef GLOBAL_COLLECTION_LOCK
811- apr_global_mutex_unlock (msr -> modsecurity -> dbm_lock );
795+ msr_global_mutex_unlock (msr , msr -> modsecurity -> dbm_lock , "collections_remove_stale" );
812796#endif
813797 }
814798
0 commit comments