[master] a668bfc Retire varnishtest semaphores and use barriers

Dridi Boukelmoune dridi.boukelmoune at gmail.com
Tue Mar 29 14:20:05 CEST 2016


commit a668bfc6d9ed18dcb1c4698646125fdca12c8f36
Author: Dridi Boukelmoune <dridi.boukelmoune at gmail.com>
Date:   Wed Dec 23 11:52:52 2015 +0100

    Retire varnishtest semaphores and use barriers
    
    All usage of cyclic semaphores has been replaced by non-cylic barriers,
    except in the disabled test r01252 that absolutely needs one. It still
    passes when run with the proper requirements.

diff --git a/bin/varnishtest/Makefile.am b/bin/varnishtest/Makefile.am
index 5732534..9d8c0b5 100644
--- a/bin/varnishtest/Makefile.am
+++ b/bin/varnishtest/Makefile.am
@@ -32,7 +32,6 @@ varnishtest_SOURCES = \
 		vtc_http.c \
 		vtc_main.c \
 		vtc_log.c \
-		vtc_sema.c \
 		vtc_server.c \
 		vtc_varnish.c \
 		vtc_logexp.c \
diff --git a/bin/varnishtest/Makefile.phk b/bin/varnishtest/Makefile.phk
index 5c80efd..b50535d 100644
--- a/bin/varnishtest/Makefile.phk
+++ b/bin/varnishtest/Makefile.phk
@@ -4,7 +4,6 @@ PROG_SRC += vtc_http.c
 PROG_SRC += vtc_log.c
 PROG_SRC += vtc_logexp.c
 PROG_SRC += vtc_main.c
-PROG_SRC += vtc_sema.c
 PROG_SRC += vtc_barrier.c
 PROG_SRC += vtc_server.c
 PROG_SRC += vtc_varnish.c
diff --git a/bin/varnishtest/tests.disabled/r01252.vtc b/bin/varnishtest/tests.disabled/r01252.vtc
index fd820e9..21a2995 100644
--- a/bin/varnishtest/tests.disabled/r01252.vtc
+++ b/bin/varnishtest/tests.disabled/r01252.vtc
@@ -5,10 +5,12 @@ varnishtest "#1252 - Drop remote closed connections returning from waitinglists"
 # because it requires "-t 80" argument to varnishtest (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"
-	sema r1 sync 2
+	barrier b1 sync
 	delay 75
 	close
 } -start
@@ -50,7 +52,7 @@ client c1 {
 } -start
 
 client c2 {
-	sema r1 sync 2
+	barrier b1 sync
 	txreq -hdr "X-Client: 2"
 	delay 1
 } -start
diff --git a/bin/varnishtest/tests.disabled/r01506.vtc b/bin/varnishtest/tests.disabled/r01506.vtc
index f2bb5b2..1d0f0bb 100644
--- a/bin/varnishtest/tests.disabled/r01506.vtc
+++ b/bin/varnishtest/tests.disabled/r01506.vtc
@@ -1,5 +1,7 @@
 varnishtest "range requests on streamed response"
 
