diff --git a/src/libostree/ostree-fetcher-curl.h b/src/libostree/ostree-fetcher-curl.h deleted file mode 100644 index 98386127a2..0000000000 --- a/src/libostree/ostree-fetcher-curl.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (C) 2016 Colin Walters - * - * SPDX-License-Identifier: LGPL-2.0+ - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see . - */ - -#pragma once - -#ifndef __GI_SCANNER__ - -#include "ostree-fetcher.h" - -G_BEGIN_DECLS - -typedef enum -{ - OPT_CURL_TIMEOUT = 300L, - OPT_CURL_CONNECT_TIMEOUT = 30L, - OPT_CURL_LOWSPEED_LIMIT = 1000L, -} OstreeCurlOptConfigFlags; - -#endif diff --git a/src/libostree/ostree-fetcher.h b/src/libostree/ostree-fetcher.h index 7e6254bb37..6f1e931bc6 100644 --- a/src/libostree/ostree-fetcher.h +++ b/src/libostree/ostree-fetcher.h @@ -99,9 +99,11 @@ void _ostree_fetcher_set_proxy (OstreeFetcher *fetcher, const char *proxy); void _ostree_fetcher_set_client_cert (OstreeFetcher *fetcher, const char *cert_path, const char *key_path); -void _ostree_fetcher_set_low_speed_limit (OstreeFetcher *self, long int *opt_low_speed_limit); +void _ostree_fetcher_set_low_speed_limit (OstreeFetcher *self, long *opt_low_speed_limit); -void _ostree_fetcher_set_low_speed_time (OstreeFetcher *self, long int *opt_low_speed_time); +void _ostree_fetcher_set_low_speed_time (OstreeFetcher *self, long *opt_low_speed_time); + +void _ostree_fetcher_set_retry_all (OstreeFetcher *self, gboolean *opt_retry_all; void _ostree_fetcher_set_tls_database (OstreeFetcher *self, const char *tlsdb_path); diff --git a/src/libostree/ostree-repo-pull-private.h b/src/libostree/ostree-repo-pull-private.h index 2e0c42a291..266b4e7b3f 100644 --- a/src/libostree/ostree-repo-pull-private.h +++ b/src/libostree/ostree-repo-pull-private.h @@ -54,8 +54,9 @@ typedef struct GVariant *extra_headers; char *append_user_agent; - long int *low_speed_limit; - long int *low_speed_time; + long low_speed_limit; + long low_speed_time; + gboolean retry_all; gboolean dry_run; diff --git a/src/libostree/ostree-repo-pull.c b/src/libostree/ostree-repo-pull.c index 38e011472c..e2c7e3a29f 100644 --- a/src/libostree/ostree-repo-pull.c +++ b/src/libostree/ostree-repo-pull.c @@ -63,6 +63,7 @@ #define DEFAULT_N_NETWORK_RETRIES 5 #define OPT_LOWSPEEDLIMIT_DEFAULT 1000L #define OPT_LOWSPEEDTIME_DEFAULT 30L +#define OPT_RETRYALL_DEFAULT true typedef struct { @@ -2930,8 +2931,9 @@ _ostree_repo_cache_summary (OstreeRepo *self, const char *remote, GBytes *summar static OstreeFetcher * _ostree_repo_remote_new_fetcher (OstreeRepo *self, const char *remote_name, gboolean gzip, GVariant *extra_headers, const char *append_user_agent, - long int *low_speed_limit, long int *low_speed_time, - OstreeFetcherSecurityState *out_state, GError **error) + long low_speed_limit, long low_speed_time, + gboolean retry_all, OstreeFetcherSecurityState *out_state, + GError **error) { OstreeFetcher *fetcher = NULL; OstreeFetcherConfigFlags fetcher_flags = 0; @@ -3000,6 +3002,7 @@ _ostree_repo_remote_new_fetcher (OstreeRepo *self, const char *remote_name, gboo _ostree_fetcher_set_low_speed_limit (fetcher, (low_speed_limit) ? low_speed_limit : OPT_LOWSPEEDLIMIT_DEFAULT); _ostree_fetcher_set_low_speed_time (fetcher, (low_speed_time) ? low_speed_time : OPT_LOWSPEEDTIME_DEFAULT); + _ostree_fetcher_set_retry_all (fetcher, (retry_all) ? retry_all : OPT_RETRYALL_DEFAULT); { g_autofree char *tls_ca_path = NULL; @@ -3227,7 +3230,7 @@ reinitialize_fetcher (OtPullData *pull_data, const char *remote_name, GError **e g_clear_object (&pull_data->fetcher); pull_data->fetcher = _ostree_repo_remote_new_fetcher ( pull_data->repo, remote_name, FALSE, pull_data->extra_headers, pull_data->append_user_agent, - pull_data->low_speed_limit, pull_data->low_speed_time, + pull_data->low_speed_limit, pull_data->low_speed_time, pull_data->retry_all, &pull_data->fetcher_security_state, error); if (pull_data->fetcher == NULL) return FALSE; @@ -3461,6 +3464,8 @@ all_requested_refs_have_commit ( during the time set via "low-speed-time-seconds" for libcurl to abort. * * `low-speed-time-seconds` (`u`): The time in number seconds that the transfer speed should be below the "low-speed-limit-bytes" setting for libcurl to abort. + * * `retry-all-network-errors` (`b`): Retry when network issues happen, instead of + * failing automatically. Currently only affects libcurl. (Default set to true) * * `ref-keyring-map` (`a(sss)`): Array of (collection ID, ref name, keyring * remote name) tuples specifying which remote's keyring should be used when * doing GPG verification of each collection-ref. This is useful to prevent a @@ -3583,6 +3588,7 @@ ostree_repo_pull_with_options (OstreeRepo *self, const char *remote_name_or_base (void)g_variant_lookup (options, "append-user-agent", "s", &pull_data->append_user_agent); (void)g_variant_lookup (options, "low-speed-limit-bytes", "u", &pull_data->low_speed_limit); (void)g_variant_lookup (options, "low-speed-time-seconds", "u", &pull_data->low_speed_time); + (void)g_variant_lookup (options, "retry-all-network-errors", "b", &pull_data->retry_all); opt_n_network_retries_set = g_variant_lookup (options, "n-network-retries", "u", &pull_data->n_network_retries); opt_ref_keyring_map_set @@ -4910,6 +4916,7 @@ ostree_repo_pull_with_options (OstreeRepo *self, const char *remote_name_or_base g_free (pull_data->append_user_agent); g_free (pull_data->low_speed_limit); g_free (pull_data->low_speed_time); + g_free (pull_data->retry_all); g_clear_pointer (&pull_data->signapi_commit_verifiers, g_ptr_array_unref); g_clear_pointer (&pull_data->signapi_summary_verifiers, g_ptr_array_unref); g_clear_pointer (&pull_data->meta_mirrorlist, g_ptr_array_unref); @@ -5708,7 +5715,7 @@ find_remotes_cb (GObject *obj, GAsyncResult *async_result, gpointer user_data) goto error; fetcher = _ostree_repo_remote_new_fetcher (self, result->remote->name, TRUE, NULL, - NULL, NULL, NULL, NULL, &error); + NULL, NULL, NULL, TRUE, NULL, &error); if (fetcher == NULL) goto error; @@ -6322,8 +6329,9 @@ ostree_repo_remote_fetch_summary_with_options (OstreeRepo *self, const char *nam g_autoptr (GVariant) extra_headers = NULL; g_autoptr (GPtrArray) mirrorlist = NULL; const char *append_user_agent = NULL; - long int *low_speed_limit = NULL; - long int *low_speed_time = NULL; + long low_speed_limit = OPT_LOWSPEEDLIMIT_DEFAULT; + long low_speed_time = OPT_LOWSPEEDTIME_DEFAULT; + gboolean retry_all = OPT_RETRYALL_DEFAULT; guint n_network_retries = DEFAULT_N_NETWORK_RETRIES; gboolean summary_sig_not_modified = FALSE; g_autofree char *summary_sig_if_none_match = NULL; @@ -6350,6 +6358,7 @@ ostree_repo_remote_fetch_summary_with_options (OstreeRepo *self, const char *nam (void)g_variant_lookup (options, "n-network-retries", "u", &n_network_retries); (void)g_variant_lookup (options, "low-speed-limit-bytes", "u", &low_speed_limit); (void)g_variant_lookup (options, "low-speed-time-seconds", "u", &low_speed_time); + (void)g_variant_lookup (options, "retry-all-network-errors", "b", &retry_all); } if (!ostree_repo_remote_get_gpg_verify_summary (self, name, &gpg_verify_summary, error)) @@ -6362,7 +6371,7 @@ ostree_repo_remote_fetch_summary_with_options (OstreeRepo *self, const char *nam (void)mainctx; // Used for autocleanup fetcher = _ostree_repo_remote_new_fetcher (self, name, TRUE, extra_headers, append_user_agent, - low_speed_limit, low_speed_time, NULL, error); + low_speed_limit, low_speed_time, retry_all, NULL, error); if (fetcher == NULL) return FALSE;