1# test delay before server read, unsplice during client write
2
3use strict;
4use warnings;
5use POSIX;
6
7our %args = (
8    client => {
9	len => 2**17,
10	func => sub { errignore(@_); write_stream(@_); },
11    },
12    relay => {
13	func => sub {
14	    my $self = shift;
15	    defined(my $pid = fork())
16		or die "relay func: fork failed: $!";
17	    if ($pid == 0) {
18		sleep 2;
19		setsplice(\*STDIN)
20		    or die ref($self), " unsplice stdin failed: $!";
21		POSIX::_exit(0);
22	    }
23	    sleep 1;
24	    eval { relay($self, @_) };
25	    if ($self->{forward} =~ /splice/) {
26		$@ =~ /^Relay sysread stdin has data:/
27		    or die ref($self), " no data after unsplice: $@";
28	    }
29	    sleep 2;
30	    kill 9, $pid;
31	    (my $kid = waitpid($pid, 0)) > 0
32		or die ref($self), " wait unsplice child failed: $!";
33	    my $status = $?;
34	    my $code;
35	    $code = "exit: ".   WEXITSTATUS($?) if WIFEXITED($?);
36	    $code = "signal: ". WTERMSIG($?)    if WIFSIGNALED($?);
37	    $code = "stop: ".   WSTOPSIG($?)    if WIFSTOPPED($?);
38	    $status == 0
39		or die ref($self), " unsplice child status: $status $code";
40	},
41	rcvbuf => 2**10,
42	sndbuf => 2**10,
43    },
44    server => {
45	func => sub { sleep 3; read_stream(@_); },
46    },
47    noecho => 1,
48    nocheck => 1,
49    len => 131072,
50    md5 => "31e5ad3d0d2aeb1ad8aaa847dfa665c2",
51);
52