]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/GetlineBody.pm
qspawn: replace anonymous $end callbacks w/ event_step
[public-inbox.git] / lib / PublicInbox / GetlineBody.pm
index 0a922fd271ccd53426fe3caa18c11be105f3d8cf..750a8c536183e0abeb2cd0eba60b54ab341e6de4 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (C) 2016-2018 all contributors <meta@public-inbox.org>
+# Copyright (C) 2016-2019 all contributors <meta@public-inbox.org>
 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
 
 # Wrap a pipe or file for PSGI streaming response bodies and calls the
@@ -13,10 +13,11 @@ use strict;
 use warnings;
 
 sub new {
-       my ($class, $rpipe, $end, $buf, $filter) = @_;
+       my ($class, $rpipe, $end, $end_arg, $buf, $filter) = @_;
        bless {
                rpipe => $rpipe,
                end => $end,
+               end_arg => $end_arg,
                buf => $buf,
                filter => $filter || 0,
        }, $class;
@@ -40,10 +41,9 @@ sub getline {
 
 sub close {
        my ($self) = @_;
-       my $rpipe = delete $self->{rpipe};
+       my ($rpipe, $end, $end_arg) = delete @$self{qw(rpipe end end_arg)};
        close $rpipe if $rpipe;
-       my $end = delete $self->{end};
-       $end->() if $end;
+       $end->($end_arg) if $end;
 }
 
 1;