vinyltest "#1252 - Drop remote closed connections returning from waitinglists"

# This test case is disabled because it will only pass on platforms
# where the tcp_keepalive_* runtime arguments are available, and also
# because it requires "-t 80" argument to vinyltest (remote closed
# state will only be detected after FIN timeout has passed (60s))

barrier b1 cond 2

server s1 {
	rxreq
	expect req.http.X-Client == "1"
	barrier b1 sync
	delay 75
	close
} -start

server s2 {
	rxreq
	expect req.url == "/should/not/happen"
	txresp
} -start

vinyl v1 -arg "-p debug=+waitinglist" -vcl+backend {
	sub vcl_recv {
		if (req.http.x-client == "2") {
			set req.backend_hint = s2;
		}
	}
} -start

vinyl v1 -cliok "param.show tcp_keepalive_time"
vinyl v1 -cliok "param.set tcp_keepalive_time 1"

vinyl v1 -cliok "param.show tcp_keepalive_probes"
vinyl v1 -cliok "param.set tcp_keepalive_probes 1"

vinyl v1 -cliok "param.show tcp_keepalive_intvl"
vinyl v1 -cliok "param.set tcp_keepalive_intvl 1"

vinyl v1 -cliok "param.show first_byte_timeout"
vinyl v1 -cliok "param.set first_byte_timeout 70"

delay 2

client c1 {
	timeout 70
	txreq -hdr "X-Client: 1"
	rxresp
	expect resp.status == 503
	delay 2
} -start

client c2 {
	barrier b1 sync
	txreq -hdr "X-Client: 2"
	delay 1
} -start

client c1 -wait
client c2 -wait
