git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Dave Zarzycki <zarzycki@apple.com>
To: git@vger.kernel.org
Subject: Resend: [PATCH] Do not log unless all connect() attempts fail
Date: Mon, 11 Jul 2011 11:06:15 -0700	[thread overview]
Message-ID: <A3C89B89-4E31-400E-9DF8-C0F289D72D81@apple.com> (raw)

IPv6 hosts are often unreachable on the primarily IPv4 Internet and
therefore we shouldn't print an error if there are still other hosts we
can try to connect() to. This helps "git fetch --quiet" stay quiet.
---
 connect.c |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/connect.c b/connect.c
index 2119c3f..8eb9f44 100644
--- a/connect.c
+++ b/connect.c
@@ -192,6 +192,7 @@ static const char *ai_name(const struct addrinfo *ai)
  */
 static int git_tcp_connect_sock(char *host, int flags)
 {
+       struct strbuf error_message = STRBUF_INIT;
        int sockfd = -1, saved_errno = 0;
        const char *port = STR(DEFAULT_GIT_PORT);
        struct addrinfo hints, *ai0, *ai;
@@ -225,11 +226,8 @@ static int git_tcp_connect_sock(char *host, int flags)
                }
                if (connect(sockfd, ai->ai_addr, ai->ai_addrlen) < 0) {
                        saved_errno = errno;
-                       fprintf(stderr, "%s[%d: %s]: errno=%s\n",
-                               host,
-                               cnt,
-                               ai_name(ai),
-                               strerror(saved_errno));
+                       strbuf_addf(&error_message, "%s[%d: %s]: errno=%s\n",
+                               host, cnt, ai_name(ai), strerror(saved_errno));
                        close(sockfd);
                        sockfd = -1;
                        continue;
@@ -242,11 +240,13 @@ static int git_tcp_connect_sock(char *host, int flags)
        freeaddrinfo(ai0);

        if (sockfd < 0)
-               die("unable to connect a socket (%s)", strerror(saved_errno));
+               die("unable to connect to %s:\n%s", host, error_message.buf);

        if (flags & CONNECT_VERBOSE)
                fprintf(stderr, "done.\n");

+       strbuf_release(&error_message);
+
        return sockfd;
 }

-- 
1.7.6.135.g8cdba

             reply	other threads:[~2011-07-11 18:06 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-11 18:06 Dave Zarzycki [this message]
2011-07-12  5:55 ` Resend: [PATCH] Do not log unless all connect() attempts fail Jeff King
2011-07-12 16:09 ` Junio C Hamano
2011-07-12 16:29   ` Dave Zarzycki
2011-07-13  9:26   ` Erik Faye-Lund

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=A3C89B89-4E31-400E-9DF8-C0F289D72D81@apple.com \
    --to=zarzycki@apple.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).