File tree Expand file tree Collapse file tree 3 files changed +18
-3
lines changed Expand file tree Collapse file tree 3 files changed +18
-3
lines changed Original file line number Diff line number Diff line change @@ -615,7 +615,7 @@ size_t diagnose_files(
615
615
616
616
if (symlink_target != NULL )
617
617
{
618
- int usage ;
618
+ int usage = 0 ;
619
619
bool needs_rotation = lmdb_file_needs_rotation (symlink_target , & usage );
620
620
Log (LOG_LEVEL_INFO ,
621
621
"Status of '%s' -> '%s': %s [%d%% usage%s]\n" ,
@@ -627,7 +627,7 @@ size_t diagnose_files(
627
627
}
628
628
else
629
629
{
630
- int usage ;
630
+ int usage = 0 ;
631
631
bool needs_rotation = lmdb_file_needs_rotation (filename , & usage );
632
632
Log (LOG_LEVEL_INFO ,
633
633
"Status of '%s': %s [%d%% usage%s]\n" ,
Original file line number Diff line number Diff line change @@ -592,27 +592,34 @@ int CFCheck_Validate(const char *path)
592
592
rc = mdb_env_open (env , path , MDB_NOSUBDIR | MDB_RDONLY , 0644 );
593
593
if (rc != 0 )
594
594
{
595
+ mdb_env_close (env );
595
596
return rc ;
596
597
}
597
598
598
599
MDB_txn * txn ;
599
600
rc = mdb_txn_begin (env , NULL , MDB_RDONLY , & txn );
600
601
if (rc != 0 )
601
602
{
603
+ mdb_env_close (env );
602
604
return rc ;
603
605
}
604
606
605
607
MDB_dbi dbi ;
606
608
rc = mdb_open (txn , NULL , 0 , & dbi );
607
609
if (rc != 0 )
608
610
{
611
+ mdb_txn_abort (txn );
612
+ mdb_env_close (env );
609
613
return rc ;
610
614
}
611
615
612
616
MDB_cursor * cursor ;
613
617
rc = mdb_cursor_open (txn , dbi , & cursor );
614
618
if (rc != 0 )
615
619
{
620
+ mdb_close (env , dbi );
621
+ mdb_txn_abort (txn );
622
+ mdb_env_close (env );
616
623
return rc ;
617
624
}
618
625
@@ -627,6 +634,10 @@ int CFCheck_Validate(const char *path)
627
634
{
628
635
// At this point, not found is expected, anything else is an error
629
636
DestroyValidator (& state );
637
+ mdb_cursor_close (cursor );
638
+ mdb_close (env , dbi );
639
+ mdb_txn_abort (txn );
640
+ mdb_env_close (env );
630
641
return rc ;
631
642
}
632
643
mdb_cursor_close (cursor );
Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ function check_valgrind_output {
37
37
fi
38
38
echo " Looking for problems in $1 :"
39
39
grep -i " ERROR SUMMARY: 0 errors" " $1 "
40
- cat $1 | sed -e " / 0 errors/d" -e " /and suppressed error/d" -e " /a memory error detector/d" -e " /This database contains unknown binary data/d" > filtered.txt
40
+ cat $1 | sed -e " / 0 errors/d" -e " /and suppressed error/d" -e " /a memory error detector/d" -e " /This database contains unknown binary data/d" -e " /error: Problems detected in 1\/1 databases/d " -e " /error: Failed to stat() 'no-such-file.lmdb'/d " -e " /Status of 'no-such-file.lmdb': SYSTEM_ERROR 2/d " > filtered.txt
41
41
no_errors filtered.txt
42
42
set +e
43
43
grep -i " at 0x" filtered.txt
@@ -98,6 +98,10 @@ echo "Running cf-check diagnose --validate on all databases:"
98
98
valgrind $VG_OPTS /var/cfengine/bin/cf-check diagnose --validate 2>&1 | tee cf_check_validate_all_1.txt
99
99
check_valgrind_output cf_check_validate_all_1.txt
100
100
101
+ echo " Running cf-check diagnose --validate on non-existent file:"
102
+ valgrind $VG_OPTS /var/cfengine/bin/cf-check diagnose --validate no-such-file.lmdb 2>&1 | tee cf_check_validate_non_existent.txt
103
+ check_valgrind_output cf_check_validate_non_existent.txt
104
+
101
105
check_masterfiles_and_inputs
102
106
103
107
print_ps
You can’t perform that action at this time.
0 commit comments