Skip to content

Commit

Permalink
curl: Only free multi handle as last action
Browse files Browse the repository at this point in the history
This is my best current guess as to the cause of
#3299

If the fetcher gets torn down while it has outstanding requests
in flight, I think we'll end up in some code paths calling
into libcurl to cancel things.

It might be that prior to the curl change, while the handle was
invalid it was "valid enough" for that to work.

Clearly moving the multi cleanup to be the last step is
a safe thing, and it might fix the bug, so let's do that.

Signed-off-by: Colin Walters <[email protected]>
  • Loading branch information
cgwalters committed Sep 18, 2024
1 parent 2945165 commit 34e4f1a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/libostree/ostree-fetcher-curl.c
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,6 @@ _ostree_fetcher_finalize (GObject *object)
{
OstreeFetcher *self = OSTREE_FETCHER (object);

curl_multi_cleanup (self->multi);
g_free (self->remote_name);
g_free (self->tls_ca_db_path);
g_free (self->tls_client_cert_path);
Expand All @@ -195,6 +194,11 @@ _ostree_fetcher_finalize (GObject *object)
if (self->mainctx)
g_main_context_unref (self->mainctx);
g_clear_pointer (&self->custom_user_agent, g_free);
// Do this last as it may be possible that some of the teardown functions
// invoked by callbacks above reference this. For example,
// self->outstanding_requests has a GTask whose cleanup invokes request_unref()
// which calls curl_easy_cleanup().
curl_multi_cleanup (self->multi);

G_OBJECT_CLASS (_ostree_fetcher_parent_class)->finalize (object);
}
Expand Down

0 comments on commit 34e4f1a

Please sign in to comment.