summaryrefslogtreecommitdiff
path: root/regress/usr.sbin/relayd/args-http-slow-consumer.pl
blob: e8e6680b35cada26662040d128f7cc00f6abadcc (plain)
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
42
43
44
45
46
47
48
# test that a slow (in this case sleeping) client causes relayd to slow down
# reading from the server (instead of balooning its buffers)

use strict;
use warnings;
use Errno ':POSIX';

my @errors = (EWOULDBLOCK);
my $errors = "(". join("|", map { $! = $_ } @errors). ")";

my $size = 2**21;

our %args = (
    client => {
	fast => 1,
	max => 100,
	func => sub {
	    my $self = shift;
	    http_request($self , $size, "1.0", "");
	    http_response($self , $size);
	    print STDERR "going to sleep\n";
	    ${$self->{server}}->loggrep(qr/blocked write/, 8)
		or die "no blocked write in server.log";
	    read_char($self, $size);
	    return;
	},
	rcvbuf => 2**12,
	nocheck => 1,
    },
    relayd => {
	protocol => [ "http",
	    "tcp socket buffer 1024",
	    "match request header log",
	    "match request path log",
	],
    },
    server => {
	fast => 1,
	func => \&http_server,
	sndbuf => 2**12,
	sndtimeo => 2,
	loggrep => qr/blocked write .*: $errors/,

    },
    lengths => [$size],
);

1;