Update of /cvsroot/popfile/engine/Classifier
In directory sc8-pr-cvs1:/tmp/cvs-serv28656/Classifier
Modified Files:
Bayes.pm
Log Message:
Make POPFile die quickly if the database tie fails
Index: Bayes.pm
===================================================================
RCS file: /cvsroot/popfile/engine/Classifier/Bayes.pm,v
retrieving revision 1.219
retrieving revision 1.220
diff -C2 -d -r1.219 -r1.220
*** Bayes.pm 30 Oct 2003 14:57:12 -0000 1.219
--- Bayes.pm 5 Nov 2003 15:11:49 -0000 1.220
***************
*** 586,598 ****
-Flags => DB_CREATE; # PROFILE BLOCK STOP
if ( !defined( $self->{matrix__}{$bucket}{__POPFILE__TOTAL__} ) ) {
$self->{matrix__}{$bucket}{__POPFILE__TOTAL__} = 0;
$self->{matrix__}{$bucket}{__POPFILE__UNIQUE__} = 0;
}
}
# ---------------------------------------------------------------------------------------------
#
! # tie_bucket__
#
# Unties the matrix__ hash from the BerkeleyDB
--- 586,610 ----
-Flags => DB_CREATE; # PROFILE BLOCK STOP
+ # Check to see if the tie worked, if it failed then POPFile is about to fail
+ # badly
+
+ if ( !defined( $self->{db__}{$bucket} ) ) {
+ $self->log_( "Failed to tie database hash for bucket $bucket" );
+ die "Database tie failed for $bucket";
+ }
+
if ( !defined( $self->{matrix__}{$bucket}{__POPFILE__TOTAL__} ) ) {
$self->{matrix__}{$bucket}{__POPFILE__TOTAL__} = 0;
$self->{matrix__}{$bucket}{__POPFILE__UNIQUE__} = 0;
}
+
+ if ( !defined( $self->{matrix__}{$bucket}{__POPFILE__UNIQUE__} ) ) {
+ $self->{matrix__}{$bucket}{__POPFILE__UNIQUE__} = 0;
+ }
}
# ---------------------------------------------------------------------------------------------
#
! # untie_bucket__
#
# Unties the matrix__ hash from the BerkeleyDB
|