From: phk Date: Thu, 18 Dec 2008 12:00:43 +0000 (+0000) Subject: Only fail -T argument if none of the addresses it resolves to X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3a0d3f8c33058462e77bacba7c338e316235a466;p=varnish Only fail -T argument if none of the addresses it resolves to can be listend on. Fixes #97 git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@3473 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- diff --git a/varnish-cache/bin/varnishd/mgt_cli.c b/varnish-cache/bin/varnishd/mgt_cli.c index 827cddf1..725d4741 100644 --- a/varnish-cache/bin/varnishd/mgt_cli.c +++ b/varnish-cache/bin/varnishd/mgt_cli.c @@ -459,22 +459,23 @@ mgt_cli_telnet(int dflag, const char *T_arg) { struct vss_addr **ta; char *addr, *port; - int i, n, sock; + int i, n, sock, good; struct telnet *tn; dflag_copy = dflag; XXXAZ(VSS_parse(T_arg, &addr, &port)); n = VSS_resolve(addr, port, &ta); - free(addr); - free(port); if (n == 0) { fprintf(stderr, "Could not open management port\n"); exit(2); } + good = 0; for (i = 0; i < n; ++i) { sock = VSS_listen(ta[i], 10); - assert(sock >= 0); + if (sock < 0) + continue; + good++; tn = telnet_new(sock); tn->ev = vev_new(); XXXAN(tn->ev); @@ -486,5 +487,12 @@ mgt_cli_telnet(int dflag, const char *T_arg) ta[i] = NULL; } free(ta); + if (good == 0) { + REPORT(LOG_ERR, "-T %s:%s could not be listened on.", + addr, port); + exit(2); + } + free(addr); + free(port); return (0); }