git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 4/6] transport: fix index in ipv6 connection failed message

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Jun 6, 2011, 09:40 UTC
Message-ID
<20110606094054.GI8015@elie>
In-Reply-To
<20110606093019.GD8015@elie>

Ever since v1.5.3-rc0~185^2~1 (Verbose connect messages to show the IP addresses used, 2007-05-23), git's ipv4 connection failure messages have looked something like

	git.example.com[2: 127.0.0.1]: errno=Network Unreachable

The increasing index ("2" above) indicates which item in the list of addresses returned by gethostbyname was being tried so the operator can tell that git was not just trying to resolve the same hostname again and again.

The ipv6 codepath prints something similar, but the counter is never incremented so the index is always "0". Fix it.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
 tcp.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/tcp.c b/tcp.c
index 2cb90db..9916272 100644
--- a/tcp.c
+++ b/tcp.c
@@ -134,7 +134,7 @@ static int git_tcp_connect_sock(char *host, int flags)
 	const char *port = STR(DEFAULT_GIT_PORT);
 	struct addrinfo hints, *ai0, *ai;
 	int gai;
-	int cnt = 0;
+	int cnt;
 
 	get_host_and_port(&host, &port);
 	if (!*port)
@@ -154,7 +154,7 @@ static int git_tcp_connect_sock(char *host, int flags)
 	if (flags & CONNECT_VERBOSE)
 		fprintf(stderr, "done.\nConnecting to %s (port %s) ... ", host, port);
 
-	for (ai0 = ai; ai; ai = ai->ai_next) {
+	for (cnt = 0, ai0 = ai; ai; ai = ai->ai_next, cnt++) {
 		sockfd = socket(ai->ai_family,
 				ai->ai_socktype, ai->ai_protocol);
 		if (sockfd < 0) {
-- 
1.7.5.3
Previous: Jonathan NiederNext: Jonathan Nieder
Message 5 of 9 in “git: please honor DNS SRV records”
  1. 0/6 git: please honor DNS SRV recordsJonathan Nieder, Jun 6, 2011
  2. 1/6 transport: expose git_tcp_connect and friends in new tcp.hJonathan Nieder, Jun 6, 2011
  3. 2/6 daemon: make host resolution into a separate functionJonathan Nieder, Jun 6, 2011
  4. 3/6 daemon: move locate_host to tcp.cJonathan Nieder, Jun 6, 2011
  5. 4/6 transport: fix index in ipv6 connection failed messageJonathan Nieder, Jun 6, 2011
  6. 5/6 tcp: unify ipv4 and ipv6 code pathsJonathan Nieder, Jun 6, 2011
  7. Jonathan NiederJun 6, 2011
  8. 6/6 transport: learn to honor DNS SRV recordsJonathan Nieder, Jun 6, 2011
  9. Jonathan NiederJun 6, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.