From 43830ce2bff25a9acca4268ffaa3a681ac3afec2 Mon Sep 17 00:00:00 2001 From: David Härdeman Date: Wed, 1 Jul 2020 21:47:14 +0200 Subject: Teach connect_any to report the address it connected to in order to improve dbg messages --- minecctl/mc-commands.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'minecctl/mc-commands.c') diff --git a/minecctl/mc-commands.c b/minecctl/mc-commands.c index 648af0e..49fea30 100644 --- a/minecctl/mc-commands.c +++ b/minecctl/mc-commands.c @@ -11,6 +11,7 @@ bool do_mc_pcount(struct cfg *cfg, unsigned *online, unsigned *max) { struct server *server; struct saddr *saddr; + const char *error; char buf[4096]; size_t plen, off; ssize_t r; @@ -19,19 +20,12 @@ bool do_mc_pcount(struct cfg *cfg, unsigned *online, unsigned *max) server = server_get_default(cfg); - fd = connect_any(&server->scfg.remotes, true); + fd = connect_any(&server->scfg.remotes, &saddr, &error); if (fd < 0) { - error("%s: unable to connect", server->name); + error("%s: unable to connect - %s", server->name, error); return false; } - /* FIXME: connect_any needs to indicate the address it used */ - saddr = list_first_entry(&server->scfg.remotes, struct saddr, list); - if (!saddr) { - error("No saddr"); - goto out; - } - if (!mc_protocol_create_status_request(buf, sizeof(buf), &plen, saddr)) { error("Failed to create req"); -- cgit v1.2.3