1# test concurrent write 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 func => sub { 19 defined(my $pid = fork()) 20 or die "relay func: fork failed: $!"; 21 if ($pid == 0) { 22 alarm(25); 23 my $n; 24 do { 25 $n = syswrite(STDOUT, "\n foo bar\n"); 26 sleep .01; 27 } while (!defined($n) || $n); 28 POSIX::_exit(0); 29 } 30 # give the userland a moment to wite, even if splicing 31 sleep .1; 32 relay(@_); 33 kill 9, $pid; 34 waitpid($pid, 0); 35 }, 36 nocheck => 1, 37 }, 38 server => { 39 func => sub { sleep 2; read_stream(@_); }, 40 # As syswrite() adds data to the socket, the content length is not 41 # correct. Disable the checks. 42 nocheck => 1, 43 }, 44 len => 1048576, 45 md5 => '6649bbec13f3d7efaedf01c0cfa54f88', 46); 47