From 48aca3659c248c936a978a8338cf19aacc9483a1 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Tue, 17 Oct 2023 23:38:02 +0000 Subject: syscall: common $F_SETPIPE_SZ definition We use this in various places to minimize or maximize pipe size on Linux. So keep it all in one place. --- t/gcf2.t | 5 +++-- t/lei-sigpipe.t | 7 +++---- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 't') diff --git a/t/gcf2.t b/t/gcf2.t index d12a4420..33f3bbca 100644 --- a/t/gcf2.t +++ b/t/gcf2.t @@ -10,6 +10,7 @@ use POSIX qw(_exit); use Cwd qw(abs_path); require_mods('PublicInbox::Gcf2'); use_ok 'PublicInbox::Gcf2'; +use PublicInbox::Syscall qw($F_SETPIPE_SZ); use PublicInbox::Import; my ($tmpdir, $for_destroy) = tmpdir(); @@ -109,7 +110,7 @@ SKIP: { for my $blk (1, 0) { my ($r, $w); pipe($r, $w) or BAIL_OUT $!; - fcntl($w, 1031, 4096) or + fcntl($w, $F_SETPIPE_SZ, 4096) or skip('Linux too old for F_SETPIPE_SZ', 14); $w->blocking($blk); seek($fh, 0, SEEK_SET) or BAIL_OUT "seek: $!"; @@ -129,7 +130,7 @@ SKIP: { $ck_copying->("pipe blocking($blk)"); pipe($r, $w) or BAIL_OUT $!; - fcntl($w, 1031, 4096) or BAIL_OUT $!; + fcntl($w, $F_SETPIPE_SZ, 4096) or BAIL_OUT $!; $w->blocking($blk); close $r; local $SIG{PIPE} = 'IGNORE'; diff --git a/t/lei-sigpipe.t b/t/lei-sigpipe.t index 55c208e2..622598a4 100644 --- a/t/lei-sigpipe.t +++ b/t/lei-sigpipe.t @@ -6,6 +6,7 @@ use v5.10.1; use PublicInbox::TestCommon; use POSIX qw(WTERMSIG WIFSIGNALED SIGPIPE); use PublicInbox::OnDestroy; +use PublicInbox::Syscall qw($F_SETPIPE_SZ); # undo systemd (and similar) ignoring SIGPIPE, since lei expects to be run # from an interactive terminal: @@ -21,10 +22,8 @@ test_lei(sub { my $imported; for my $out ([], [qw(-f mboxcl2)], [qw(-f text)]) { pipe(my ($r, $w)) or BAIL_OUT $!; - my $size = 65536; - if ($^O eq 'linux' && fcntl($w, 1031, 4096)) { - $size = 4096; - } + my $size = $F_SETPIPE_SZ && fcntl($w, $F_SETPIPE_SZ, 4096) ? + 4096 : 65536; unless (-f $f) { open my $fh, '>', $f or xbail "open $f: $!"; print $fh <<'EOM' or xbail; -- cgit v1.2.3-24-ge0c7