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-06-24 02:52:27 +0000
committerEric Wong <e@80x24.org>2019-06-24 05:26:26 +0000
commit62e3722f13164696a7af66cfa6253f69f0f5892b (patch)
tree583601e2243609a85d89179b7f8e4e9f3ccc993c /lib/PublicInbox/HTTPD/Async.pm
parent7c89df780b7b160fe85b8a355455d06ec8499205 (diff)
downloadpublic-inbox-62e3722f13164696a7af66cfa6253f69f0f5892b.tar.gz
This is cleaner in most cases and may allow Perl to reuse memory
from unused fields.

We can do this now that we no longer support Perl 5.8; since
Danga::Socket was written with struct-like pseudo-hash support
in mind, and Perl 5.9+ dropped support for pseudo-hashes over
a decade ago.
Diffstat (limited to 'lib/PublicInbox/HTTPD/Async.pm')
-rw-r--r--lib/PublicInbox/HTTPD/Async.pm9
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/PublicInbox/HTTPD/Async.pm b/lib/PublicInbox/HTTPD/Async.pm
index 9cc41f17..bec49337 100644
--- a/lib/PublicInbox/HTTPD/Async.pm
+++ b/lib/PublicInbox/HTTPD/Async.pm
@@ -63,7 +63,7 @@ sub main_cb ($$$) {
 
                 # Done! Error handling will happen in $fh->close
                 # called by the {cleanup} handler
-                $http->{forward} = undef;
+                delete $http->{forward};
                 $self->close;
         }
 }
@@ -81,12 +81,13 @@ sub event_step { $_[0]->{cb}->(@_) }
 
 sub close {
         my $self = shift;
-        my $cleanup = $self->{cleanup};
-        $self->{cleanup} = $self->{cb} = undef;
+        delete $self->{cb};
         $self->SUPER::close(@_);
 
         # we defer this to the next timer loop since close is deferred
-        PublicInbox::EvCleanup::next_tick($cleanup) if $cleanup;
+        if (my $cleanup = delete $self->{cleanup}) {
+                PublicInbox::EvCleanup::next_tick($cleanup);
+        }
 }
 
 1;