From ac474b431a77107fe8994c94806864bab2bc7fa9 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Thu, 14 Oct 2021 13:16:04 +0000 Subject: git: async_err shows retried requests properly We make $req a reference upon retrying, but "SCALAR(...)" in error messages isn't helpful, so dereference the scalar ref. --- lib/PublicInbox/Git.pm | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'lib/PublicInbox/Git.pm') diff --git a/lib/PublicInbox/Git.pm b/lib/PublicInbox/Git.pm index 7c08be47..016dd2ae 100644 --- a/lib/PublicInbox/Git.pm +++ b/lib/PublicInbox/Git.pm @@ -19,7 +19,7 @@ use Time::HiRes qw(stat); use PublicInbox::Spawn qw(popen_rd spawn); use PublicInbox::Tmpfile; use IO::Poll qw(POLLIN); -use Carp qw(croak); +use Carp qw(croak carp); use Digest::SHA (); use PublicInbox::DS qw(dwaitpid); our @EXPORT_OK = qw(git_unquote git_quote); @@ -228,7 +228,7 @@ sub cat_async_step ($$) { } $self->{rbuf} = $rbuf if $$rbuf ne ''; eval { $cb->($bref, $oid, $type, $size, $arg) }; - async_err($self, "E: cat $req ($oid) $@") if $@; + async_err($self, $req, $oid, $@, 'cat') if $@; } sub cat_async_wait ($) { @@ -274,7 +274,7 @@ sub check_async_step ($$) { } $self->{rbuf_c} = $rbuf if $$rbuf ne ''; eval { $cb->($hex, $type, $size, $arg, $self) }; - async_err($self, "E: check $req ($hex) $@") if $@; + async_err($self, $req, $hex, $@, 'check') if $@; } sub check_async_wait ($) { @@ -342,6 +342,7 @@ sub async_abort ($) { my $q = $self->{"inflight$c"}; while (@$q) { my ($req, $cb, $arg) = splice(@$q, 0, 3); + $req = $$req if ref($req); $req =~ s/ .*//; # drop git_dir for Gcf2Client eval { $cb->(undef, $req, undef, undef, $arg) }; warn "E: (in abort) $req: $@" if $@; @@ -359,10 +360,11 @@ sub fail { # may be augmented in subclasses croak(ref($self) . ' ' . ($self->{git_dir} // '') . ": $msg"); } -sub async_err ($$) { - my ($self, $msg) = @_; - return warn($msg) if $async_warn; - $self->fail($msg); +sub async_err ($$$$$) { + my ($self, $req, $oid, $err, $action) = @_; + $req = $$req if ref($req); # retried + my $msg = "E: $action $req ($oid): $err"; + $async_warn ? carp($msg) : $self->fail($msg); } # $git->popen(qw(show f00)); # or -- cgit v1.2.3-24-ge0c7