Fix EventPipe shutdown to include last events in session. (#52431)
authorJohan Lorensson <lateralusx.github@gmail.com>
Sat, 8 May 2021 11:06:49 +0000 (13:06 +0200)
committerGitHub <noreply@github.com>
Sat, 8 May 2021 11:06:49 +0000 (13:06 +0200)
Fixing an incorrect state check in write_event, write_event_2 that would
prevent events written during disable in ep_shutdown to be included
in session. Since most sessions already closed out at this point this
case is mainly hit using the default env based file session, but
it will also affect sessions that are running during shutdown since they
wouldn't get their rundown events included in session stream.

This is a regression from C++ -> C port of EventPipe library.

src/native/eventpipe/ep.c

index d5ce8dfa0bcc88e2f52f7c0324252f05d3585366..d13c2ac61ef2c8ece788981c5d918c8c081a0eec 100644 (file)
@@ -611,7 +611,7 @@ write_event (
        EP_ASSERT (payload != NULL);
 
        // We can't proceed if tracing is not initialized.
-       ep_return_void_if_nok (ep_volatile_load_eventpipe_state () == EP_STATE_INITIALIZED);
+       ep_return_void_if_nok (ep_volatile_load_eventpipe_state () >= EP_STATE_INITIALIZED);
 
        // Exit early if the event is not enabled.
        ep_return_void_if_nok (ep_event_is_enabled (ep_event));
@@ -649,7 +649,7 @@ write_event_2 (
        EP_ASSERT (payload != NULL);
 
        // We can't proceed if tracing is not initialized.
-       ep_return_void_if_nok (ep_volatile_load_eventpipe_state () == EP_STATE_INITIALIZED);
+       ep_return_void_if_nok (ep_volatile_load_eventpipe_state () >= EP_STATE_INITIALIZED);
 
        EventPipeThread *const current_thread = ep_thread_get_or_create ();
        if (!current_thread) {