Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/native/eventpipe/ep-provider.c
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,7 @@ provider_free (EventPipeProvider * provider)

dn_list_custom_free (provider->event_list, event_free_func);

ep_rt_wait_event_free (&provider->callbacks_complete_event);
ep_rt_utf16_string_free (provider->provider_name_utf16);
ep_rt_utf8_string_free (provider->provider_name);
ep_rt_object_free (provider);
Expand Down
34 changes: 18 additions & 16 deletions src/native/eventpipe/ep.c
Original file line number Diff line number Diff line change
Expand Up @@ -1319,22 +1319,15 @@ ep_delete_provider (EventPipeProvider *provider)
// where we hold a provider after tracing has been disabled.
bool wait_for_provider_callbacks_completion = false;
EP_LOCK_ENTER (section1)
if (enabled ()) {
// Save the provider until the end of the tracing session.
ep_provider_set_delete_deferred (provider, true);

// The callback func must be previously set to null,
// otherwise callbacks might never stop coming.
EP_ASSERT (provider->callback_func == NULL);

// Calling ep_delete_provider within a Callback will result in a deadlock
// as deleting the provider with an active tracing session will block
// until all of the provider's callbacks are completed.
if (provider->callbacks_pending > 0)
wait_for_provider_callbacks_completion = true;
} else {
config_delete_provider (ep_config_get (), provider);
}
// The callback func must be set to null,
// otherwise callbacks might never stop coming.
provider->callback_func = NULL;

// Calling ep_delete_provider within a Callback will result in a deadlock
// as deleting the provider with an active tracing session will block
// until all of the provider's callbacks are completed.
if (provider->callbacks_pending > 0)
wait_for_provider_callbacks_completion = true;
EP_LOCK_EXIT (section1)

// Block provider deletion until all pending callbacks are completed.
Expand All @@ -1344,6 +1337,15 @@ ep_delete_provider (EventPipeProvider *provider)
if (wait_for_provider_callbacks_completion)
ep_rt_wait_event_wait (&provider->callbacks_complete_event, EP_INFINITE_WAIT, false);

EP_LOCK_ENTER (section2)
if (enabled ()) {
// Save the provider until the end of the tracing session.
ep_provider_set_delete_deferred (provider, true);
} else {
config_delete_provider (ep_config_get (), provider);
}
EP_LOCK_EXIT (section2)

ep_on_exit:
ep_requires_lock_not_held ();
return;
Expand Down