[master] ab550ba Report errors on listen() to the management process.

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


commit ab550bae3bccda66786e596a0746907655eb28e6
Author: Martin Blix Grydeland <martin at varnish-software.com>
Date:   Wed Feb 28 11:58:40 2018 +0100

    Report errors on listen() to the management process.
    
    If the listen() system call were to report problems, they are now reported
    back to the management process, failing the child startup (instead of
    asserting). This can happen on many widely used Linux kernels if the
    listen socket already has another process listening on that port with the
    SO_REUSEPORT flag set.
    
    Newer Linux kernels will report the problem at bind() time (causing error
    to be reported upon management process startup).
    
    Fixes: #2551

diff --git a/bin/varnishd/cache/cache_acceptor.c b/bin/varnishd/cache/cache_acceptor.c
index a617581..6973d01 100644
--- a/bin/varnishd/cache/cache_acceptor.c
+++ b/bin/varnishd/cache/cache_acceptor.c
@@ -631,7 +631,12 @@ ccf_start(struct cli *cli, const char * const *av, void *priv)
 				    "Kernel TCP Fast Open: sock=%d, ret=%d %s",
 				    ls->sock, i, strerror(errno));
 		}
-		AZ(listen(ls->sock, cache_param->listen_depth));
+		if (listen(ls->sock, cache_param->listen_depth)) {
+			VCLI_SetResult(cli, CLIS_CANT);
+			VCLI_Out(cli, "Listen failed on socket '%s': %s",
+			    ls->endpoint, strerror(errno));
+			return;
+		}
 		vca_tcp_opt_set(ls, 1);
 		if (cache_param->accept_filter) {
 			int i;


More information about the varnish-commit mailing list