1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
|
From 2256b4671d48bcddff5145904d50c91fd91f00a2 Mon Sep 17 00:00:00 2001
From: Niko Tyni <ntyni@debian.org>
Date: Fri, 11 Feb 2022 21:55:29 +0200
Subject: [PATCH] syswrite test: unclog the pipe harder
Reading out 4 kB from a full pipe is not enough to unblock
it on all systems.
On Linux, the pipe size is by default 16 * page size, and
at least the Debian (and apparently Alpine too) ppc64le port
has a page size of 64 kB instead of the more usual 4 kB.
Bug: https://rt.cpan.org/Public/Bug/Display.html?id=140489
Forwarded: https://rt.cpan.org/Public/Bug/Display.html?id=140489
Bug-Debian: https://bugs.debian.org/1004146
Last-Update: 2025-09-15
--- a/lib/Test/Future/IO/Impl.pm
+++ b/lib/Test/Future/IO/Impl.pm
@@ -332,8 +332,11 @@ sub run_send_test
or die "Cannot socketpair() - $!";
$wr->blocking( 0 );
+ my $i = 0;
# Attempt to fill the buffer
- $wr->write( "X" x 4096 ) for 1..256;
+ $i++ while $wr->write( "X" x 4096 );
+ $! == Errno::EAGAIN or $! == Errno::EWOULDBLOCK or
+ die "Expected EAGAIN, got $!";
my $f = Future::IO->send( $wr, "more" );
@@ -342,7 +345,7 @@ sub run_send_test
# Now make some space. We need to drain it quite a lot for mechanisms
# like ppoll() to be happy that the socket is actually writable
$rd->blocking( 0 );
- $rd->read( my $buf, 4096 ) for 1..256;
+ $rd->read( my $buf, 4096 ) while !$f->is_ready and $i-- > 0;
is( scalar $f->get, 4, 'Future::IO->send yields written count' );
}
@@ -505,15 +508,18 @@ sub _run_write_test
pipe my ( $rd, $wr ) or die "Cannot pipe() - $!";
$wr->blocking( 0 );
+ my $i = 0;
# Attempt to fill the pipe
- $wr->$method( "X" x 4096 ) for 1..256;
+ $i++ while $wr->$method( "X" x 4096 );
+ $! == Errno::EAGAIN or $! == Errno::EWOULDBLOCK or
+ die "Expected EAGAIN, got $!";
my $f = Future::IO->$method( $wr, "more" );
ok( !$f->is_ready, '$f is still pending' );
# Now make some space
- $rd->read( my $buf, 4096 );
+ $rd->read( my $buf, 4096 ) while !$f->is_ready and $i-- > 0;
is( scalar $f->get, 4, "Future::IO->$method yields written count" );
}
|