varnishtest "things stuck on busy object"

barrier b1 cond 2
barrier b2 cond 2

server s1 {
	rxreq
	barrier b1 sync
	barrier b2 sync
	# There is a race in varnish between the first request releasing
	# the backend connection, and the second request trying to get it
	# which makes reuse of backend connection sometimes work and
	# sometimes not.  Solve by never reusing the backend connection.
	txresp -hdr "Connection: close" -bodylen 2
	accept
	rxreq
	txresp -bodylen 5
} -start


varnish v1 -vcl+backend {
	sub vcl_backend_response {
		set beresp.ttl = 0s;
	}
} -start


client c1 {
	txreq
	rxresp
	expect resp.bodylen == 2
} -start

client c2 {
	barrier b1 sync
	txreq
	barrier b2 sync
	rxresp
	expect resp.bodylen == 5
} -start

client c1 -wait
client c2 -wait
