]> Sergey Matveev's repositories - public-inbox.git/commitdiff
purge Email::Address cache
authorEric Wong <e@80x24.org>
Thu, 1 May 2014 01:56:34 +0000 (01:56 +0000)
committerEric Wong <e@80x24.org>
Thu, 1 May 2014 01:56:34 +0000 (01:56 +0000)
This prevents memory bloat in case we're serving many requests
with a large, diverse set of email addresses (potentially from
malicious spammers).

lib/PublicInbox/Feed.pm
lib/PublicInbox/View.pm

index d535cea93c95e6cb63029a900342c0957ec64fff..6b317ab0573fb298b0882187ddd65accaed823ea 100644 (file)
@@ -43,6 +43,8 @@ sub generate {
                my ($add) = @_;
                add_to_feed($feed_opts, $feed, $add, $git);
        });
+       $git = undef; # destroy pipes
+       Email::Address->purge_cache;
        $feed->as_string;
 }
 
@@ -68,6 +70,7 @@ sub generate_html_index {
                push @messages, $mime;
                1;
        });
+       $git = undef; # destroy pipes.
 
        my $th = Mail::Thread->new(@messages);
        $th->thread;
@@ -85,6 +88,8 @@ sub generate_html_index {
        });
        dump_html_line($_, 0, \$html) for $th->rootset;
 
+       Email::Address->purge_cache;
+
        my $footer = nav_footer($args->{cgi}, $last);
        $footer = "<hr /><pre>$footer</pre>" if $footer;
        $html . "</pre>$footer</html>";
index c6ecee6ef9060eb1ac8e67fa7c2007228cfe82ed..a43ab620792c8de7aeb2f155d3923cc5ff36f14f 100644 (file)
@@ -210,6 +210,7 @@ sub html_footer {
                        $to ||= $dst;
                }
        }
+       Email::Address->purge_cache;
 
        my $subj = $mime->header('Subject') || '';
        $subj = "Re: $subj" unless $subj =~ /\bRe:/;