pkg: p5-TimeDate
rpm: perl-TimeDate
-* Devel::Peek deb: libperl5.$MINOR (e.g. libperl5.24)
- pkg: perl5
- rpm: perl-Devel-Peek
- (typically installed alongside Perl5)
-
* Email::MIME deb: libemail-mime-perl
pkg: p5-Email-MIME
rpm: perl-Email-MIME
rpm: perl-DBI
(pulled in by DBD::SQLite)
+* Devel::Peek deb: libperl5.$MINOR (e.g. libperl5.24)
+ pkg: perl5
+ rpm: perl-Devel-Peek
+ (optional for stale FD cleanup in daemons,
+ typically installed alongside Perl5)
+
- Filesys::Notify::Simple deb: libfilesys-notify-simple-perl
pkg: pkg-Filesys-Notify-Simple
rpm: perl-Filesys-Notify-Simple
STDOUT->autoflush(1);
STDERR->autoflush(1);
require PublicInbox::DS;
+require PublicInbox::EvCleanup;
require POSIX;
require PublicInbox::Listener;
require PublicInbox::ParentPipe;
sub daemon_loop ($$) {
my ($refresh, $post_accept) = @_;
+ PublicInbox::EvCleanup::enable(); # early for $refresh
my $parent_pipe;
if ($worker_processes > 0) {
$refresh->(); # preload by default
@listeners = map {
PublicInbox::Listener->new($_, $post_accept)
} @listeners;
- PublicInbox::EvCleanup::enable();
PublicInbox::DS->EventLoop;
$parent_pipe = undef;
}
use warnings;
use PublicInbox::Git;
use PublicInbox::MID qw(mid2path);
-use Devel::Peek qw(SvREFCNT);
use PublicInbox::MIME;
+# Long-running "git-cat-file --batch" processes won't notice
+# unlinked packs, so we need to restart those processes occasionally.
+# Xapian and SQLite file handles are mostly stable, but sometimes an
+# admin will attempt to replace them atomically after compact/vacuum
+# and we need to be prepared for that.
my $cleanup_timer;
-eval {
- $cleanup_timer = 'disabled';
- require PublicInbox::EvCleanup;
- $cleanup_timer = undef; # OK if we get here
-};
-my $cleanup_broken = $@;
-
+my $cleanup_avail = -1; # 0, or 1
+my $have_devel_peek;
my $CLEANUP = {}; # string(inbox) -> inbox
sub cleanup_task () {
$cleanup_timer = undef;
my $next = {};
for my $ibx (values %$CLEANUP) {
my $again;
- foreach my $f (qw(mm search)) {
- delete $ibx->{$f} if SvREFCNT($ibx->{$f}) == 1;
+ if ($have_devel_peek) {
+ foreach my $f (qw(mm search)) {
+ # we bump refcnt by assigning tmp, here:
+ my $tmp = $ibx->{$f} or next;
+ next if Devel::Peek::SvREFCNT($tmp) > 2;
+ delete $ibx->{$f};
+ # refcnt is zero when tmp is out-of-scope
+ }
}
my $expire = time - 60;
if (my $git = $ibx->{git}) {
$again = 1 if $git->cleanup($expire);
}
}
- $again ||= !!($ibx->{mm} || $ibx->{search});
+ if ($have_devel_peek) {
+ $again ||= !!($ibx->{mm} || $ibx->{search});
+ }
$next->{"$ibx"} = $ibx if $again;
}
$CLEANUP = $next;
}
+sub cleanup_possible () {
+ # no need to require EvCleanup, here, if it were enabled another
+ # module would've require'd it, already
+ eval { PublicInbox::EvCleanup::enabled() } or return 0;
+
+ eval {
+ require Devel::Peek; # needs separate package in Fedora
+ $have_devel_peek = 1;
+ };
+ 1;
+}
+
sub _cleanup_later ($) {
my ($self) = @_;
- return if $cleanup_broken;
- return unless PublicInbox::EvCleanup::enabled();
+ $cleanup_avail = cleanup_possible() if $cleanup_avail < 0;
+ return if $cleanup_avail != 1;
$cleanup_timer ||= PublicInbox::EvCleanup::later(*cleanup_task);
$CLEANUP->{"$self"} = $self;
}
ok($lim, 'Limiter exists');
is($lim->{max}, 3, 'limiter has expected slots');
$ibx->{git} = undef;
- PublicInbox::Inbox::cleanup_task;
my $new = $ibx->git;
isnt($old, "$new", 'got new Git object');
is("$new->{-httpbackend_limiter}", "$lim", 'same limiter');