Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
jmarrero committed Oct 12, 2023
1 parent d2934a8 commit 060152e
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 11 deletions.
7 changes: 7 additions & 0 deletions src/libostree/ostree-fetcher-curl.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ struct OstreeFetcher
guint32 opt_low_speed_limit;
guint32 opt_low_speed_time;
gboolean opt_retry_all;
guint32 opt_max_outstanding_fetcher_requests;

GMainContext *mainctx;
CURLM *multi;
Expand Down Expand Up @@ -691,6 +692,12 @@ _ostree_fetcher_set_retry_all (OstreeFetcher *self, gboolean opt_retry_all)
self->opt_retry_all = opt_retry_all;
}

void
_ostree_fetcher_set_max_outstanding_fetcher_requests (OstreeFetcher *self, guint32 opt_max_outstanding_fetcher_requests)
{
self->opt_max_outstanding_fetcher_requests = opt_max_outstanding_fetcher_requests;
}

void
_ostree_fetcher_set_cookie_jar (OstreeFetcher *self, const char *jar_path)
{
Expand Down
6 changes: 6 additions & 0 deletions src/libostree/ostree-fetcher-soup.c
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,12 @@ _ostree_fetcher_set_retry_all (OstreeFetcher *self, gboolean opt_retry_all)
// TODO
}

void
_ostree_fetcher_set_max_outstanding_fetcher_requests (OstreeFetcher *self, guint32 opt_max_outstanding_fetcher_requests)
{
self->opt_max_outstanding_fetcher_requests = opt_max_outstanding_fetcher_requests;
}

static void on_request_sent (GObject *object, GAsyncResult *result, gpointer user_data);

static void
Expand Down
6 changes: 6 additions & 0 deletions src/libostree/ostree-fetcher-soup3.c
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,12 @@ _ostree_fetcher_set_retry_all (OstreeFetcher *self, gboolean opt_retry_all)
// TODO
}

void
_ostree_fetcher_set_max_outstanding_fetcher_requests (OstreeFetcher *self, guint32 opt_max_outstanding_fetcher_requests)
{
self->opt_max_outstanding_fetcher_requests = opt_max_outstanding_fetcher_requests;
}

static gboolean
finish_stream (FetcherRequest *request, GCancellable *cancellable, GError **error)
{
Expand Down
25 changes: 14 additions & 11 deletions src/libostree/ostree-repo-pull.c
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ fetcher_queue_is_full (OtPullData *pull_data)
const gboolean fetch_full
= ((pull_data->n_outstanding_metadata_fetches + pull_data->n_outstanding_content_fetches
+ pull_data->n_outstanding_deltapart_fetches)
== max_outstanding_fetcher_requests);
== pull_data->max_outstanding_fetcher_requests);
const gboolean deltas_full
= (pull_data->n_outstanding_deltapart_fetches == _OSTREE_MAX_OUTSTANDING_DELTAPART_REQUESTS);
const gboolean writes_full = ((pull_data->n_outstanding_metadata_write_requests
Expand Down Expand Up @@ -2936,8 +2936,8 @@ static OstreeFetcher *
_ostree_repo_remote_new_fetcher (OstreeRepo *self, const char *remote_name, gboolean gzip,
GVariant *extra_headers, const char *append_user_agent,
guint32 low_speed_limit, guint32 low_speed_time,
gboolean retry_all, guint32 max_outstanding_fetcher_requests, OstreeFetcherSecurityState *out_state,
GError **error)
gboolean retry_all, guint32 max_outstanding_fetcher_requests,
OstreeFetcherSecurityState *out_state, GError **error)
{
OstreeFetcher *fetcher = NULL;
OstreeFetcherConfigFlags fetcher_flags = 0;
Expand Down Expand Up @@ -3235,8 +3235,8 @@ 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->retry_all, pull_data->max_outstanding_fetcher_requests,
&pull_data->fetcher_security_state, error);
pull_data->low_speed_limit, pull_data->low_speed_time, pull_data->retry_all,
pull_data->max_outstanding_fetcher_requests, &pull_data->fetcher_security_state, error);
if (pull_data->fetcher == NULL)
return FALSE;

Expand Down Expand Up @@ -3602,7 +3602,8 @@ ostree_repo_pull_with_options (OstreeRepo *self, const char *remote_name_or_base
opt_retry_all_set
= g_variant_lookup (options, "retry-all-network-errors", "b", &pull_data->retry_all);
opt_max_outstanding_fetcher_requests_set
= g_variant_lookup (options, "max-outstanding-fetcher-requests", "b", &pull_data->max_outstanding_fetcher_requests);
= g_variant_lookup (options, "max-outstanding-fetcher-requests", "b",
&pull_data->max_outstanding_fetcher_requests);
opt_n_network_retries_set
= g_variant_lookup (options, "n-network-retries", "u", &pull_data->n_network_retries);
opt_ref_keyring_map_set
Expand Down Expand Up @@ -3684,7 +3685,8 @@ ostree_repo_pull_with_options (OstreeRepo *self, const char *remote_name_or_base
if (!opt_retry_all_set)
pull_data->retry_all = OPT_RETRYALL_DEFAULT;
if (!opt_max_outstanding_fetcher_requests_set)
pull_data->max_outstanding_fetcher_requests = OPT_OSTREE_MAX_OUTSTANDING_FETCHER_REQUESTS_DEFAULT;
pull_data->max_outstanding_fetcher_requests
= OPT_OSTREE_MAX_OUTSTANDING_FETCHER_REQUESTS_DEFAULT;

pull_data->repo = self;
pull_data->progress = progress;
Expand Down Expand Up @@ -6379,7 +6381,8 @@ ostree_repo_remote_fetch_summary_with_options (OstreeRepo *self, const char *nam
(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);
(void)g_variant_lookup (options, "max-outstanding-fetcher-requests", "b", &max_outstanding_fetcher_requests);
(void)g_variant_lookup (options, "max-outstanding-fetcher-requests", "b",
&max_outstanding_fetcher_requests);
}

if (!ostree_repo_remote_get_gpg_verify_summary (self, name, &gpg_verify_summary, error))
Expand All @@ -6391,9 +6394,9 @@ ostree_repo_remote_fetch_summary_with_options (OstreeRepo *self, const char *nam
mainctx = _ostree_main_context_new_default ();
(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, retry_all, max_outstanding_fetcher_requests, NULL, error);
fetcher = _ostree_repo_remote_new_fetcher (self, name, TRUE, extra_headers, append_user_agent,
low_speed_limit, low_speed_time, retry_all,
max_outstanding_fetcher_requests, NULL, error);
if (fetcher == NULL)
return FALSE;

Expand Down

0 comments on commit 060152e

Please sign in to comment.