X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=lib%2FPublicInbox%2FOnDestroy.pm;h=615bc450998beea1e82606db35c0d456450d966b;hb=4eee5af6011cc8cdefb66c9729952c7eff5c0b0b;hp=841f87d45eabe27ea676536f64268a88127a4953;hpb=7e7f4bfca5f2ef0d123445e074280f5e65cdfb85;p=public-inbox.git
diff --git a/lib/PublicInbox/OnDestroy.pm b/lib/PublicInbox/OnDestroy.pm
index 841f87d4..615bc450 100644
--- a/lib/PublicInbox/OnDestroy.pm
+++ b/lib/PublicInbox/OnDestroy.pm
@@ -1,4 +1,4 @@
-# Copyright (C) 2020 all contributors
+# Copyright (C) 2020-2021 all contributors
# License: AGPL-3.0+
package PublicInbox::OnDestroy;
@@ -10,6 +10,11 @@ sub new {
sub DESTROY {
my ($cb, @args) = @{$_[0]};
+ if (!ref($cb) && $cb) {
+ my $pid = $cb;
+ return if $pid != $$;
+ $cb = shift @args;
+ }
$cb->(@args) if $cb;
}