use PublicInbox::Inbox;
use PublicInbox::Spawn qw(popen_rd);
our $LD_PRELOAD = $ENV{LD_PRELOAD}; # only valid at startup
+our $DEDUPE; # set to {} to dedupe or clear cache
sub _array ($) { ref($_[0]) eq 'ARRAY' ? $_[0] : [ $_[0] ] }
my ($class, $file, $errfh) = @_;
$file //= default_file();
my $self;
+ my $set_dedupe;
if (ref($file) eq 'SCALAR') { # used by some tests
open my $fh, '<', $file or die; # PerlIO::scalar
$self = config_fh_parse($fh, "\n", '=');
bless $self, $class;
} else {
+ if (-f $file && $DEDUPE) {
+ $file = rel2abs_collapsed($file);
+ $self = $DEDUPE->{$file} and return $self;
+ $set_dedupe = 1;
+ }
$self = git_config_dump($class, $file, $errfh);
$self->{'-f'} = $file;
}
if (my $css = delete $self->{'publicinbox.css'}) {
$self->{css} = _array($css);
}
-
+ $DEDUPE->{$file} = $self if $set_dedupe;
$self;
}
use PublicInbox::Git;
use PublicInbox::GitAsyncCat;
use PublicInbox::Eml;
+use PublicInbox::Config;
our $SO_ACCEPTFILTER = 0x1000;
my @CMD;
my ($set_user, $oldset);
sub daemon_loop ($) {
my ($xnetd) = @_;
+ local $PublicInbox::Config::DEDUPE = {}; # enable dedupe cache
my $refresh = sub {
my ($sig) = @_;
+ %$PublicInbox::Config::DEDUPE = (); # clear cache
for my $xn (values %$xnetd) {
delete $xn->{tlsd}->{ssl_ctx}; # PublicInbox::TLS::start
eval { $xn->{refresh}->($sig) };
my $old_ibx = $cur->[0];
$cur->[0] = $ibx;
if ($old_ibx) {
- $ibx->{unlock_subs} and
- die "BUG: $dir->{unlock_subs} should not exist";
+ my $u = $ibx->{unlock_subs};
$ibx->{unlock_subs} = $old_ibx->{unlock_subs};
+ %{$ibx->{unlock_subs}} = (%$u, %{$ibx->{unlock_subs}}) if $u;
# Linux::Inotify2::Watch::name matches if watches are the
# same, no point in replacing a watch of the same name