1# test concurrent read and splice
2
3use strict;
4use warnings;
5use POSIX;
6use Time::HiRes;
7
8our %args = (
9    client => {
10	func => sub { errignore(@_); write_stream(@_); },
11	len => 2**20,
12	nocheck => 1,
13    },
14    relay => {
15	# terminate in time on slow machines
16	alarm => 25,
17	down => "Alarm|Shutdown",
18	nonblocking => 1,
19	func => sub {
20	    defined(my $pid = fork())
21		or die "relay func: fork failed: $!";
22	    if ($pid == 0) {
23		alarm(25);
24		my $n;
25		do {
26		    $n = sysread(STDIN, my $buf, 10);
27		} while (!defined($n) || $n);
28		POSIX::_exit(0);
29	    }
30	    # give the userland a moment to read, even if splicing
31	    sleep .1;
32	    relay(@_);
33	    kill 9, $pid;
34	    waitpid($pid, 0);
35	},
36	# As sysread() may extract data from the socket before splicing starts,
37	# the spliced content length is not reliable.  Disable the checks.
38	nocheck => 1,
39    },
40    server => {
41	func => sub { sleep 2; read_stream(@_); },
42	nocheck => 1,
43    },
44    len => 1048576,
45    md5 => '6649bbec13f3d7efaedf01c0cfa54f88',
46);
47