1 # subclass Mail::Thread and use this to workaround a memory leak
2 # Based on the patch in: https://rt.cpan.org/Public/Bug/Display.html?id=22817
4 # Additionally, workaround for a bug where $walk->topmost returns undef:
5 # - http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=795913
6 # - https://rt.cpan.org/Ticket/Display.html?id=106498
8 # License differs from the rest of public-inbox (but is compatible):
9 # This library is free software; you can redistribute it and/or modify
10 # it under the same terms as Perl itself.
11 package PublicInbox::Thread;
14 use base qw(Mail::Thread);
16 if ($Mail::Thread::VERSION <= 2.55) {
17 eval q(sub _container_class { 'PublicInbox::Thread::Container' });
22 (eval { $a->topmost->message->header('X-PI-TS') } || 0) <=>
23 (eval { $b->topmost->message->header('X-PI-TS') } || 0)
29 (eval { $b->topmost->message->header('X-PI-TS') } || 0) <=>
30 (eval { $a->topmost->message->header('X-PI-TS') } || 0)
34 package PublicInbox::Thread::Container;
37 use base qw(Mail::Thread::Container);
38 use Scalar::Util qw(weaken);
39 sub parent { @_ == 2 ? weaken($_[0]->{parent} = $_[1]) : $_[0]->{parent} }
42 $_[0]->SUPER::topmost || PublicInbox::Thread::CPANRTBug106498->new;
46 # - http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=795913
47 # - https://rt.cpan.org/Ticket/Display.html?id=106498
48 package PublicInbox::Thread::CPANRTBug106498;
52 sub new { bless {}, $_[0] }