about summary refs log tree commit homepage
diff options
context:
space:
mode:
-rw-r--r--lib/PublicInbox/DS.pm1
-rw-r--r--lib/PublicInbox/HTTP.pm21
-rw-r--r--lib/PublicInbox/HTTPD/Async.pm9
-rw-r--r--lib/PublicInbox/NNTP.pm4
4 files changed, 17 insertions, 18 deletions
diff --git a/lib/PublicInbox/DS.pm b/lib/PublicInbox/DS.pm
index f5986e55..482710f7 100644
--- a/lib/PublicInbox/DS.pm
+++ b/lib/PublicInbox/DS.pm
@@ -23,6 +23,7 @@ use Time::HiRes qw(clock_gettime CLOCK_MONOTONIC);
 use parent qw(Exporter);
 our @EXPORT_OK = qw(now msg_more write_in_full);
 use warnings;
+use 5.010_001;
 
 use PublicInbox::Syscall qw(:epoll);
 
diff --git a/lib/PublicInbox/HTTP.pm b/lib/PublicInbox/HTTP.pm
index 4738e156..94972054 100644
--- a/lib/PublicInbox/HTTP.pm
+++ b/lib/PublicInbox/HTTP.pm
@@ -118,8 +118,7 @@ sub read_input ($) {
 
         # env->{CONTENT_LENGTH} (identity)
         my $sock = $self->{sock};
-        my $len = $self->{input_left};
-        $self->{input_left} = undef;
+        my $len = delete $self->{input_left};
         my $rbuf = \($self->{rbuf});
         my $input = $env->{'psgi.input'};
 
@@ -246,8 +245,7 @@ sub next_request ($) {
 sub response_done_cb ($$) {
         my ($self, $alive) = @_;
         sub {
-                my $env = $self->{env};
-                $self->{env} = undef;
+                my $env = delete $self->{env};
                 $self->write(\"0\r\n\r\n") if $alive == 2;
                 $self->write(sub{$alive ? next_request($self) : $self->close});
         }
@@ -279,7 +277,7 @@ sub getline_cb ($$$) {
                 }
         }
 
-        $self->{forward} = $self->{pull} = undef;
+        delete @$self{qw(forward pull)};
         # avoid recursion
         if ($forward) {
                 eval { $forward->close };
@@ -370,8 +368,7 @@ sub read_input_chunked { # unlikely...
         my ($self) = @_;
         my $input = $self->{env}->{'psgi.input'};
         my $sock = $self->{sock};
-        my $len = $self->{input_left};
-        $self->{input_left} = undef;
+        my $len = delete $self->{input_left};
         my $rbuf = \($self->{rbuf});
 
         while (1) { # chunk start
@@ -442,11 +439,11 @@ sub quit {
 
 sub close {
         my $self = shift;
-        my $forward = $self->{forward};
-        my $env = $self->{env};
-        delete $env->{'psgix.io'} if $env; # prevent circular references
-        $self->{pull} = $self->{forward} = $self->{env} = undef;
-        if ($forward) {
+        if (my $env = delete $self->{env}) {
+                delete $env->{'psgix.io'}; # prevent circular references
+        }
+        delete $self->{pull};
+        if (my $forward = delete $self->{forward}) {
                 eval { $forward->close };
                 err($self, "forward ->close error: $@") if $@;
         }
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;
diff --git a/lib/PublicInbox/NNTP.pm b/lib/PublicInbox/NNTP.pm
index fbdf1364..6a582ea4 100644
--- a/lib/PublicInbox/NNTP.pm
+++ b/lib/PublicInbox/NNTP.pm
@@ -624,7 +624,7 @@ sub long_response ($$) {
         $self->{long_res} = sub {
                 my $more = eval { $cb->() };
                 if ($@ || !$self->{sock}) { # something bad happened...
-                        $self->{long_res} = undef;
+                        delete $self->{long_res};
 
                         if ($@) {
                                 err($self,
@@ -646,7 +646,7 @@ sub long_response ($$) {
                         push @$nextq, $self;
                         $nextt ||= PublicInbox::EvCleanup::asap(*next_tick);
                 } else { # all done!
-                        $self->{long_res} = undef;
+                        delete $self->{long_res};
                         check_read($self);
                         res($self, '.');
                         out($self, " deferred[$fd] done - %0.6f", now() - $t0);