1# test EINVAL for splicing with negative idle timeout 2 3use strict; 4use warnings; 5use IO::Socket::IP; 6use BSD::Socket::Splice "SO_SPLICE"; 7use Config; 8 9our %args = ( 10 errno => 'EINVAL', 11 func => sub { 12 my $sl = IO::Socket::IP->new( 13 Proto => "tcp", 14 Listen => 5, 15 LocalAddr => "127.0.0.1", 16 ) or die "socket listen failed: $!"; 17 18 my $s = IO::Socket::IP->new( 19 Proto => "tcp", 20 PeerAddr => $sl->sockhost(), 21 PeerPort => $sl->sockport(), 22 ) or die "socket failed: $!"; 23 24 my $ss = IO::Socket::IP->new( 25 Proto => "tcp", 26 PeerAddr => $sl->sockhost(), 27 PeerPort => $sl->sockport(), 28 ) or die "socket splice failed: $!"; 29 30 my $packed; 31 if ($Config{longsize} == 8) { 32 $packed = pack('ixxxxqql!', $ss->fileno(),-1,-1-1); 33 } else { 34 my $pad = $Config{ARCH} eq 'i386'? '': 'xxxx'; 35 my $packstr = "i${pad}lllll!${pad}"; 36 $packed = pack($packstr, $ss->fileno(),0,0,-1,-1,-1); 37 } 38 $s->setsockopt(SOL_SOCKET, SO_SPLICE, $packed) 39 and die "splice with negative idle timeout succeeded"; 40 }, 41); 42