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
|
# test EINVAL for splicing with negative maximum
use strict;
use warnings;
use IO::Socket::IP;
use BSD::Socket::Splice "SO_SPLICE";
use Config;
our %args = (
errno => 'EINVAL',
func => sub {
my $sl = IO::Socket::IP->new(
Proto => "tcp",
Listen => 5,
LocalAddr => "127.0.0.1",
) or die "socket listen failed: $!";
my $s = IO::Socket::IP->new(
Proto => "tcp",
PeerAddr => $sl->sockhost(),
PeerPort => $sl->sockport(),
) or die "socket failed: $!";
my $ss = IO::Socket::IP->new(
Proto => "tcp",
PeerAddr => $sl->sockhost(),
PeerPort => $sl->sockport(),
) or die "socket splice failed: $!";
my $packed;
if ($Config{longsize} == 8) {
$packed = pack('ixxxxqql!', $ss->fileno(),-1,0,0);
} else {
my $pad = $Config{ARCH} eq 'i386'? '': 'xxxx';
my $packstr = "i${pad}lllll!${pad}";
$packed = pack($packstr, $ss->fileno(),-1,-1,0,0,0);
}
$s->setsockopt(SOL_SOCKET, SO_SPLICE, $packed)
and die "splice with negative maximum succeeded";
},
);
|