@@ -166,7 +166,7 @@ static apr_table_t *collection_retrieve_ex(int db_option, void *existing_dbm, mo
166166 }
167167else {
168168if (msr -> txcfg -> data_dir == NULL ) {
169- msr_log (msr ,1 ,"[ERROR] collection_retrieve_ex_origin: Unable to retrieve collection (name \"%s\", key \"%s\"). Use "
169+ msr_log (msr ,1 ,"collection_retrieve_ex_origin: Unable to retrieve collection (name \"%s\", key \"%s\"). Use "
170170"SecDataDir to define data directory first." ,log_escape (msr -> mp ,col_name ),
171171log_escape_ex (msr -> mp ,col_key ,col_key_len ));
172172 gotocleanup ;
@@ -218,22 +218,22 @@ static apr_table_t *collection_retrieve_ex(int db_option, void *existing_dbm, mo
218218//if not called by collection_store(), need to get lock
219219if (existing_dbm == NULL ){
220220rc = AGMDB_getSharedLock (ag_dbm );
221- if (rc != AGMDB_SUCCESS ){
222- msr_log (msr ,1 ,"[ERROR] collection_retrieve_ex_agmdb: Failed to get shared lock" );
221+ if (AGMDB_isError ( rc ) ){
222+ msr_log (msr ,1 ,"collection_retrieve_ex_agmdb: Failed to get shared lock. Error info: %s." , AGMDB_getErrorInfo ( rc ) );
223223 gotocleanup ;
224224 }
225225 }
226226rc = AGMDB_get (ag_dbm ,col_key ,col_key_len ,buffer ,AGMDB_MAX_ENTRY_SIZE ,& tmp_val_len );
227- if (rc != AGMDB_SUCCESS ) {
228- msr_log (msr ,1 ,"[ERROR] collection_retrieve_ex_agmdb: Failed to read from database \"%s\": %s" ,log_escape (msr -> mp ,
229- col_name ),col_key );
227+ if (AGMDB_isError ( rc ) ) {
228+ msr_log (msr ,1 ,"collection_retrieve_ex_agmdb: Failed to read from database \"%s\": %s. Error info: %s. " ,log_escape (msr -> mp ,
229+ col_name ),col_key , AGMDB_getErrorInfo ( rc ) );
230230 gotocleanup ;
231231 }
232232
233233if (existing_dbm == NULL ){
234234rc = AGMDB_freeSharedLock (ag_dbm );
235- if (rc != AGMDB_SUCCESS ) {
236- msr_log (msr ,1 ,"[ERROR] collection_retrieve_ex_agmdb: Failed to free shared lock" );
235+ if (AGMDB_isError ( rc ) ) {
236+ msr_log (msr ,1 ,"collection_retrieve_ex_agmdb: Failed to free shared lock. Error info: %s." , AGMDB_getErrorInfo ( rc ) );
237237 gotocleanup ;
238238 }
239239 }
@@ -316,19 +316,19 @@ static apr_table_t *collection_retrieve_ex(int db_option, void *existing_dbm, mo
316316if (db_option == DB_OPT_AGMDB ){
317317if (existing_dbm == NULL ){
318318rc = AGMDB_getExclusiveLock (ag_dbm );
319- if (rc != AGMDB_SUCCESS ){
320- msr_log (msr ,1 ,"collection_retrieve_ex: Failed to get exclusive lock" );
319+ if (AGMDB_isError ( rc ) ){
320+ msr_log (msr ,1 ,"collection_retrieve_ex: Failed to get exclusive lock. Error info: %s." , AGMDB_getErrorInfo ( rc ) );
321321 gotocleanup ;
322322 }
323323 }
324324rc = AGMDB_delete (ag_dbm ,col_key ,col_key_len );
325- if (rc != AGMDB_SUCCESS )
325+ if (AGMDB_isError ( rc ) )
326326fail_flag = 1 ;
327327
328328if (existing_dbm == NULL ){
329329rc = AGMDB_freeExclusiveLock (ag_dbm );
330- if (rc != AGMDB_SUCCESS ){
331- msr_log (msr ,1 ,"collection_retrieve_ex: Failed to free exclusive lock" );
330+ if (AGMDB_isError ( rc ) ){
331+ msr_log (msr ,1 ,"collection_retrieve_ex: Failed to free exclusive lock. Error info: %s." , AGMDB_getErrorInfo ( rc ) );
332332 gotocleanup ;
333333 }
334334 }
@@ -494,7 +494,7 @@ static int collection_store_ex(int db_option, modsec_rec *msr, apr_table_t *col)
494494msc_string * var_name = NULL ,* var_key = NULL ;
495495unsignedchar * blob = NULL ;
496496unsignedint blob_size = 0 ,blob_offset = 0 ;
497- int rc , rc2 ;
497+ int rc ;
498498apr_sdbm_datum_t key ;
499499apr_sdbm_datum_t value ;
500500const apr_array_header_t * arr ;
@@ -598,7 +598,7 @@ static int collection_store_ex(int db_option, modsec_rec *msr, apr_table_t *col)
598598root_dcfg = msr -> dcfg1 -> root_config ;
599599dbm_filename = apr_pstrcat (root_dcfg -> mp ,root_dcfg -> data_dir ,"/" ,var_name -> value ,NULL );
600600if (root_dcfg == NULL ){
601- msr_log_error (msr ,"[ERROR] collection_retrieve_ex_agmdb: Cannot find root_config in msr->dcfg1." );
601+ msr_log (msr ,1 , " collection_retrieve_ex_agmdb: Cannot find root_config in msr->dcfg1." );
602602 gotoerror ;
603603 }
604604new_handle = (struct agmdb_handle_entry * )apr_pcalloc (root_dcfg -> mp ,sizeof (struct agmdb_handle_entry ));
@@ -607,8 +607,8 @@ static int collection_store_ex(int db_option, modsec_rec *msr, apr_table_t *col)
607607strcpy ((char * )(new_handle -> col_name ),var_name -> value );
608608
609609rc = AGMDB_openDB (new_handle -> handle ,dbm_filename ,strlen (dbm_filename ),MAXIMUM_AGMDB_ENTRY_NUM );
610- if (rc != AGMDB_SUCCESS ){
611- msr_log (msr ,1 ,"[ERROR] collection_retrieve_ex_agmdb: Failed to create DBM name: %s" ,apr_psprintf (msr -> mp ,"%.*s" ,var_name -> value_len ,var_name -> value ));
610+ if (AGMDB_isError ( rc ) ){
611+ msr_log (msr ,1 ,"collection_retrieve_ex_agmdb: Failed to create DBM name: %s. Error info: %s " ,apr_psprintf (msr -> mp ,"%.*s" ,var_name -> value_len ,var_name -> value ), AGMDB_getErrorInfo ( rc ));
612612 gotoerror ;
613613 }
614614ag_dbm = new_handle -> handle ;
@@ -619,7 +619,7 @@ static int collection_store_ex(int db_option, modsec_rec *msr, apr_table_t *col)
619619// ENH: lowercase the var name in the filename
620620dbm_filename = apr_pstrcat (msr -> mp ,msr -> txcfg -> data_dir ,"/" ,var_name -> value ,NULL );
621621if (msr -> txcfg -> debuglog_level >=9 ) {
622- msr_log (msr ,9 ,"[ERRNO] collection_store_ex_origin: Retrieving collection (name \"%s\", filename \"%s\")" ,log_escape (msr -> mp ,var_name -> value ),
622+ msr_log (msr ,9 ,"collection_store_ex_origin: Retrieving collection (name \"%s\", filename \"%s\")" ,log_escape (msr -> mp ,var_name -> value ),
623623log_escape (msr -> mp ,dbm_filename ));
624624 }
625625
@@ -639,7 +639,7 @@ static int collection_store_ex(int db_option, modsec_rec *msr, apr_table_t *col)
639639#ifdef GLOBAL_COLLECTION_LOCK
640640apr_global_mutex_unlock (msr -> modsecurity -> dbm_lock );
641641#endif
642- msr_log (msr ,1 ,"[ERRNO] collection_store_ex_origin: Failed to access DBM file \"%s\": %s" ,log_escape (msr -> mp ,dbm_filename ),
642+ msr_log (msr ,1 ,"collection_store_ex_origin: Failed to access DBM file \"%s\": %s" ,log_escape (msr -> mp ,dbm_filename ),
643643get_apr_error (msr -> mp ,rc ));
644644apr_dbm = NULL ;
645645 gotoerror ;
@@ -653,12 +653,12 @@ static int collection_store_ex(int db_option, modsec_rec *msr, apr_table_t *col)
653653//---------------------------------
654654if (db_option == DB_OPT_AGMDB ){
655655rc = AGMDB_getExclusiveLock (ag_dbm );
656- if (rc != AGMDB_SUCCESS ) {
656+ if (AGMDB_isError ( rc ) ) {
657657#ifdef _WIN32
658658int lasterr = (int )GetLastError ();
659- msr_log (msr ,1 ,"collection_store: Failed to getExclusiveLock, lasterr = %d" ,lasterr );
659+ msr_log (msr ,1 ,"collection_store: Failed to getExclusiveLock, lasterr = %d. Error info: %s " ,lasterr , AGMDB_getErrorInfo ( rc ) );
660660#else
661- msr_log (msr ,1 ,"collection_store: Failed to getExclusiveLock, errno = %d" ,errno );
661+ msr_log (msr ,1 ,"collection_store: Failed to getExclusiveLock, errno = %d. Error info: %s " ,errno , AGMDB_getErrorInfo ( rc ) );
662662#endif
663663 gotoerror ;
664664 }
@@ -668,7 +668,7 @@ static int collection_store_ex(int db_option, modsec_rec *msr, apr_table_t *col)
668668/* Need to lock to pull in the stored data again and apply deltas. */
669669rc = apr_sdbm_lock (apr_dbm ,APR_FLOCK_EXCLUSIVE );
670670if (rc != APR_SUCCESS ) {
671- msr_log (msr ,1 ,"[ERRNO] collection_store_ex_origin: Failed to exclusivly lock DBM file \"%s\": %s" ,log_escape (msr -> mp ,dbm_filename ),
671+ msr_log (msr ,1 ,"collection_store_ex_origin: Failed to exclusivly lock DBM file \"%s\": %s" ,log_escape (msr -> mp ,dbm_filename ),
672672get_apr_error (msr -> mp ,rc ));
673673 gotoerror ;
674674 }
@@ -745,8 +745,10 @@ static int collection_store_ex(int db_option, modsec_rec *msr, apr_table_t *col)
745745if (blob == NULL ) {
746746if (ag_dbm != NULL ) {
747747rc = AGMDB_freeExclusiveLock (ag_dbm );
748+ if (AGMDB_isError (rc ))
749+ msr_log (msr ,1 ,"collection_stror_ex: Fail to free exclusive lock. Error info: %s" ,AGMDB_getErrorInfo (rc ));
748750 }
749- msr_log_error (msr ,"[ERROR] collection_store_ex_agdb: fail to create blob" );
751+ msr_log (msr ,1 , " collection_store_ex_agdb: fail to create blob" );
750752return -1 ;
751753 }
752754 }
@@ -815,15 +817,14 @@ static int collection_store_ex(int db_option, modsec_rec *msr, apr_table_t *col)
815817value .dsize = blob_size ;
816818
817819if (db_option == DB_OPT_AGMDB ) {
818- rc2 = AGMDB_set (ag_dbm ,var_key -> value ,var_key -> value_len , (char * )blob ,blob_size );
819- rc = AGMDB_freeExclusiveLock (ag_dbm );
820-
821- if (rc2 != AGMDB_SUCCESS ) {
822- msr_log (msr ,1 ,"[ERROR]collection_store_ex_agmdb: Failed to write to database key: %s" ,var_key -> value );
823- return -1 ;
820+ rc = AGMDB_set (ag_dbm ,var_key -> value ,var_key -> value_len , (char * )blob ,blob_size );
821+ if (AGMDB_isError (rc )) {
822+ msr_log (msr ,1 ,"collection_store_ex_agmdb: Failed to write to database key: %s. Error info: %s." ,var_key -> value ,AGMDB_getErrorInfo (rc ));
824823 }
825- if (rc != AGMDB_SUCCESS ){
826- msr_log (msr ,1 ,"[ERROR]collection_store_ex_agmdb: Failed to free exclusive lock" );
824+
825+ rc = AGMDB_freeExclusiveLock (ag_dbm );
826+ if (AGMDB_isError (rc )){
827+ msr_log (msr ,1 ,"collection_store_ex_agmdb: Failed to free exclusive lock. Error info: %s." ,AGMDB_getErrorInfo (rc ));
827828return -1 ;
828829 }
829830 }
@@ -895,7 +896,7 @@ static int collections_remove_stale_ex(int db_option, modsec_rec *msr, const cha
895896apr_array_header_t * keys_arr ;
896897char * * keys ;
897898apr_time_t now = apr_time_sec (msr -> request_time );
898- int i ;
899+ int i , rc2 ;
899900
900901//---------------------------------
901902//AGMDB
@@ -906,7 +907,9 @@ static int collections_remove_stale_ex(int db_option, modsec_rec *msr, const cha
906907ag_dbm = dcfg_searchAGMDBhandler (col_name , (struct agmdb_handle_entry * )(root_dcfg -> agmdb_handles ));
907908if (ag_dbm == NULL )
908909return 1 ;
909- return AGMDB_removeStale (ag_dbm );
910+ rc2 = AGMDB_removeStale (ag_dbm );
911+ if (AGMDB_isError (rc2 ))
912+ msr_log (msr ,1 ,"collections_remove_stale_ex_agmdb: error in remove stale. Error info: %s" ,AGMDB_getErrorInfo (rc2 ));
910913 }
911914//---------------------------------
912915//apr_sdbm