From nobody Mon Jan 24 07:38:35 2022 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 42AD11969DD1; Mon, 24 Jan 2022 07:38:36 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Jj20X1Pb0z3k15; Mon, 24 Jan 2022 07:38:36 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1643009916; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=skJqas3lqfBwyh6anuAD+O4llD+V4BGrkxH9J7KO9AM=; b=BPJi6anwU4dxfXA6wsmhhU6AMQhNNr/Jin9m0x0TkqWSqIyiLR6qp+0SoOSoWsjAfWM3c4 p7ZOU4QYHWp2CQsbS/J15gm5m3IJPTKwI9xJZ0m2zUS7v0O6Re9AQ/4iUL1z0BHE2Dg+1S aw5dgHA/ZIhJeJtX9aIzzx5PPN20sdM7McMijCLpnN0MOvPDmsIMblHKgqKAoL4ty8fFZs V8njGQgqsgTBSSdSMLNrQ9sJpCgCTmXAIjNLhQfAlXVbHUBxmrlfKkQgzIp9bxyvO/xgk4 kWFw+6qBPjKlLPwnHEfTE5obG9JBEfUEAAa12xL3P/+Cz7W7YiE97jXug4gUAw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 0BD0711FB9; Mon, 24 Jan 2022 07:38:36 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 20O7cZr0098679; Mon, 24 Jan 2022 07:38:35 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 20O7cZPs098678; Mon, 24 Jan 2022 07:38:35 GMT (envelope-from git) Date: Mon, 24 Jan 2022 07:38:35 GMT Message-Id: <202201240738.20O7cZPs098678@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Eugene Grosbein Subject: git: bf599c03f09d - main - fetch(1): do not consider HTTP 5XX errors as soft failures List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: eugen X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: bf599c03f09dea0f7e188e002b42d782af6841c3 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1643009916; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=skJqas3lqfBwyh6anuAD+O4llD+V4BGrkxH9J7KO9AM=; b=NeJIOb/ZOpKeMPC5C7usWoOcXmwbM33GQliLNuHOdGyam9GWTDqzJWvaG9Akk+7CpNohB7 Hhty3tEe6b7NTqpgQRpn0AdM4lvZ25hwt5fHY2IJTB+87ZmZrPwo5NKhd9pjYq9dCh1QXt z3f0IGCg9FvxfPGRO09fHP1yOzcRsO/0F6sLYNtra/NQHTnbSwGmih1I2mhjm4ah0VSP1/ qNnpGzg67lsNTDifiURiLhL+xcv7UuNLZ78tBusnGvsxsZT2fS0cFPf4M8GlaNGf0dvi4A CTJvWRknS+yAcsYvRHpmqEY/RRwlpFysxwv7DMhM8S1H5HQVGX3qXwTtS0fDbw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1643009916; a=rsa-sha256; cv=none; b=XB61xLiC954LqSSKba8A0a3c/JBX8LtvIn0bI0feSfDwfeKlGBZ0Fgp5bkY+8AHxit3TbJ fZoR98OfLEy7w1a2DnMSJrc/k95ZrU0ikxASs+REN1rLwWHSq/zjOrFA9VcAtyAt3msDFx SSauZLiS4ju0tjC3c3Jl0ootaX8FzqTKrDuACe3nWuxb0XLO7SBwm6TDR+1mgIb/MUefu9 xuMN1yg5mSNDzsrT64U5p7av8j8TkxFXqbfh3A/bvScoWUOAcIZWAM/YipkQXF05MZqfRi UYbMRXQgE3FEfaSBlA6GH517XR+OB9cb52T4FLZHA+rxl2G5WUhBe+fGGZm65w== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by eugen: URL: https://cgit.FreeBSD.org/src/commit/?id=bf599c03f09dea0f7e188e002b42d782af6841c3 commit bf599c03f09dea0f7e188e002b42d782af6841c3 Author: Eugene Grosbein AuthorDate: 2022-01-24 07:35:49 +0000 Commit: Eugene Grosbein CommitDate: 2022-01-24 07:38:26 +0000 fetch(1): do not consider HTTP 5XX errors as soft failures This change fixes "fetch -a" looping forever on "502 Bad gateway" error and similar. MFC after: 1 month --- usr.bin/fetch/fetch.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/usr.bin/fetch/fetch.c b/usr.bin/fetch/fetch.c index 3e24707d6021..55209538e49b 100644 --- a/usr.bin/fetch/fetch.c +++ b/usr.bin/fetch/fetch.c @@ -425,7 +425,7 @@ query_auth(struct url *URL) * Fetch a file */ static int -fetch(char *URL, const char *path) +fetch(char *URL, const char *path, int *is_http) { struct url *url; struct url_stat us; @@ -475,6 +475,9 @@ fetch(char *URL, const char *path) strcpy(url->scheme, SCHEME_HTTP); } + /* for both of http and https */ + *is_http = strncmp(url->scheme, SCHEME_HTTP, sizeof(SCHEME_HTTP)) == 0; + /* common flags */ switch (family) { case PF_INET: @@ -911,7 +914,7 @@ main(int argc, char *argv[]) struct sigaction sa; const char *p, *s; char *end, *q; - int c, e, r; + int c, e, is_http, r; while ((c = getopt_long(argc, argv, @@ -1176,16 +1179,16 @@ main(int argc, char *argv[]) if (o_flag) { if (o_stdout) { - e = fetch(*argv, "-"); + e = fetch(*argv, "-", &is_http); } else if (o_directory) { asprintf(&q, "%s/%s", o_filename, p); - e = fetch(*argv, q); + e = fetch(*argv, q, &is_http); free(q); } else { - e = fetch(*argv, o_filename); + e = fetch(*argv, o_filename, &is_http); } } else { - e = fetch(*argv, p); + e = fetch(*argv, p, &is_http); } if (sigint) @@ -1201,7 +1204,13 @@ main(int argc, char *argv[]) && fetchLastErrCode != FETCH_MOVED && fetchLastErrCode != FETCH_URL && fetchLastErrCode != FETCH_RESOLV - && fetchLastErrCode != FETCH_UNKNOWN)) { + && fetchLastErrCode != FETCH_UNKNOWN + && (is_http + && fetchLastErrCode != FETCH_PROTO + && fetchLastErrCode != FETCH_SERVER + && fetchLastErrCode != FETCH_TEMP + && fetchLastErrCode != FETCH_TIMEOUT + ))) { if (w_secs && v_level) fprintf(stderr, "Waiting %ld seconds " "before retrying\n", w_secs);