]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
treewide: remove unnecessary Sigfd use and requires
authorEric Wong <e@80x24.org>
Tue, 29 Apr 2025 17:16:44 +0000 (17:16 +0000)
committerEric Wong <e@80x24.org>
Thu, 1 May 2025 21:29:40 +0000 (21:29 +0000)
signalfd is an implementation detail and its use may be
replaced in future changes.

lib/PublicInbox/ExtSearchIdx.pm
lib/PublicInbox/TestCommon.pm
t/httpd-unix.t
t/spawn.t
xt/git-http-backend-parallel.t

index 7cf600c1f97ca0b15d2871a94028e51a1b34e0fd..748743fe76c7953e15d8d8d1b082e442bf70476c 100644 (file)
@@ -1358,7 +1358,6 @@ sub eidx_watch { # public-inbox-extindex --watch main loop
        require PublicInbox::InboxIdle;
        require PublicInbox::DS;
        require PublicInbox::Syscall;
-       require PublicInbox::Sigfd;
        my $idler = PublicInbox::InboxIdle->new($self->{cfg});
        if (!$self->{cfg}) {
                $idler->watch_inbox($_) for (@{ibx_sorted($self, 'active')});
index ec54e2f1cc1d76e0da0136d3fc73273e3dc2132f..80032272c34d51397e4a373f21d2d6efac7d6252 100644 (file)
@@ -32,6 +32,7 @@ BEGIN {
                tcp_host_port test_lei lei lei_ok $lei_out $lei_err $lei_opt
                test_httpd no_httpd_errors xbail require_cmd is_xdeeply tail_f
                ignore_inline_c_missing no_pollerfd no_coredump cfg_new
+               require_fast_reliable_signals
                strace strace_inject lsof_pid oct_is $find_xh_pid);
        require Test::More;
        my @methods = grep(!/\W/, @Test::More::EXPORT);
@@ -61,6 +62,18 @@ sub check_broken_tmpfs () {
        1;
 }
 
+sub require_fast_reliable_signals (;$) {
+       state $ok = do {
+               require PublicInbox::Sigfd;
+               my $s = PublicInbox::Sigfd->new({}) ? 1 : $ENV{TEST_UNRELIABLE};
+               PublicInbox::DS->Reset;
+               $s;
+       };
+       return $ok if $ok || defined(wantarray);
+       my $m = "fast, reliable signals not available(\$^O=$^O)";
+       @_ ? skip($m, 1) : plan(skip_all => $m);
+}
+
 sub require_bsd (;$) {
        state $ok = ($^O =~ m!\A(?:free|net|open)bsd\z! ||
                        $^O eq 'dragonfly');
index d4d50528ef076a50eb85e995e45ee53685917c7e..7f992f7fc75af076c7909b1edf295e95a2e10ad0 100644 (file)
@@ -11,7 +11,6 @@ use autodie qw(close);
 require_mods qw(-httpd);
 use IO::Socket::UNIX;
 use POSIX qw(mkfifo);
-require PublicInbox::Sigfd;
 my ($tmpdir, $for_destroy) = tmpdir();
 my $unix = "$tmpdir/unix.sock";
 my $psgi = './t/httpd-corner.psgi';
@@ -97,11 +96,6 @@ check_sock($unix);
        ok(-S $unix, 'unix socket still exists');
 }
 
-# portable Perl can delay or miss signal dispatches due to races,
-# so disable some tests on systems lacking signalfd(2) or EVFILT_SIGNAL
-my $has_sigfd = PublicInbox::Sigfd->new({}) ? 1 : $ENV{TEST_UNRELIABLE};
-PublicInbox::DS::Reset() if $has_sigfd;
-
 sub delay_until {
        my ($cond, $msg) = @_;
        my $end = time + 30;
@@ -114,7 +108,7 @@ sub delay_until {
 
 SKIP: {
        require_mods('Net::Server::Daemonize', 52);
-       $has_sigfd or skip('signalfd / EVFILT_SIGNAL not available', 52);
+       require_fast_reliable_signals 1;
        my $pid_file = "$tmpdir/pid";
        my $read_pid = sub {
                my $f = shift;
index 36f4ed2e595ee1a5f0496921172814936ed686a8..dd30bf457215fe7535f7cfbbf35cd930f2e86f90 100644 (file)
--- a/t/spawn.t
+++ b/t/spawn.t
@@ -4,7 +4,6 @@
 use v5.12;
 use Test::More;
 use PublicInbox::Spawn qw(which spawn popen_rd run_qx);
-require PublicInbox::Sigfd;
 require PublicInbox::DS;
 use PublicInbox::OnDestroy;
 my $rlimit_map = PublicInbox::Spawn->can('rlimit_map');
index 70b5d0eae7a4f5895d11d714644627517b3f8773..2d957b65c777a3c09ae0a51c7ca3f8dab8d5f372 100644 (file)
@@ -10,7 +10,6 @@ use File::Path qw(remove_tree);
 use PublicInbox::IO qw(write_file try_cat);
 use PublicInbox::Spawn qw(spawn);
 use PublicInbox::Git qw(git_exe);
-require PublicInbox::Sigfd;
 my $git_dir = $ENV{GIANT_GIT_DIR} //
        plan 'skip_all' => 'GIANT_GIT_DIR not defined';
 require_mods qw(-httpd psgi);
@@ -55,13 +54,10 @@ my $run_clones = sub {
        \%chld_status;
 };
 
-my $sigfd = PublicInbox::Sigfd->new;
 my $reload_cfg = sub {
        write_file '>>', $henv->{PI_CONFIG}, @_;
        kill 'HUP', $PublicInbox::TestCommon::CURRENT_DAEMON->{pid};
-       # signalfd/EVFILT_SIGNAL platforms should handle signals more
-       # predictably and not need tick
-       tick(1) unless $sigfd;
+       tick(1) unless require_fast_reliable_signals;
 };
 
 my $ck_503 = sub {