We can avoid making getpeername syscalls this way.
my ($self) = @_;
# no loop here, we want to fairly distribute clients
# between multiple processes sharing the same socket
- if (accept(my $c, $self->{sock})) {
+ if (my $addr = accept(my $c, $self->{sock})) {
IO::Handle::blocking($c, 0); # no accept4 :<
- $self->{post_accept}->($c);
+ $self->{post_accept}->($c, $addr);
}
}
require PublicInbox::Config;
my $nntpd = PublicInbox::NNTPD->new;
daemon_run('0.0.0.0:119',
- sub { $nntpd->refresh_groups },
- sub ($) { PublicInbox::NNTP->new($_[0], $nntpd) });
+ sub { $nntpd->refresh_groups }, # refresh
+ sub ($$) { PublicInbox::NNTP->new($_[0], $nntpd) }); # post_accept
1;
package PublicInbox::NNTPD;