]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
git: workaround occasional -watch error message
authorEric Wong <e@80x24.org>
Tue, 9 Jan 2024 11:39:23 +0000 (11:39 +0000)
committerEric Wong <e@80x24.org>
Wed, 10 Jan 2024 10:26:55 +0000 (10:26 +0000)
I'm not sure how this happens (perl 5.34.1 on FreeBSD 13.2)
but it appears the {sock} check can succeed and then go undef
and become unable to call ->owner_pid.

This happens when libgit2 is in use, so perhaps that's a factor.
In any case, the rest of the tests succeed.

lib/PublicInbox/Git.pm

index 6c4fcf9328cd78b0b04678ba2b2dd4fa25ebd6f9..7b991c6b3be0c3e2c52a46ddc2449107c00b4db1 100644 (file)
@@ -208,8 +208,17 @@ sub cat_async_retry ($$) {
 
 sub gcf_inflight ($) {
        my ($self) = @_;
+       # FIXME: the first {sock} check can succeed but Perl can complain
+       # about calling ->owner_pid on an undefined value.  Not sure why or
+       # how this happens but t/imapd.t can complain about it, sometimes.
        if ($self->{sock}) {
-               return $self->{inflight} if $self->{sock}->owner_pid == $$;
+               if (eval { $self->{sock}->owner_pid == $$ }) {
+                       return $self->{inflight};
+               } elsif ($@) {
+                       no warnings 'uninitialized';
+                       warn "E: $self sock=$self->{sock}: owner_pid failed: ".
+                               "$@ (continuing...)";
+               }
                delete @$self{qw(sock inflight)};
        } else {
                $self->close;