@@ -284,10 +284,13 @@ static int s_aws_s3_mmap_part_streaming_input_stream_read(struct aws_input_strea
284284 /* Map the content */
285285 size_t read_length = aws_min_size (dest -> capacity - dest -> len , impl -> total_length - impl -> total_length_read );
286286 uint64_t time = 0 ;
287+
288+ aws_s3_meta_request_lock_synced_data (impl -> meta_request );
287289 if (impl -> request -> send_data .metrics -> time_metrics .body_read_start_timestamp_ns == -1 ) {
288290 aws_high_res_clock_get_ticks (& time );
289291 impl -> request -> send_data .metrics -> time_metrics .body_read_start_timestamp_ns = time ;
290292 }
293+ aws_s3_meta_request_unlock_synced_data (impl -> meta_request );
291294 aws_high_res_clock_get_ticks (& impl -> metrics .start_timestamp );
292295 impl -> metrics .thread_id = aws_thread_current_thread_id ();
293296
@@ -333,15 +336,15 @@ static int s_aws_s3_mmap_part_streaming_input_stream_read(struct aws_input_strea
333336 impl -> total_length_read += read_length ;
334337 aws_high_res_clock_get_ticks (& impl -> metrics .end_timestamp );
335338 int64_t duration = impl -> metrics .end_timestamp - impl -> metrics .start_timestamp ;
339+
340+ /* BEGIN CRITICAL SECTION */
341+ aws_s3_meta_request_lock_synced_data (impl -> meta_request );
342+ aws_array_list_push_back (& impl -> meta_request -> read_metrics_list , & impl -> metrics );
336343 if (impl -> request -> send_data .metrics -> time_metrics .body_read_total_ns == -1 ) {
337344 impl -> request -> send_data .metrics -> time_metrics .body_read_total_ns = duration ;
338345 } else {
339346 impl -> request -> send_data .metrics -> time_metrics .body_read_total_ns += duration ;
340347 }
341-
342- /* BEGIN CRITICAL SECTION */
343- aws_s3_meta_request_lock_synced_data (impl -> meta_request );
344- aws_array_list_push_back (& impl -> meta_request -> read_metrics_list , & impl -> metrics );
345348 aws_s3_meta_request_unlock_synced_data (impl -> meta_request );
346349 /* END CRITICAL SECTION */
347350 if (impl -> in_chunk_offset == impl -> reading_chunk_buf -> len ) {
@@ -352,13 +355,15 @@ static int s_aws_s3_mmap_part_streaming_input_stream_read(struct aws_input_strea
352355 /* We reached the end of the stream. */
353356 impl -> eos_reached = true;
354357 AWS_ASSERT (impl -> total_length_read == impl -> total_length );
358+ aws_s3_meta_request_lock_synced_data (impl -> meta_request );
355359 if (impl -> request -> send_data .metrics -> time_metrics .body_read_end_timestamp_ns == -1 ) {
356360 aws_high_res_clock_get_ticks (& time );
357361 impl -> request -> send_data .metrics -> time_metrics .body_read_end_timestamp_ns = time ;
358362 }
359363 impl -> request -> send_data .metrics -> time_metrics .body_read_duration_ns =
360364 impl -> request -> send_data .metrics -> time_metrics .body_read_end_timestamp_ns -
361365 impl -> request -> send_data .metrics -> time_metrics .body_read_start_timestamp_ns ;
366+ aws_s3_meta_request_unlock_synced_data (impl -> meta_request );
362367 }
363368 }
364369
0 commit comments