@@ -378,6 +378,8 @@ buffer_manager_init_sequence_point_thread_list (
378378 ep_buffer_manager_requires_lock_held (buffer_manager );
379379
380380 DN_LIST_FOREACH_BEGIN (EventPipeThreadSessionState * , thread_session_state , buffer_manager -> thread_session_state_list ) {
381+ EventPipeThread * thread = ep_thread_session_state_get_thread (thread_session_state );
382+
381383 // The sequence number captured here is not guaranteed to be the most recent sequence number, nor
382384 // is it guaranteed to match the number of events we would observe in the thread's write buffer
383385 // memory. This is only used as a lower bound on the number of events the thread has attempted to
@@ -388,8 +390,8 @@ buffer_manager_init_sequence_point_thread_list (
388390 // underflow.
389391 uint32_t sequence_number = ep_thread_session_state_get_volatile_sequence_number (thread_session_state ) - 1 ;
390392
391- dn_umap_ptr_uint32_insert (ep_sequence_point_get_thread_sequence_numbers (sequence_point ), thread_session_state , sequence_number );
392- ep_thread_addref (ep_thread_holder_get_thread ( ep_thread_session_state_get_thread_holder_ref ( thread_session_state )) );
393+ dn_umap_ptr_uint32_insert (ep_sequence_point_get_thread_sequence_numbers (sequence_point ), thread , sequence_number );
394+ ep_thread_addref (thread );
393395 } DN_LIST_FOREACH_END ;
394396
395397 // This needs to come after querying the thread sequence numbers to ensure that any recorded
@@ -1166,17 +1168,18 @@ ep_buffer_manager_write_all_buffers_to_file_v4 (
11661168 EP_SPIN_LOCK_ENTER (& buffer_manager -> rt_lock , section2 )
11671169 for (dn_list_it_t it = dn_list_begin (buffer_manager -> thread_session_state_list ); !dn_list_it_end (it ); ) {
11681170 EventPipeThreadSessionState * session_state = * dn_list_it_data_t (it , EventPipeThreadSessionState * );
1169- dn_umap_it_t found = dn_umap_ptr_uint32_find (ep_sequence_point_get_thread_sequence_numbers (sequence_point ), session_state );
1171+ EventPipeThread * thread = ep_thread_session_state_get_thread (session_state );
1172+ dn_umap_it_t found = dn_umap_ptr_uint32_find (ep_sequence_point_get_thread_sequence_numbers (sequence_point ), thread );
11701173 uint32_t thread_sequence_number = !dn_umap_it_end (found ) ? dn_umap_it_value_uint32_t (found ) : 0 ;
11711174 uint32_t last_read_sequence_number = ep_thread_session_state_get_last_read_sequence_number (session_state );
11721175 // Sequence numbers can overflow so we can't use a direct last_read > sequence_number comparison
11731176 // If a thread is able to drop more than 0x80000000 events in between sequence points then we will
11741177 // miscategorize it, but that seems unlikely.
11751178 uint32_t last_read_delta = last_read_sequence_number - thread_sequence_number ;
11761179 if (0 < last_read_delta && last_read_delta < 0x80000000 ) {
1177- dn_umap_ptr_uint32_insert_or_assign (ep_sequence_point_get_thread_sequence_numbers (sequence_point ), session_state , last_read_sequence_number );
1180+ dn_umap_ptr_uint32_insert_or_assign (ep_sequence_point_get_thread_sequence_numbers (sequence_point ), thread , last_read_sequence_number );
11781181 if (dn_umap_it_end (found ))
1179- ep_thread_addref (ep_thread_holder_get_thread ( ep_thread_session_state_get_thread_holder_ref ( session_state )) );
1182+ ep_thread_addref (thread );
11801183 }
11811184
11821185 it = dn_list_it_next (it );
@@ -1214,11 +1217,12 @@ ep_buffer_manager_write_all_buffers_to_file_v4 (
12141217 DN_LIST_FOREACH_BEGIN (EventPipeSequencePoint * , current_sequence_point , buffer_manager -> sequence_points ) {
12151218 // foreach (session_state in session_states_to_delete)
12161219 DN_VECTOR_PTR_FOREACH_BEGIN (EventPipeThreadSessionState * , thread_session_state , & session_states_to_delete ) {
1217- dn_umap_it_t found = dn_umap_ptr_uint32_find (ep_sequence_point_get_thread_sequence_numbers (current_sequence_point ), thread_session_state );
1220+ EventPipeThread * thread = ep_thread_session_state_get_thread (thread_session_state );
1221+ dn_umap_it_t found = dn_umap_ptr_uint32_find (ep_sequence_point_get_thread_sequence_numbers (current_sequence_point ), thread );
12181222 if (!dn_umap_it_end (found )) {
12191223 dn_umap_erase (found );
12201224 // every entry of this map was holding an extra ref to the thread (see: ep-event-instance.{h|c})
1221- ep_thread_release (ep_thread_session_state_get_thread ( thread_session_state ) );
1225+ ep_thread_release (thread );
12221226 }
12231227 } DN_VECTOR_PTR_FOREACH_END ;
12241228 } DN_LIST_FOREACH_END ;
0 commit comments