about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2017-01-21 02:29:50 +0000
committerEric Wong <e@80x24.org>2017-01-21 02:30:06 +0000
commit984df62e41cd7c90fda9b7f129616d1b30fa02e4 (patch)
tree63846fb0d0507357b274e35422994a1876f77d02
parent488211c1f3066cebfe5d74332527dcc790ddd740 (diff)
downloadpublic-inbox-984df62e41cd7c90fda9b7f129616d1b30fa02e4.tar.gz
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).
-rw-r--r--lib/PublicInbox/Qspawn.pm19
-rw-r--r--lib/PublicInbox/RepobrowseGitSnapshot.pm2
2 files changed, 8 insertions, 13 deletions
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;
                 }