]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
http: don't ->close after ->accept_SSL failure
authorEric Wong <e@80x24.org>
Thu, 5 Jun 2025 06:53:36 +0000 (06:53 +0000)
committerEric Wong <e@80x24.org>
Thu, 5 Jun 2025 09:21:11 +0000 (09:21 +0000)
->accept_SSL failures leaves the socket ref as a GLOB (not
IO::Handle) and unable to respond to the ->close method.
Calling close in any form isn't actually necessary at all,
so just let refcounting destroy the socket.

Followup-to: e85d3280 (ds: don't try ->close after ->accept_SSL failure, 2023-11-02)
lib/PublicInbox/HTTP.pm

index f40d783856446bc77cf47a8f6b6ef5d131df189e..f456f3c07b248328cb38853dc8c426808ecef25f 100644 (file)
@@ -75,13 +75,10 @@ sub new ($$$) {
        my ($class, $sock, $addr, $srv_env) = @_;
        my $self = bless { srv_env => $srv_env }, $class;
        my $ev = EPOLLIN;
-       my $wbuf;
        if ($sock->can('accept_SSL') && !$sock->accept_SSL) {
-               return $sock->close if $! != EAGAIN;
-               $ev = PublicInbox::TLS::epollbit() or return $sock->close;
-               $wbuf = [ \&PublicInbox::DS::accept_tls_step ];
+               return if $! != EAGAIN || !($ev = PublicInbox::TLS::epollbit());
+               $self->{wbuf} = [ \&PublicInbox::DS::accept_tls_step ];
        }
-       $self->{wbuf} = $wbuf if $wbuf;
        ($addr, $self->{remote_port}) =
                PublicInbox::Daemon::host_with_port($addr);
        $self->{remote_addr} = $addr if $addr ne '127.0.0.1';