[master] 4a095b7 Move the cache acceptor socket preparation to the CLI call

Martin Blix Grydeland martin at varnish-software.com
Mon Mar 5 13:51:07 UTC 2018


commit 4a095b751f656ef5c28b0fb348a2a3ad64cbd4e0
Author: Martin Blix Grydeland <martin at varnish-software.com>
Date:   Wed Feb 28 11:52:14 2018 +0100

    Move the cache acceptor socket preparation to the CLI call
    
    This moves the first time initialization of the listening sockets to the
    CLI "start" command handler. This enables errors to be reported to the
    management process if we were unable to comply.

diff --git a/bin/varnishd/cache/cache_acceptor.c b/bin/varnishd/cache/cache_acceptor.c
index c41194d..398998b 100644
--- a/bin/varnishd/cache/cache_acceptor.c
+++ b/bin/varnishd/cache/cache_acceptor.c
@@ -586,38 +586,8 @@ vca_acct(void *arg)
 	(void)arg;
 
 	t0 = VTIM_real();
-
 	vca_periodic(t0);
-	(void)vca_tcp_opt_init();
-
-	AZ(pthread_mutex_lock(&shut_mtx));
-	VTAILQ_FOREACH(ls, &heritage.socks, list) {
-		CHECK_OBJ_NOTNULL(ls->transport, TRANSPORT_MAGIC);
-		if (ls->sock == -2)
-			continue;	// VCA_Shutdown
-		assert (ls->sock > 0);	// We know where stdin is
-		if (cache_param->tcp_fastopen) {
-			int i;
-			i = VTCP_fastopen(ls->sock, cache_param->listen_depth);
-			if (i)
-				VSL(SLT_Error, ls->sock,
-				    "Kernel TCP Fast Open: sock=%d, ret=%d %s",
-				    ls->sock, i, strerror(errno));
-		}
-		AZ(listen(ls->sock, cache_param->listen_depth));
-		vca_tcp_opt_set(ls, 1);
-		if (cache_param->accept_filter) {
-			int i;
-			i = VTCP_filter_http(ls->sock);
-			if (i)
-				VSL(SLT_Error, ls->sock,
-				    "Kernel filtering: sock=%d, ret=%d %s",
-				    ls->sock, i, strerror(errno));
-		}
-	}
-	AZ(pthread_mutex_unlock(&shut_mtx));
 
-	need_test = 1;
 	pool_accepting = 1;
 
 	while (1) {
@@ -642,11 +612,39 @@ vca_acct(void *arg)
 static void v_matchproto_(cli_func_t)
 ccf_start(struct cli *cli, const char * const *av, void *priv)
 {
+	struct listen_sock *ls;
 
 	(void)cli;
 	(void)av;
 	(void)priv;
 
+	(void)vca_tcp_opt_init();
+
+	VTAILQ_FOREACH(ls, &heritage.socks, list) {
+		CHECK_OBJ_NOTNULL(ls->transport, TRANSPORT_MAGIC);
+		assert (ls->sock > 0);	// We know where stdin is
+		if (cache_param->tcp_fastopen) {
+			int i;
+			i = VTCP_fastopen(ls->sock, cache_param->listen_depth);
+			if (i)
+				VSL(SLT_Error, ls->sock,
+				    "Kernel TCP Fast Open: sock=%d, ret=%d %s",
+				    ls->sock, i, strerror(errno));
+		}
+		AZ(listen(ls->sock, cache_param->listen_depth));
+		vca_tcp_opt_set(ls, 1);
+		if (cache_param->accept_filter) {
+			int i;
+			i = VTCP_filter_http(ls->sock);
+			if (i)
+				VSL(SLT_Error, ls->sock,
+				    "Kernel filtering: sock=%d, ret=%d %s",
+				    ls->sock, i, strerror(errno));
+		}
+	}
+
+	need_test = 1;
+
 	AZ(pthread_create(&VCA_thread, NULL, vca_acct, NULL));
 }
 


More information about the varnish-commit mailing list