svn commit: r1932400 - spamassassin/trunk/lib/Mail/SpamAssassin/Plugin

[email protected]
Newsgroups gmane.mail.spam.spamassassin.cvs
Message-ID <[email protected]>
Author: gbechis
Date: Fri Mar 20 07:43:57 2026
New Revision: 1932400

Log:
close open handles on exit

Modified:
   spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/NeuralNetwork.pm

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/NeuralNetwork.pm
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/NeuralNetwork.pm	Fri Mar 20 06:45:02 2026	(r1932399)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/NeuralNetwork.pm	Fri Mar 20 07:43:57 2026	(r1932400)
@@ -44,7 +44,7 @@ use strict;
 use warnings;
 use re 'taint';
 
-my $VERSION = 0.6.2;
+my $VERSION = 0.6.3;
 
 use AI::FANN qw(:all);
 use Storable qw(store retrieve);
@@ -110,6 +110,20 @@ sub _flock {
   return $fh;
 }
 
+sub DESTROY {
+  my ($self) = @_;
+  if(defined $self->{_lock_fh}) {
+    for my $path (keys %{$self->{_lock_fh}}) {
+      close(delete $self->{_lock_fh}{$path});
+    }
+  }
+  delete $self->{_lock_fh_time} if defined $self->{_lock_fh_time};
+  if ($self->{dbh}) {
+    $self->{dbh}->disconnect();
+    undef $self->{dbh};
+  }
+}
+
 sub new {
   my ($class, $mailsa) = @_;
 
@@ -1445,8 +1459,8 @@ sub _save_vocabulary_to_sql {
     }
     1;
   } or do {
-    eval { $self->{dbh}->rollback() };
     my $err = $@ || 'unknown';
+    eval { $self->{dbh}->rollback() if !$self->{dbh}{AutoCommit} };
     dbg("Failed to save vocabulary to SQL: $err");
   };
 }
@@ -1560,8 +1574,9 @@ sub _save_model_vocab_to_sql {
     dbg("Saved model vocabulary (" . scalar(@$vocab_keys_ref) . " terms) to SQL for user: $username");
     1;
   } or do {
-    eval { $self->{dbh}->rollback() };
-    dbg("Failed to save model vocabulary to SQL: " . ($@ || 'unknown'));
+    my $err = $@ || 'unknown';
+    eval { $self->{dbh}->rollback() if !$self->{dbh}{AutoCommit} };
+    dbg("Failed to save model vocabulary to SQL: $err");
   };
 }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.