From 94096cab6cd5e00c8a36a4a2667bdb9acf43d01f Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sat, 27 Jun 2020 10:03:38 +0000 Subject: ds: remove fields.pm usage Since the removal of pseudo-hash support in Perl 5.10, the "fields" module no longer provides the space or speed benefits it did in 5.8. It also does not allow for compile-time checks, only run-time checks. To me, the extra developer overhead in maintaining "use fields" args has become a hassle. None of our non-DS-related code uses fields.pm, nor do any of our current dependencies. In fact, Danga::Socket (which DS was originally forked from) and its subclasses are the only fields.pm users I've ever encountered in the wild. Removing fields may make our code more approachable to other Perl hackers. So stop using fields.pm and locked hashes, but continue to document what fields do for non-trivial classes. --- lib/PublicInbox/Sigfd.pm | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'lib/PublicInbox/Sigfd.pm') diff --git a/lib/PublicInbox/Sigfd.pm b/lib/PublicInbox/Sigfd.pm index 17456592..bf91bb37 100644 --- a/lib/PublicInbox/Sigfd.pm +++ b/lib/PublicInbox/Sigfd.pm @@ -1,9 +1,11 @@ # Copyright (C) 2019-2020 all contributors # License: AGPL-3.0+ + +# Wraps a signalfd (or similar) for PublicInbox::DS +# fields: (sig: hashref similar to %SIG, but signal numbers as keys) package PublicInbox::Sigfd; use strict; use parent qw(PublicInbox::DS); -use fields qw(sig); # hashref similar to %SIG, but signal numbers as keys use PublicInbox::Syscall qw(signalfd EPOLLIN EPOLLET SFD_NONBLOCK); use POSIX qw(:signal_h); use IO::Handle (); @@ -12,7 +14,6 @@ use IO::Handle (); # are available. sub new { my ($class, $sig, $flags) = @_; - my $self = fields::new($class); my %signo = map {; my $cb = $sig->{$_}; # SIGWINCH is 28 on FreeBSD, NetBSD, OpenBSD @@ -22,6 +23,7 @@ sub new { }; $num => $cb; } keys %$sig; + my $self = bless { sig => \%signo }, $class; my $io; my $fd = signalfd(-1, [keys %signo], $flags); if (defined $fd && $fd >= 0) { @@ -35,9 +37,8 @@ sub new { $self->SUPER::new($io, EPOLLIN | EPOLLET); } else { # master main loop $self->{sock} = $io; + $self; } - $self->{sig} = \%signo; - $self; } # PublicInbox::Daemon in master main loop (blocking) -- cgit v1.2.3-24-ge0c7