about summary refs log tree commit homepage
path: root/lib/PublicInbox/HTTPD/Async.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2019-12-25 07:50:36 +0000
committerEric Wong <e@80x24.org>2019-12-26 10:48:19 +0000
commitbfa40d0c4a970e5af0eae0441920a491c4f6fa1d (patch)
tree49f80c0ed96b50f922401e29db8d0d16d54ec5bc /lib/PublicInbox/HTTPD/Async.pm
parent5c94a55c24a17c8250cf80d78246851c0a7c4087 (diff)
downloadpublic-inbox-bfa40d0c4a970e5af0eae0441920a491c4f6fa1d.tar.gz
Another step towards removing anonymous subs to eliminate
a possible source of memory leaks and high memory use.
Diffstat (limited to 'lib/PublicInbox/HTTPD/Async.pm')
-rw-r--r--lib/PublicInbox/HTTPD/Async.pm8
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/PublicInbox/HTTPD/Async.pm b/lib/PublicInbox/HTTPD/Async.pm
index d5628ee8..d182c118 100644
--- a/lib/PublicInbox/HTTPD/Async.pm
+++ b/lib/PublicInbox/HTTPD/Async.pm
@@ -10,7 +10,7 @@ package PublicInbox::HTTPD::Async;
 use strict;
 use warnings;
 use base qw(PublicInbox::DS);
-use fields qw(cb end);
+use fields qw(cb arg end end_arg);
 use Errno qw(EAGAIN);
 use PublicInbox::Syscall qw(EPOLLIN EPOLLET);
 
@@ -18,12 +18,12 @@ use PublicInbox::Syscall qw(EPOLLIN EPOLLET);
 # $io is a read-only pipe ($rpipe) for now, but may be a
 # bidirectional socket in the future.
 sub new {
-        my ($class, $io, $cb, $end) = @_;
+        my ($class, $io, $cb, $arg, $end, $end_arg) = @_;
 
         # no $io? call $cb at the top of the next event loop to
         # avoid recursion:
         unless (defined($io)) {
-                PublicInbox::DS::requeue($cb);
+                PublicInbox::DS::requeue($cb ? $cb : $arg);
                 die '$end unsupported w/o $io' if $end;
                 return;
         }
@@ -32,7 +32,9 @@ sub new {
         IO::Handle::blocking($io, 0);
         $self->SUPER::new($io, EPOLLIN | EPOLLET);
         $self->{cb} = $cb; # initial read callback, later replaced by main_cb
+        $self->{arg} = $arg; # arg for $cb
         $self->{end} = $end; # like END {}, but only for this object
+        $self->{end_arg} = $end_arg; # arg for $end
         $self;
 }