about summary refs log tree commit homepage
path: root/lib/PublicInbox/Sigfd.pm
diff options
context:
space:
mode:
authorEric Wong <e@yhbt.net>2020-06-27 10:03:38 +0000
committerEric Wong <e@yhbt.net>2020-06-28 22:27:15 +0000
commit94096cab6cd5e00c8a36a4a2667bdb9acf43d01f (patch)
tree791b61b5e115e6ca0835a4f55445795b0d766dc1 /lib/PublicInbox/Sigfd.pm
parent58c0333adbdd9f5f82309cb6eef3c379f0ff064e (diff)
downloadpublic-inbox-94096cab6cd5e00c8a36a4a2667bdb9acf43d01f.tar.gz
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.
Diffstat (limited to 'lib/PublicInbox/Sigfd.pm')
-rw-r--r--lib/PublicInbox/Sigfd.pm9
1 files changed, 5 insertions, 4 deletions
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 <meta@public-inbox.org>
 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
+
+# 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)