[master] 3b73cf0 Close a race where varnishtest::client would attempt to connect before varnishd::acceptor had called listen(2)

Poul-Henning Kamp phk at varnish-cache.org
Wed Oct 12 10:19:51 CEST 2011


commit 3b73cf0e92f432c23387ca498d7783f1d1b18bee
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Wed Oct 12 08:18:43 2011 +0000

    Close a race where varnishtest::client would attempt to connect before
    varnishd::acceptor had called listen(2)
    
    Found and fixed by:	slink aka. Nils Goroll

diff --git a/bin/varnishd/cache_acceptor.c b/bin/varnishd/cache_acceptor.c
index e6ad6e3..f92bace 100644
--- a/bin/varnishd/cache_acceptor.c
+++ b/bin/varnishd/cache_acceptor.c
@@ -376,6 +376,16 @@ ccf_listen_address(struct cli *cli, const char * const *av, void *priv)
 	(void)cli;
 	(void)av;
 	(void)priv;
+
+	/*
+	 * This CLI command is primarily used by varnishtest.  Don't
+	 * respond until liste(2) has been called, in order to avoid
+	 * a race where varnishtest::client would attempt to connect(2)
+	 * before listen(2) has been called.
+	 */
+	while(!hack_ready)
+		(void)usleep(100*1000);
+
 	VTAILQ_FOREACH(ls, &heritage.socks, list) {
 		if (ls->sock < 0)
 			continue;



More information about the varnish-commit mailing list