]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 1082557: Use a persistent connection to the SMTP server for improved performance
authorFrédéric Buclin <LpSolit@gmail.com>
Thu, 16 Oct 2014 16:09:15 +0000 (18:09 +0200)
committerFrédéric Buclin <LpSolit@gmail.com>
Thu, 16 Oct 2014 16:09:15 +0000 (18:09 +0200)
r=dylan a=glob

Bugzilla.pm
Bugzilla/Mailer.pm

index 2347a8ae8cdc7cd8a2640a5efc8ff9be6d94f29c..048e72d481868b41a8acba1afc53a3b81b643716 100644 (file)
@@ -659,13 +659,16 @@ sub memcached {
 # Per-process cleanup. Note that this is a plain subroutine, not a method,
 # so we don't have $class available.
 sub _cleanup {
-    my $main   = Bugzilla->request_cache->{dbh_main};
-    my $shadow = Bugzilla->request_cache->{dbh_shadow};
+    my $cache = Bugzilla->request_cache;
+    my $main = $cache->{dbh_main};
+    my $shadow = $cache->{dbh_shadow};
     foreach my $dbh ($main, $shadow) {
         next if !$dbh;
         $dbh->bz_rollback_transaction() if $dbh->bz_in_transaction;
         $dbh->disconnect;
     }
+    my $smtp = $cache->{smtp};
+    $smtp->disconnect if $smtp;
     clear_request_cache();
 
     # These are both set by CGI.pm but need to be undone so that
index 3c88153066f839be4d89f916e7b0681afbf3dd8c..01e0dc25597563780b615258bb08cfc7f169cb02 100644 (file)
@@ -25,7 +25,7 @@ use Encode qw(encode);
 use Encode::MIME::Header;
 use Email::MIME;
 use Email::Sender::Simple qw(sendmail);
-use Email::Sender::Transport::SMTP;
+use Email::Sender::Transport::SMTP::Persistent;
 use Bugzilla::Sender::Transport::Sendmail;
 
 sub MessageToMTA {
@@ -127,7 +127,8 @@ sub MessageToMTA {
     }
 
     if ($method eq "SMTP") {
-        $transport = Email::Sender::Transport::SMTP->new({
+        $transport = Bugzilla->request_cache->{smtp} //=
+          Email::Sender::Transport::SMTP::Persistent->new({
             host  => Bugzilla->params->{'smtpserver'},
             sasl_username => Bugzilla->params->{'smtp_username'},
             sasl_password => Bugzilla->params->{'smtp_password'},