From 984df62e41cd7c90fda9b7f129616d1b30fa02e4 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sat, 21 Jan 2017 02:29:50 +0000 Subject: qspawn: better annotate where $qx_cb is called Hopefully this makes the code easier-to-follow for random readers. This requires a small amount of modification to our one caller, but this is a new, unstable API (as is nearly all of our code). --- lib/PublicInbox/Qspawn.pm | 19 +++++++------------ lib/PublicInbox/RepobrowseGitSnapshot.pm | 2 +- 2 files changed, 8 insertions(+), 13 deletions(-) (limited to 'lib') diff --git a/lib/PublicInbox/Qspawn.pm b/lib/PublicInbox/Qspawn.pm index da770cc0..73022656 100644 --- a/lib/PublicInbox/Qspawn.pm +++ b/lib/PublicInbox/Qspawn.pm @@ -74,10 +74,10 @@ sub _psgi_finish ($$) { sub psgi_qx { my ($self, $env, $limiter, $qx_cb) = @_; - my $qx = PublicInbox::Qspawn::Qx->new($qx_cb); + my $qx = PublicInbox::Qspawn::Qx->new; my $end = sub { _psgi_finish($self, $env); - $qx->close; + eval { $qx_cb->($qx) }; $qx = undef; }; my $rpipe; @@ -196,19 +196,14 @@ use strict; use warnings; sub new { - my ($class, $cb) = @_; - bless [ '', $cb ], $class; + my ($class) = @_; + my $buf = ''; + bless \$buf, $class; } +# called by PublicInbox::HTTPD::Async ($fh->write) sub write { - $_[0]->[0] .= $_[1]; - undef; -} - -sub close { - my ($self) = @_; - my $cb = $self->[1]; - eval { $cb->(\($self->[0])) }; + ${$_[0]} .= $_[1]; undef; } diff --git a/lib/PublicInbox/RepobrowseGitSnapshot.pm b/lib/PublicInbox/RepobrowseGitSnapshot.pm index cceb4641..a9751b97 100644 --- a/lib/PublicInbox/RepobrowseGitSnapshot.pm +++ b/lib/PublicInbox/RepobrowseGitSnapshot.pm @@ -87,7 +87,7 @@ sub call_git_snapshot ($$) { # invoked by PublicInbox::RepobrowseBase::call $env->{'qspawn.quiet'} = 1; my $tree_cb = $env->{'repobrowse.tree_cb'} = sub { my ($ref) = @_; - if (ref($ref) eq 'SCALAR') { + if (defined $ref) { $tree = $$ref; chomp $tree; } -- cgit v1.2.3-24-ge0c7