]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
listener: bless all accepted sockets
authorEric Wong <e@80x24.org>
Tue, 12 May 2026 22:31:49 +0000 (22:31 +0000)
committerEric Wong <e@80x24.org>
Fri, 15 May 2026 09:56:50 +0000 (09:56 +0000)
Newer IO::Socket::SSL (tested 2.098 on FreeBSD) seems to trigger
undefined variable warnings on TLS negotiation failures and
other problems.  Since I've been meaning to unify the {rbuf}
used by PublicInbox::DS with the {pi_io_rbuf} field anyways, it
seems best to bless these as PublicInbox::IO objects as early as
possible and avoid adding branches into in later stages.

I originally considered specialized changes to accept_tls_step
to stash the FD and ensure proper cleanup after IO::Socket::SSL
closes the socket behind our back, but it was too complex.

lib/PublicInbox/Listener.pm

index 364301d0f2dc616800ff393a7c205a25deaa5fe5..a87581db5d9ffbcfc286c87543d09dab75513da2 100644 (file)
@@ -34,6 +34,10 @@ sub event_step {
        do {
                if (my $addr = accept(my $c, $sock)) {
                        IO::Handle::blocking($c, 0); # no accept4 :<
+                       # newer IO::Socket::SSL (tested 2.098) doesn't like
+                       # unblessed sockets on TLS handshake failures;
+                       # and plan to unify DS{rbuf} with {pi_io_rbuf}
+                       bless $c, 'PublicInbox::IO';
                        eval { $self->{post_accept}->($c, $addr, $sock) };
                        warn "E: $@\n" if $@;
                } elsif ($! == EAGAIN || $! == ECONNABORTED) {