From: Jeff King <peff@peff.net>
To: Dave Zarzycki <zarzycki@apple.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] Only print an error for the last connect() failure
Date: Thu, 9 Jun 2011 12:33:41 -0400 [thread overview]
Message-ID: <20110609163340.GD25885@sigill.intra.peff.net> (raw)
In-Reply-To: <13539E82-3E8D-4210-9A3A-DD83F0CA6F85@apple.com>
On Thu, Jun 09, 2011 at 09:18:10AM -0700, Dave Zarzycki wrote:
> 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, 7 insertions(+), 5 deletions(-)
>
> diff --git a/connect.c b/connect.c
> index 2119c3f..7f70ce7 100644
> --- a/connect.c
> +++ b/connect.c
> @@ -225,11 +225,13 @@ 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));
> + if (ai->ai_next == NULL) {
> + fprintf(stderr, "%s[%d: %s]: errno=%s\n",
> + host,
> + cnt,
> + ai_name(ai),
> + strerror(saved_errno));
> + }
I agree being noisy about early failures when we succeed later is a bad
thing. But when we fail completely, doesn't your code now mask early
failures and print only the final one? The early failures might be the
important ones for the user.
So perhaps we should do something instead like:
struct strbuf error_message = STRBUF_INIT;
...
if (connect(...) < 0) {
strbuf_addf(&error_message, "%s[%d: %s]: errno=%s\n",
host, cnt, ai_name(ai), strerror(errno));
...
}
if (sockfd < 0)
die("unable to connect to %s:\n%s", host, error_message.buf);
strbuf_release(&error_message);
-Peff
next prev parent reply other threads:[~2011-06-09 16:33 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-09 16:18 [PATCH] Only print an error for the last connect() failure Dave Zarzycki
2011-06-09 16:33 ` Jeff King [this message]
2011-06-09 16:49 ` Dave Zarzycki
2011-06-09 17:05 ` Jeff King
2011-06-09 17:30 ` Junio C Hamano
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20110609163340.GD25885@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=zarzycki@apple.com \
/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.
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 NNTP newsgroup(s).