+barrier b1 cond 2 -cyclic
+
 server s1 -repeat 4 {
 	rxreq
 	txresp -nolen \
@@ -9,7 +11,7 @@ server s1 -repeat 4 {
 	send "11\r\n1_23456789abcdef\n"
 	send "11\r\n2_23456789abcdef\n"
 	send "11\r\n3_23456789abcdef\n"
-	sema r1 sync 2
+	barrier b1 sync
 	send "11\r\n4_23456789abcdef\n"
 	send "11\r\n5_23456789abcdef\n"
 	send "11\r\n6_23456789abcdef\n"
@@ -32,7 +34,7 @@ client c1 {
 	rxresphdrs
 	expect resp.status == 206
 	expect resp.http.content-length == 85
-	sema r1 sync 2
+	barrier b1 sync
 	rxrespbody
 	expect resp.bodylen == 85
 	delay .1
@@ -42,7 +44,7 @@ client c1 {
 	rxresphdrs
 	expect resp.status == 200
 	expect resp.http.Transfer-Encoding == chunked
-	sema r1 sync 2
+	barrier b1 sync
 	rxrespbody
 	expect resp.bodylen == 136
 	delay .1
@@ -52,7 +54,7 @@ client c1 {
 	rxresphdrs
 	expect resp.status == 200
 	expect resp.http.Transfer-Encoding == chunked
-	sema r1 sync 2
+	barrier b1 sync
 	rxrespbody
 	expect resp.bodylen == 136
 	delay .1
@@ -62,7 +64,7 @@ client c1 {
 	rxresphdrs
 	expect resp.status == 206
 	expect resp.http.content-length == 99
-	sema r1 sync 2
+	barrier b1 sync
 	recv 34
 	delay .3
 	expect_close
diff --git a/bin/varnishtest/tests.disabled/r01732.vtc b/bin/varnishtest/tests.disabled/r01732.vtc
index f738dec..052ae09 100644
--- a/bin/varnishtest/tests.disabled/r01732.vtc
+++ b/bin/varnishtest/tests.disabled/r01732.vtc
@@ -1,17 +1,20 @@
 varnishtest "range related panic"
 
+barrier b1 cond 2
+barrier b2 cond 2
+
 server s1 {
 	rxreq
 	txresp -nolen -hdr "Transfer-Encoding: chunked"
 	chunkedlen 10
 	chunkedlen 10
-	sema r1 sync 2
+	barrier b1 sync
 	chunkedlen 10
 	chunkedlen 10
 	chunkedlen 10
 	chunkedlen 0
 	delay .1
-	sema r2 sync 2
+	barrier b2 sync
 } -start
 
 varnish v1 -vcl+backend {
@@ -25,8 +28,8 @@ client c1 {
 } -run
 
 delay .1
-sema r1 sync 2
-sema r2 sync 2
+barrier b1 sync
+barrier b2 sync
 delay .4
 
 client c1 {
diff --git a/bin/varnishtest/tests.disabled/t00000.vtc b/bin/varnishtest/tests.disabled/t00000.vtc
index 7dd5818..c84100a 100644
--- a/bin/varnishtest/tests.disabled/t00000.vtc
+++ b/bin/varnishtest/tests.disabled/t00000.vtc
@@ -1,16 +1,21 @@
 varnishtest "Ticket #873"
 
+barrier b1 cond 2
+barrier b2 cond 2
+barrier b3 cond 2
+barrier b4 cond 2
+
 server s1 {
 	rxreq
 	txresp -nolen -hdr "Transfer-encoding: chunked"
 	chunked "<1>------------------------<1>\n"
-	sema r1 sync 2
+	barrier b1 sync
 	chunked "<2>------------------------<2>\n"
-	sema r2 sync 2
+	barrier b2 sync
 	chunked "<3>------------------------<3>\n"
-	sema r1 sync 2
+	barrier b3 sync
 	chunked "<4>------------------------<4>\n"
-	sema r2 sync 2
+	barrier b4 sync
 	chunkedlen 0
 } -start
 
@@ -28,19 +33,19 @@ client c1 {
 
 	rxchunk
 	expect resp.chunklen == 31
-	sema r1 sync 2
+	barrier b1 sync
 
 	rxchunk
 	expect resp.chunklen == 31
-	sema r2 sync 2
+	barrier b2 sync
 
 	rxchunk
 	expect resp.chunklen == 31
-	sema r1 sync 2
+	barrier b3 sync
 
 	rxchunk
 	expect resp.chunklen == 31
-	sema r2 sync 2
+	barrier b4 sync
 
 	rxchunk
 	expect resp.chunklen == 0
diff --git a/bin/varnishtest/tests/c00013.vtc b/bin/varnishtest/tests/c00013.vtc
index 70eedad..b833296 100644
--- a/bin/varnishtest/tests/c00013.vtc
+++ b/bin/varnishtest/tests/c00013.vtc
@@ -1,15 +1,18 @@
 varnishtest "Test parking second request on backend delay"
 
+barrier b1 cond 2
+barrier b2 cond 2
+
 server s1 {
 	rxreq
 	expect req.url == "/foo"
 	send "HTTP/1.0 200 OK\r\nConnection: close\r\n\r\n"
 	delay .2
-	sema r1 sync 2
+	barrier b1 sync
 	delay .2
 	send "line1\n"
 	delay .2
-	sema r1 sync 2
+	barrier b2 sync
 	send "line2\n"
 } -start
 
@@ -29,12 +32,12 @@ client c1 {
 	expect resp.http.x-varnish == "1001"
 } -start
 
-sema r1 sync 2
+barrier b1 sync
 
 client c2 {
 	txreq -url "/foo" -hdr "client: c2"
 	delay .2
-	sema r1 sync 2
+	barrier b2 sync
 	rxresp
 	expect resp.status == 200
 	expect resp.bodylen == 12
diff --git a/bin/varnishtest/tests/c00014.vtc b/bin/varnishtest/tests/c00014.vtc
index ec8c9d8..41eb00b 100644
--- a/bin/varnishtest/tests/c00014.vtc
+++ b/bin/varnishtest/tests/c00014.vtc
@@ -1,9 +1,11 @@
 varnishtest "Test parking second request on backend delay, then pass"
 
+barrier b1 cond 2
+
 server s1 {
 	rxreq
 	expect req.url == "/foo"
-	sema r1 sync 2
+	barrier b1 sync
 	send "HTTP/1.1 200 OK\r\nContent-Length: 12\r\n\r\n"
 	send "line1\n"
 	send "line2\n"
@@ -28,7 +30,7 @@ client c1 {
 	expect resp.http.x-varnish == "1001"
 } -start
 
-sema r1 sync 2
+barrier b1 sync
 delay .2
 
 client c2 {
diff --git a/bin/varnishtest/tests/c00017.vtc b/bin/varnishtest/tests/c00017.vtc
index 9342c53..b062980 100644
--- a/bin/varnishtest/tests/c00017.vtc
+++ b/bin/varnishtest/tests/c00017.vtc
@@ -1,5 +1,7 @@
 varnishtest "Test Backend Polling"
 
+barrier b1 cond 2
+
 server s1 {
 	# Probes
 	loop 8 {
@@ -22,7 +24,7 @@ server s1 {
 		accept
 	}
 
-	sema r1 sync 2
+	barrier b1 sync
 } -start
 
 varnish v1 -vcl {
@@ -38,6 +40,6 @@ varnish v1 -vcl {
 
 } -start
 
-sema r1 sync 2
+barrier b1 sync
 
 varnish v1 -cli "backend.list -p"
diff --git a/bin/varnishtest/tests/c00038.vtc b/bin/varnishtest/tests/c00038.vtc
index e9402b6..1e81f26 100644
--- a/bin/varnishtest/tests/c00038.vtc
+++ b/bin/varnishtest/tests/c00038.vtc
@@ -1,8 +1,10 @@
 varnishtest "Test req.hash_ignore_busy in vcl_recv"
 
+barrier b1 cond 2
+
 server s1 {
 	rxreq
-	sema r1 sync 2
+	barrier b1 sync
 	delay 1
 	txresp -hdr "Server: 1"
 } -start
@@ -36,7 +38,7 @@ client c1 {
 } -start
 
 client c2 {
-    sema r1 sync 2
+	barrier b1 sync
 	txreq -url "/" -hdr "x-client: 2" -hdr "x-ignorebusy: 1"
 	txreq -url "/" -hdr "x-client: 2"
 	rxresp
diff --git a/bin/varnishtest/tests/c00043.vtc b/bin/varnishtest/tests/c00043.vtc
index 0960621..15d87c7 100644
--- a/bin/varnishtest/tests/c00043.vtc
+++ b/bin/varnishtest/tests/c00043.vtc
@@ -1,12 +1,14 @@
 varnishtest "predictive vary"
 
+barrier b1 cond 2
+barrier b2 cond 2
 
 server s1 {
 	rxreq
 	txresp -hdr "Vary: foo" -bodylen 1
 	rxreq
-	sema r2 sync 2
-	sema r1 sync 2
+	barrier b2 sync
+	barrier b1 sync
 	txresp -hdr "Vary: foo" -bodylen 2
 } -start
 
@@ -33,10 +35,10 @@ client c1 {
 } -start
 
 client c2 {
-	sema r2 sync 2
+	barrier b2 sync
 	txreq -hdr "Foo: vary3" -hdr "bar: yes"
 	rxresp
-	sema r1 sync 2
+	barrier b1 sync
 	expect resp.bodylen == 3
 } -start
 
diff --git a/bin/varnishtest/tests/c00058.vtc b/bin/varnishtest/tests/c00058.vtc
index b898034..6a2d733 100644
--- a/bin/varnishtest/tests/c00058.vtc
+++ b/bin/varnishtest/tests/c00058.vtc
@@ -1,11 +1,13 @@
 varnishtest "Test v4 grace"
 
+barrier b1 cond 2
+
 server s1 {
 	rxreq
 	txresp -hdr "Last-Modified: Mon, 09 Feb 2015 09:32:47 GMT" -bodylen 3
 	rxreq
 	txresp -bodylen 6
-	sema r2 sync 2
+	barrier b1 sync
 } -start
 
 varnish v1 -vcl+backend {
@@ -33,7 +35,7 @@ client c1 {
 	expect resp.bodylen == 3
 
 	# But bg fetch was kicked off
-	sema r2 sync 2
+	barrier b1 sync
 	delay .2
 
 	# And now we get the new object
diff --git a/bin/varnishtest/tests/c00062.vtc b/bin/varnishtest/tests/c00062.vtc
index 643a2f6..54e0318 100644
--- a/bin/varnishtest/tests/c00062.vtc
+++ b/bin/varnishtest/tests/c00062.vtc
@@ -1,12 +1,15 @@
 varnishtest "Check that aborted backend body aborts client in streaming mode"
 
+barrier b1 cond 2
+barrier b2 cond 2
+
 server s1 {
 	rxreq
 	txresp -nolen -hdr "Transfer-encoding: chunked"
 	chunked {<HTML>}
-	sema r1 sync 2
+	barrier b1 sync
 	chunked {<HTML>}
-	sema r1 sync 2
+	barrier b2 sync
 } -start
 
 varnish v1 -cliok "param.set debug +syncvsl" -vcl+backend {
@@ -19,9 +22,9 @@ client c1 {
 	rxresphdrs
 	expect resp.status == 200
 	rxchunk
-	sema r1 sync 2
+	barrier b1 sync
 	rxchunk
-	sema r1 sync 2
+	barrier b2 sync
 	expect_close
 } -run
 
diff --git a/bin/varnishtest/tests/d00009.vtc b/bin/varnishtest/tests/d00009.vtc
index 6b20030..fd30602 100644
--- a/bin/varnishtest/tests/d00009.vtc
+++ b/bin/varnishtest/tests/d00009.vtc
@@ -1,17 +1,20 @@
 varnishtest "Test dynamic backends hot swap while being used"
 
+barrier b1 cond 2
+barrier b2 cond 2
+
 server s1 {
 	rxreq
 	expect req.url == "/foo"
-	sema r1 sync 2
-	sema r2 sync 2
+	barrier b1 sync
+	barrier b2 sync
 	txresp
 } -start
 
 server s2 {
 	rxreq
 	expect req.url == "/bar"
-	sema r2 sync 2
+	barrier b2 sync
 	txresp
 } -start
 
@@ -42,7 +45,7 @@ client c1 {
 } -start
 
 client c2 {
-	sema r1 sync 2
+	barrier b1 sync
 	txreq -req "SWAP" -hdr "X-Addr: ${s2_addr}" -hdr "X-Port: ${s2_port}"
 	rxresp
 	expect resp.status == 200
diff --git a/bin/varnishtest/tests/d00010.vtc b/bin/varnishtest/tests/d00010.vtc
index e67fd54..4646ec2 100644
--- a/bin/varnishtest/tests/d00010.vtc
+++ b/bin/varnishtest/tests/d00010.vtc
@@ -1,17 +1,20 @@
 varnishtest "Test dynamic backends hot swap during a pipe"
 
+barrier b1 cond 2
+barrier b2 cond 2
+
 server s1 {
 	rxreq
 	expect req.url == "/foo"
-	sema r1 sync 2
-	sema r2 sync 2
+	barrier b1 sync
+	barrier b2 sync
 	txresp
 } -start
 
 server s2 {
 	rxreq
 	expect req.url == "/bar"
-	sema r2 sync 2
+	barrier b2 sync
 	txresp
 } -start
 
@@ -43,7 +46,7 @@ client c1 {
 } -start
 
 client c2 {
-	sema r1 sync 2
+	barrier b1 sync
 	txreq -req "SWAP" -hdr "X-Addr: ${s2_addr}" -hdr "X-Port: ${s2_port}"
 	rxresp
 	expect resp.status == 200
diff --git a/bin/varnishtest/tests/d00011.vtc b/bin/varnishtest/tests/d00011.vtc
index ab1c8e0..f2fb3a4 100644
--- a/bin/varnishtest/tests/d00011.vtc
+++ b/bin/varnishtest/tests/d00011.vtc
@@ -1,5 +1,7 @@
 varnishtest "Test a dynamic backend hot swap after it was picked by a bereq"
 
+barrier b1 cond 2
+
 server s1 {
 } -start
 
@@ -41,13 +43,13 @@ varnish v1 -expect MAIN.n_backend == 2
 
 client c1 {
 	txreq
-	sema r2 sync 2
+	barrier b1 sync
 	rxresp
 	expect resp.status == 200
 }
 
 client c2 {
-	sema r2 sync 2
+	barrier b1 sync
 	delay 0.1
 	txreq -req "SWAP" -hdr "X-Addr: ${s2_addr}" -hdr "X-Port: ${s2_port}"
 	rxresp
diff --git a/bin/varnishtest/tests/d00012.vtc b/bin/varnishtest/tests/d00012.vtc
index aba0aec..96d4f65 100644
--- a/bin/varnishtest/tests/d00012.vtc
+++ b/bin/varnishtest/tests/d00012.vtc
@@ -2,10 +2,12 @@ varnishtest "Test a dynamic backend discard during a request"
 
 # vcl.discard testing inspired by v00006.vtc from commit e1f7207
 
+barrier b1 cond 2
+
 server s1 {
 	rxreq
 	expect req.url == "/foo"
-	sema r1 sync 2
+	barrier b1 sync
 	txresp
 } -start
 
@@ -53,7 +55,7 @@ varnish v1 -vcl {
 }
 
 varnish v1 -cli "vcl.discard vcl1"
-sema r1 sync 2
+barrier b1 sync
 
 client c1 -wait
 delay 2
diff --git a/bin/varnishtest/tests/d00013.vtc b/bin/varnishtest/tests/d00013.vtc
index 4a397ee..12457bf 100644
--- a/bin/varnishtest/tests/d00013.vtc
+++ b/bin/varnishtest/tests/d00013.vtc
@@ -1,5 +1,7 @@
 varnishtest "Test a dynamic backend hot swap after it was hinted to a req"
 
+barrier b1 cond 2
+
 server s1 {
 } -start
 
@@ -38,13 +40,13 @@ varnish v1 -expect MAIN.n_backend == 2
 
 client c1 {
 	txreq
-	sema r2 sync 2
+	barrier b1 sync
 	rxresp
 	expect resp.status == 200
 }
 
 client c2 {
-	sema r2 sync 2
+	barrier b1 sync
 	delay 0.1
 	txreq -req "SWAP" -hdr "X-Addr: ${s2_addr}" -hdr "X-Port: ${s2_port}"
 	rxresp
diff --git a/bin/varnishtest/tests/p00007.vtc b/bin/varnishtest/tests/p00007.vtc
index 1daf4e5..a7c232a 100644
--- a/bin/varnishtest/tests/p00007.vtc
+++ b/bin/varnishtest/tests/p00007.vtc
@@ -1,5 +1,8 @@
 varnishtest "test reload of object spanning incomplete segment"
 
+barrier b1 cond 2
+barrier b2 cond 2
+
 server s1 {
 	rxreq
 	expect req.url == "/1"
@@ -8,9 +11,9 @@ server s1 {
 	send "\n"
 	chunkedlen 32
 	# Tell top-level that it can sync the stevedore
-	sema r1 sync 2
+	barrier b1 sync
 	# Top-level tells us it has synched the stevedore
-	sema r1 sync 2
+	barrier b2 sync
 	chunkedlen 32
 	chunkedlen 0
 	accept
@@ -36,14 +39,14 @@ client c1 {
 } -start
 
 # Wait for first chunk to have been sent
-sema r1 sync 2
+barrier b1 sync
 delay .2
 
 # Sync the stevedore, so the next chunk ends up i segment 2
 varnish v1 -cliok "debug.persistent s0 sync"
 
 # Tell server to continue
-sema r1 sync 2
+barrier b2 sync
 
 # Get the result
 client c1 -wait
diff --git a/bin/varnishtest/tests/r00345.vtc b/bin/varnishtest/tests/r00345.vtc
index 8ce2d53..9041acd 100644
--- a/bin/varnishtest/tests/r00345.vtc
+++ b/bin/varnishtest/tests/r00345.vtc
@@ -1,10 +1,12 @@
 varnishtest "#345, ESI waitinglist trouble"
 
+barrier b1 cond 2
+
 server s1 {
 	rxreq
 	txresp -body {<esi:include src="someurl">}
 	rxreq
-	sema r1 sync 2
+	barrier b1 sync
 	delay 1
 	txresp -body {DATA}
 } -start
@@ -25,7 +27,7 @@ client c1 {
 
 client c2 {
 	txreq
-	sema r1 sync 2
+	barrier b1 sync
 	rxresp
 	expect resp.bodylen == 4
 } -run
diff --git a/bin/varnishtest/tests/r00427.vtc b/bin/varnishtest/tests/r00427.vtc
index ebeb2ba..c097494 100644
--- a/bin/varnishtest/tests/r00427.vtc
+++ b/bin/varnishtest/tests/r00427.vtc
@@ -1,5 +1,8 @@
 varnishtest "client close in ESI delivery"
 
+barrier b1 cond 2
+barrier b2 cond 2
+
 server s1 {
 	rxreq
 	txresp -body {
@@ -10,8 +13,8 @@ server s1 {
 
 	rxreq
 	expect req.url == "/foo"
-	sema r1 sync 2
-	sema r1 sync 2
+	barrier b1 sync
+	barrier b2 sync
 	txresp -body "[foo]"
 
 	rxreq
@@ -31,11 +34,11 @@ varnish v1 -vcl+backend {
 
 client c1 {
 	txreq
-	sema r1 sync 2
+	barrier b1 sync
 } -run
 
 client c1 {
-	sema r1 sync 2
+	barrier b2 sync
 	txreq
 	rxresp
 } -run
diff --git a/bin/varnishtest/tests/r00667.vtc b/bin/varnishtest/tests/r00667.vtc
index 1c1da1f..2782e63 100644
--- a/bin/varnishtest/tests/r00667.vtc
+++ b/bin/varnishtest/tests/r00667.vtc
@@ -1,9 +1,12 @@
 varnishtest "things stuck on busy object"
 
+barrier b1 cond 2
+barrier b2 cond 2
+
 server s1 {
 	rxreq
-	sema r1 sync 2
-	sema r1 sync 2
+	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
@@ -29,9 +32,9 @@ client c1 {
 } -start
 
 client c2 {
-	sema r1 sync 2
+	barrier b1 sync
 	txreq
-	sema r1 sync 2
+	barrier b2 sync
 	rxresp
 	expect resp.bodylen == 5
 } -start
diff --git a/bin/varnishtest/tests/r00963.vtc b/bin/varnishtest/tests/r00963.vtc
index 6e8fc1d..f4599f5 100644
--- a/bin/varnishtest/tests/r00963.vtc
+++ b/bin/varnishtest/tests/r00963.vtc
@@ -1,8 +1,10 @@
 varnishtest "Test hsh_rush"
 
+barrier b1 cond 5
+
 server s1 {
 	rxreq
-	sema r1 sync 5
+	barrier b1 sync
 	txresp -bodylen 10
 } -start
 
@@ -13,28 +15,28 @@ varnish v1 -cliok "param.set rush_exponent 2"
 
 client c1 {
 	txreq
-	sema r1 sync 5
+	barrier b1 sync
 	rxresp
 	expect resp.bodylen == 10
 } -start
 
 client c2 {
 	txreq
-	sema r1 sync 5
+	barrier b1 sync
 	rxresp
 	expect resp.bodylen == 10
 } -start
 
 client c3 {
 	txreq
-	sema r1 sync 5
+	barrier b1 sync
 	rxresp
 	expect resp.bodylen == 10
 } -start
 
 client c4 {
 	txreq
-	sema r1 sync 5
+	barrier b1 sync
 	rxresp
 	expect resp.bodylen == 10
 } -start
diff --git a/bin/varnishtest/tests/r01073.vtc b/bin/varnishtest/tests/r01073.vtc
index 3e0c44e..c75563f 100644
--- a/bin/varnishtest/tests/r01073.vtc
+++ b/bin/varnishtest/tests/r01073.vtc
@@ -1,16 +1,19 @@
 varnishtest "Test that hash_always_miss also implies hash_ignore_busy. Ticket #1073."
 
+barrier b1 cond 2
+barrier b2 cond 2
+
 server s1 {
 	rxreq
-	sema r1 sync 2
-	sema r2 sync 2
+	barrier b1 sync
+	barrier b2 sync
 	delay 1
 	txresp -hdr "Server: 1"
 } -start
 
 server s2 {
 	rxreq
-	sema r2 sync 2
+	barrier b2 sync
 	txresp -hdr "Server: 2"
 } -start
 
@@ -38,7 +41,7 @@ client c1 {
 } -start
 
 client c2 {
-    sema r1 sync 2
+	barrier b1 sync
 	txreq -url "/" -hdr "x-client: 2" -hdr "x-hash-always-miss: 1"
 	txreq -url "/" -hdr "x-client: 2"
 	rxresp
diff --git a/bin/varnishtest/tests/r01391.vtc b/bin/varnishtest/tests/r01391.vtc
index 9669e16..6683dde 100644
--- a/bin/varnishtest/tests/r01391.vtc
+++ b/bin/varnishtest/tests/r01391.vtc
@@ -1,12 +1,13 @@
 varnishtest "client abandoning hit-for-pass"
 
+barrier b1 cond 2
 
 server s1 {
 	non-fatal
 	rxreq
 	txresp -nolen -hdr "Transfer-Encoding: chunked" -hdr "Set-Cookie: foo=bar"
 	chunked "foo"
-	sema r1 sync 2
+	barrier b1 sync
 	chunked "bar"
 	delay .1
 	chunkedlen 64
@@ -21,7 +22,7 @@ client c1 {
 	txreq
 	rxresphdrs
 	rxchunk
-	sema r1 sync 2
+	barrier b1 sync
 } -run
 
 delay 2
diff --git a/bin/varnishtest/tests/r01399.vtc b/bin/varnishtest/tests/r01399.vtc
index 5d7171a..c7adffa 100644
--- a/bin/varnishtest/tests/r01399.vtc
+++ b/bin/varnishtest/tests/r01399.vtc
@@ -1,10 +1,12 @@
 varnishtest "1399 race issue with bg-fetches"
 
+barrier b1 cond 2
+
 server s1 {
 	rxreq
 	txresp -bodylen 1
 
-	sema r1 sync 2
+	barrier b1 sync
 
 	# Delay here, to stall the bgfetch for a while, to give the req time to finish
 	# delivery and cleanup up struct req
@@ -43,7 +45,7 @@ client c1 {
 	txreq
 	rxresp
 	expect resp.http.content-length == 1
-	sema r1 sync 2
+	barrier b1 sync
 } -run
 
 # Wait for the server to not explode
diff --git a/bin/varnishtest/tests/r01419.vtc b/bin/varnishtest/tests/r01419.vtc
index a47d424..84130b9 100644
--- a/bin/varnishtest/tests/r01419.vtc
+++ b/bin/varnishtest/tests/r01419.vtc
@@ -1,14 +1,17 @@
 varnishtest "Make sure banlurker skips busy objects"
 
+barrier b1 cond 2
+barrier b2 cond 2
+
 server s1 {
 	rxreq
 	send "HTTP/1.0 200 OK\r\n"
-	sema r1 sync 2
+	barrier b1 sync
 	send "Foobar: blaf\r\n"
 	send "Content-Length: 10\r\n"
 	send "\r\n\r\n"
 	send "abcde"
-	sema r2 sync 2
+	barrier b2 sync
 	send "abcdefghij"
 } -start
 
@@ -29,7 +32,7 @@ client c1 {
 	expect resp.http.foobar == blaf
 } -start
 
-sema r1 sync 2
+barrier b1 sync
 varnish v1 -cliok {ban.list}
 
 varnish v1 -cliok {ban obj.http.goo == bar}
@@ -38,6 +41,6 @@ delay 2
 varnish v1 -cliok {ban.list}
 
 
-sema r2 sync 2
+barrier b2 sync
 
 client c1 -wait
diff --git a/bin/varnishtest/tests/r01468.vtc b/bin/varnishtest/tests/r01468.vtc
index 119c1da..10b97cf 100644
--- a/bin/varnishtest/tests/r01468.vtc
+++ b/bin/varnishtest/tests/r01468.vtc
@@ -1,11 +1,14 @@
 varnishtest "#1468 - freeing failed obj"
 
+barrier b1 cond 2
+barrier b2 cond 2
+
 server s1 {
 	rxreq
 	expect req.url == "/1"
 	txresp -nolen -hdr "Transfer-Encoding: chunked"
 	chunked {<HTML>}
-	sema r1 sync 2
+	barrier b1 sync
 	close
 
 	accept
@@ -13,7 +16,7 @@ server s1 {
 	expect req.url == "/2"
 	txresp -nolen -hdr "Transfer-Encoding: chunked"
 	chunked {<HTML>}
-	sema r1 sync 2
+	barrier b2 sync
 } -start
 
 varnish v1 -vcl+backend {
@@ -33,7 +36,7 @@ client c1 {
 	rxresphdrs
 	expect resp.status == 200
 	rxchunk
-	sema r1 sync 2
+	barrier b1 sync
 	expect_close
 } -run
 
@@ -43,7 +46,7 @@ client c1 {
 	rxresphdrs
 	expect resp.status == 200
 	rxchunk
-	sema r1 sync 2
+	barrier b2 sync
 	expect_close
 } -run
 
diff --git a/bin/varnishtest/tests/r01478.vtc b/bin/varnishtest/tests/r01478.vtc
index 1df49a6..a6844c4 100644
--- a/bin/varnishtest/tests/r01478.vtc
+++ b/bin/varnishtest/tests/r01478.vtc
@@ -1,23 +1,28 @@
 varnishtest "panic due to hash_ignore_busy"
 
+barrier b1 cond 2
+barrier b2 cond 2
+barrier b3 cond 2
+barrier b4 cond 2
+
 server s1 {
 	rxreq
 	txresp -nolen -hdr "Transfer-Encoding: chunked"
 	chunkedlen 10
 	delay .5
-	sema r1 sync 2
+	barrier b1 sync
 	delay .5
 	chunkedlen 10
 	delay .5
-	sema r2 sync 2
+	barrier b2 sync
 	delay .5
 	chunkedlen 10
 	delay .5
-	sema r3 sync 2
+	barrier b3 sync
 	delay .5
 	chunkedlen 10
 	delay .5
-	sema r4 sync 2
+	barrier b4 sync
 	delay .5
 	chunkedlen 10
 	delay .5
@@ -41,17 +46,17 @@ client c1 {
 	rxresp
 } -start
 
-sema r1 sync 2
+barrier b1 sync
 client c2 {
 	txreq -hdr "client: c2"
-	sema r2 sync 2
+	barrier b2 sync
 	rxresp
 } -start
 
-sema r3 sync 2
+barrier b3 sync
 client c3 {
 	txreq -hdr "client: c3"
-	sema r4 sync 2
+	barrier b4 sync
 	rxresp
 } -start
 
diff --git a/bin/varnishtest/tests/r01646.vtc b/bin/varnishtest/tests/r01646.vtc
index 951350e..10b640e 100644
--- a/bin/varnishtest/tests/r01646.vtc
+++ b/bin/varnishtest/tests/r01646.vtc
@@ -1,12 +1,15 @@
 varnishtest "cond/stream race ?"
 
+barrier b1 cond 3
+barrier b2 cond 2
+
 server s1 {
 	rxreq
 	txresp -nolen -hdr "Transfer-Encoding: chunked" -hdr "Etag: foo"
 	chunkedlen 32
-	sema r1 sync 3
+	barrier b1 sync
 	chunkedlen 32
-	sema r2 sync 2
+	barrier b2 sync
 	chunkedlen 32
 	chunkedlen 0
 } -start
@@ -35,17 +38,17 @@ varnish v1 -cliok "param.set debug +syncvsl"
 client c1 {
 	txreq
 	rxresphdrs
-	sema r1 sync 3
+	barrier b1 sync
 	rxrespbody
 	expect resp.bodylen == 96
 } -start
 
 client c2 {
-	sema r1 sync 3
+	barrier b1 sync
 	delay 2
 	txreq -hdr "foo: s2"
 	rxresphdrs
-	sema r2 sync 2
+	barrier b2 sync
 	rxrespbody
 	expect resp.bodylen == 96
 } -start
diff --git a/bin/varnishtest/tests/r01648.vtc b/bin/varnishtest/tests/r01648.vtc
index de0c364..1a8cef9 100644
--- a/bin/varnishtest/tests/r01648.vtc
+++ b/bin/varnishtest/tests/r01648.vtc
@@ -1,10 +1,12 @@
 varnishtest "#1648 - corrupt object in cache through IMS update"
 
+barrier b1 cond 3
+
 # This server sends a broken response body
 server s1 {
 	rxreq
 	txresp -nolen -hdr "Transfer-Encoding: chunked" -hdr "Etag: \"foo\"" -hdr "Server: s1"
-	sema r1 sync 3
+	barrier b1 sync
 	delay 1
 	chunked "abc"
 } -start
@@ -13,7 +15,7 @@ server s1 {
 server s2 {
 	rxreq
 	expect req.http.If-None-Match == "\"foo\""
-	sema r1 sync 3
+	barrier b1 sync
 	txresp -status 304 -nolen -hdr "Server: s2"
 } -start
 
@@ -58,7 +60,7 @@ delay 1
 # IMS update by s2
 client c2 {
 	txreq -hdr "Client: c2"
-	sema r1 sync 3
+	barrier b1 sync
 	rxresphdrs
 	expect resp.status == 200
 	expect resp.http.transfer-encoding == "chunked"
diff --git a/bin/varnishtest/tests/r01737.vtc b/bin/varnishtest/tests/r01737.vtc
index 66c5aee..182d1f0 100644
--- a/bin/varnishtest/tests/r01737.vtc
+++ b/bin/varnishtest/tests/r01737.vtc
@@ -1,5 +1,7 @@
 varnishtest "#1737 - ESI sublevel session close"
 
+barrier b1 cond 2
+
 # Build a esi request tree that fails on flush before include at two different
 # levels. Synchronize a client close after the response headers have been
 # received by the client. This produces write erros for the body parts in all
@@ -7,7 +9,7 @@ varnishtest "#1737 - ESI sublevel session close"
 server s1 {
 	rxreq
 	txresp -body {<esi:include src="/bar"/><esi:include src="/bar"/>}
-	sema r1 sync 2
+	barrier b1 sync
 
 	rxreq
 	delay 1
@@ -31,7 +33,7 @@ varnish v1 -vcl+backend {
 client c1 {
 	txreq
 	rxresp -no_obj
-	sema r1 sync 2
+	barrier b1 sync
 } -run
 
 delay 3
diff --git a/bin/varnishtest/tests/r01818.vtc b/bin/varnishtest/tests/r01818.vtc
index ee887a8..2fe8ae3 100644
--- a/bin/varnishtest/tests/r01818.vtc
+++ b/bin/varnishtest/tests/r01818.vtc
@@ -1,5 +1,8 @@
 varnishtest "#1818: verify that grace works for hit_for_pass objects"
 
+barrier b1 cond 2
+barrier b2 cond 2
+
 server s1 {
 	rxreq
 	expect req.http.a == "1"
@@ -7,15 +10,15 @@ server s1 {
 
 	rxreq
 	expect req.http.b == "1"
-	sema r2 sync 2
-	sema r1 sync 2
+	barrier b2 sync
+	barrier b1 sync
 	txresp
 } -start
 
 server s2 {
 	rxreq
 	expect req.http.c == "1"
-	sema r1 sync 2
+	barrier b1 sync
 	txresp
 } -start
 
@@ -68,7 +71,7 @@ client c1 {
 } -start
 
 client c2 {
-	sema r2 sync 2
+	barrier b2 sync
 	txreq -hdr "c: 1"
 	rxresp
 	expect resp.http.pass == "1"
diff --git a/bin/varnishtest/tests/s00001.vtc b/bin/varnishtest/tests/s00001.vtc
index 0223916..77fe6fe 100644
--- a/bin/varnishtest/tests/s00001.vtc
+++ b/bin/varnishtest/tests/s00001.vtc
@@ -1,10 +1,12 @@
 varnishtest "Simple expiry test (fully reaped object)"
 
+barrier b1 cond 2
+
 server s1 {
 	rxreq
 	expect req.url == "/"
 	txresp -hdr "Cache-control: max-age = 1" -body "1111\n"
-	sema r1 sync 2
+	barrier b1 sync
 	rxreq
 	expect req.url == "/"
 	txresp -hdr "Cache-control: max-age = 1" -body "22222\n"
@@ -23,7 +25,7 @@ client c1 {
 	expect resp.status == 200
 } -run
 
-sema r1 sync 2
+barrier b1 sync
 delay 1.1
 
 client c2 {
diff --git a/bin/varnishtest/tests/s00002.vtc b/bin/varnishtest/tests/s00002.vtc
index 10049c0..3d8442e 100644
--- a/bin/varnishtest/tests/s00002.vtc
+++ b/bin/varnishtest/tests/s00002.vtc
@@ -1,5 +1,8 @@
 varnishtest "Check grace with sick backends"
 
+barrier b1 cond 2
+barrier b2 cond 2
+
 server s1 {
 	rxreq
 	expect req.url == "/"
@@ -11,7 +14,7 @@ server s1 {
 	expect req.url == "/"
 	txresp -proto HTTP/1.0 -hdr "nbr: 2" -body "hi"
 
-	sema r1 sync 2
+	barrier b1 sync
 	accept
 
 	rxreq
@@ -30,7 +33,7 @@ server s1 {
 	txresp -proto HTTP/1.0 -status 400 -hdr "nbr: 5" -body "hi"
 	accept
 
-	sema r1 sync 2
+	barrier b2 sync
 
 } -start
 
@@ -53,7 +56,7 @@ varnish v1 -vcl {
 	}
 } -start
 
-sema r1 sync 2
+barrier b1 sync
 
 client c1 {
 	txreq -url "/"
@@ -62,7 +65,7 @@ client c1 {
 	expect resp.status == 200
 } -run
 
-sema r1 sync 2
+barrier b2 sync
 
 client c2 {
 	txreq -url "/"
diff --git a/bin/varnishtest/tests/v00010.vtc b/bin/varnishtest/tests/v00010.vtc
index 7dd839c..43fb083 100644
--- a/bin/varnishtest/tests/v00010.vtc
+++ b/bin/varnishtest/tests/v00010.vtc
@@ -1,5 +1,8 @@
 varnishtest "VCL: check panic and restart"
 
+barrier b1 cond 2
+barrier b2 cond 2
+
 server s1 {
 	rxreq
 	txresp -hdr "Foo: bar" -body "abcdef\n"
@@ -7,7 +10,7 @@ server s1 {
 	txresp -hdr "Panic: fetch" -body "012345\n"
 	close
 
-	sema r1 sync 2
+	barrier b1 sync
 	accept
 	rxreq
 	txresp -hdr "Foo: bar" -body "abcdef\n"
@@ -15,7 +18,7 @@ server s1 {
 	txresp -hdr "Panic: deliver" -body "012345\n"
 	close
 
-	sema r1 sync 2
+	barrier b2 sync
 	accept
 	rxreq
 	txresp -hdr "Foo: foo" -body "abcdef\n"
@@ -53,7 +56,7 @@ varnish v1 -expect MGT.child_panic == 1
 varnish v1 -clierr 300 "panic.clear"
 varnish v1 -cliok "start"
 varnish v1 -wait-running
-sema r1 sync 2
+barrier b1 sync
 
 delay 0.5
 
@@ -71,7 +74,7 @@ varnish v1 -expect MGT.child_panic == 0
 varnish v1 -clierr 300 "panic.clear"
 varnish v1 -cliok "start"
 varnish v1 -wait-running
-sema r1 sync 2
+barrier b2 sync
 
 delay 0.5
 
diff --git a/bin/varnishtest/tests/v00012.vtc b/bin/varnishtest/tests/v00012.vtc
index e7c8d44..f68e26a 100644
--- a/bin/varnishtest/tests/v00012.vtc
+++ b/bin/varnishtest/tests/v00012.vtc
@@ -1,9 +1,12 @@
 varnishtest "Check backend connection limit"
 
+barrier b1 cond 2
+barrier b2 cond 2
+
 server s1 {
 	rxreq
-	sema r1 sync 2
-	sema r2 sync 2
+	barrier b1 sync
+	barrier b2 sync
 	txresp
 } -start
 
@@ -27,13 +30,13 @@ client c1 {
 
 
 client c2 {
-	sema r1 sync 2
+	barrier b1 sync
 	txreq
 	rxresp
 	expect resp.status == 503
 } -run
 
-sema r2 sync 2
+barrier b2 sync
 client c1 -wait
 
 varnish v1 -expect backend_busy == 1
diff --git a/bin/varnishtest/tests/v00014.vtc b/bin/varnishtest/tests/v00014.vtc
index 78b0288..01c8251 100644
--- a/bin/varnishtest/tests/v00014.vtc
+++ b/bin/varnishtest/tests/v00014.vtc
@@ -1,18 +1,23 @@
 varnishtest "Check req.backend.healthy"
 
+barrier b1 cond 2
+barrier b2 cond 2
+barrier b3 cond 2
+barrier b4 cond 2
+
 server s1 {
 	rxreq
-	sema r1 sync 2
+	barrier b1 sync
 	expect req.url == "/"
 	txresp -body "slash"
 	accept
 	rxreq
-	sema r2 sync 2
-	sema r3 sync 2
+	barrier b2 sync
+	barrier b3 sync
 	expect req.url == "/"
 	txresp -body "slash"
 	accept
-	sema r4 sync 2
+	barrier b4 sync
 } -start
 
 varnish v1 -vcl {
@@ -51,15 +56,15 @@ client c1 {
 	rxresp
 	expect resp.status == 500
 
-	sema r1 sync 2
+	barrier b1 sync
 
-	sema r2 sync 2
+	barrier b2 sync
 	txreq
 	rxresp
 	expect resp.status == 500
 
-	sema r3 sync 2
-	sema r4 sync 2
+	barrier b3 sync
+	barrier b4 sync
 	txreq
 	rxresp
 	expect resp.status == 200
diff --git a/bin/varnishtest/vtc.c b/bin/varnishtest/vtc.c
index fc42c72..d862554 100644
--- a/bin/varnishtest/vtc.c
+++ b/bin/varnishtest/vtc.c
@@ -618,7 +618,6 @@ static const struct cmds cmds[] = {
 	{ "varnishtest",cmd_varnishtest },
 	{ "shell",	cmd_shell },
 	{ "err_shell",	cmd_err_shell },
-	{ "sema",	cmd_sema },
 	{ "barrier",	cmd_barrier },
 	{ "random",	cmd_random },
 	{ "feature",	cmd_feature },
@@ -641,7 +640,6 @@ exec_file(const char *fn, const char *script, const char *tmpdir,
 	AN(vltop);
 
 	init_macro();
-	init_sema();
 	init_barrier();
 	init_server();
 
diff --git a/bin/varnishtest/vtc.h b/bin/varnishtest/vtc.h
index 584b1ba..23095d4 100644
--- a/bin/varnishtest/vtc.h
+++ b/bin/varnishtest/vtc.h
@@ -61,7 +61,6 @@ cmd_f cmd_delay;
 cmd_f cmd_server;
 cmd_f cmd_client;
 cmd_f cmd_varnish;
-cmd_f cmd_sema;
 cmd_f cmd_barrier;
 cmd_f cmd_logexp;
 cmd_f cmd_process;
@@ -74,7 +73,6 @@ extern unsigned vtc_maxdur;
 extern int vtc_witness;
 extern int feature_dns;
 
-void init_sema(void);
 void init_barrier(void);
 void init_server(void);
 
diff --git a/bin/varnishtest/vtc_http.c b/bin/varnishtest/vtc_http.c
index b2846f4..20f7354 100644
--- a/bin/varnishtest/vtc_http.c
+++ b/bin/varnishtest/vtc_http.c
@@ -1381,7 +1381,6 @@ static const struct cmds http_cmds[] = {
 	{ "chunkedlen",		cmd_http_chunkedlen },
 	{ "delay",		cmd_delay },
 	{ "barrier",		cmd_barrier },
-	{ "sema",		cmd_sema },
 	{ "expect_close",	cmd_http_expect_close },
 	{ "close",		cmd_http_close },
 	{ "accept",		cmd_http_accept },
diff --git a/bin/varnishtest/vtc_sema.c b/bin/varnishtest/vtc_sema.c
deleted file mode 100644
index 1cab9d1..0000000
--- a/bin/varnishtest/vtc_sema.c
+++ /dev/null
@@ -1,162 +0,0 @@
-/*-
- * Copyright (c) 2008-2010 Varnish Software AS
- * All rights reserved.
- *
- * Author: Poul-Henning Kamp <phk at phk.freebsd.dk>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include "config.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-#include "vtc.h"
-
-struct sema {
-	unsigned		magic;
-#define SEMA_MAGIC		0x29b64317
-	char			*name;
-	VTAILQ_ENTRY(sema)	list;
-	pthread_mutex_t		mtx;
-	pthread_cond_t		cond;
-
-	unsigned		waiters;
-	unsigned		expected;
-};
-
-static pthread_mutex_t		sema_mtx;
-static VTAILQ_HEAD(, sema)	semas = VTAILQ_HEAD_INITIALIZER(semas);
-
-/**********************************************************************
- * Allocate and initialize a sema
- */
-
-static struct sema *
-sema_new(char *name, struct vtclog *vl)
-{
-	struct sema *r;
-
-	ALLOC_OBJ(r, SEMA_MAGIC);
-	AN(r);
-	AN(name);
-	if (*name != 'r')
-		vtc_log(vl, 0, "Sema name must start with 'r' (%s)", name);
-	r->name = name;
-
-	AZ(pthread_mutex_init(&r->mtx, NULL));
-	AZ(pthread_cond_init(&r->cond, NULL));
-	r->waiters = 0;
-	r->expected = 0;
-	VTAILQ_INSERT_TAIL(&semas, r, list);
-	return (r);
-}
-
-/**********************************************************************
- * Sync a sema
- */
-
-static void
-sema_sync(struct sema *r, const char *av, struct vtclog *vl)
-{
-	unsigned u;
-
-	CHECK_OBJ_NOTNULL(r, SEMA_MAGIC);
-	u = strtoul(av, NULL, 0);
-
-	if (r->expected == 0)
-		r->expected = u;
-	if (r->expected != u)
-		vtc_log(vl, 0,
-		    "Sema(%s) use error: different expectations (%u vs %u)",
-		    r->name, r->expected, u);
-
-	if (++r->waiters == r->expected) {
-		vtc_log(vl, 4, "Sema(%s) wake %u", r->name, r->expected);
-		AZ(pthread_cond_broadcast(&r->cond));
-		r->waiters = 0;
-		r->expected = 0;
-	} else {
-		vtc_log(vl, 4, "Sema(%s) wait %u of %u",
-		    r->name, r->waiters, r->expected);
-		AZ(pthread_cond_wait(&r->cond, &r->mtx));
-	}
-}
-
-/**********************************************************************
- * Semaphore command dispatch
- */
-
-void
-cmd_sema(CMD_ARGS)
-{
-	struct sema *r, *r2;
-
-	(void)priv;
-	(void)cmd;
-
-	if (av == NULL) {
-		AZ(pthread_mutex_lock(&sema_mtx));
-		/* Reset and free */
-		VTAILQ_FOREACH_SAFE(r, &semas, list, r2) {
-			AZ(pthread_mutex_lock(&r->mtx));
-			AZ(r->waiters);
-			AZ(r->expected);
-			AZ(pthread_mutex_unlock(&r->mtx));
-		}
-		AZ(pthread_mutex_unlock(&sema_mtx));
-		return;
-	}
-
-	AZ(strcmp(av[0], "sema"));
-	av++;
-
-	AZ(pthread_mutex_lock(&sema_mtx));
-	VTAILQ_FOREACH(r, &semas, list)
-		if (!strcmp(r->name, av[0]))
-			break;
-	if (r == NULL)
-		r = sema_new(av[0], vl);
-	av++;
-	AZ(pthread_mutex_lock(&r->mtx));
-	AZ(pthread_mutex_unlock(&sema_mtx));
-
-	for (; *av != NULL; av++) {
-		if (!strcmp(*av, "sync")) {
-			av++;
-			AN(*av);
-			sema_sync(r, *av, vl);
-			continue;
-		}
-		vtc_log(vl, 0, "Unknown sema argument: %s", *av);
-	}
-	AZ(pthread_mutex_unlock(&r->mtx));
-}
-
-void
-init_sema(void)
-{
-	AZ(pthread_mutex_init(&sema_mtx, NULL));
-}



More information about the varnish-commit mailing list