From: Eric Wong Date: Tue, 12 May 2026 22:31:49 +0000 (+0000) Subject: listener: bless all accepted sockets X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8cfeeff83a1db46998daff1eccc6580dbc446bc1;p=thirdparty%2Fpublic-inbox.git listener: bless all accepted sockets 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. --- diff --git a/lib/PublicInbox/Listener.pm b/lib/PublicInbox/Listener.pm index 364301d0f..a87581db5 100644 --- a/lib/PublicInbox/Listener.pm +++ b/lib/PublicInbox/Listener.pm @@ -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) {