@@ -32,11 +32,13 @@ pub struct EpollEventInstance {
3232 events : u32 ,
3333 /// Original data retrieved from `epoll_event` during `epoll_ctl`.
3434 data : u64 ,
35+ /// The release clock associated with this event.
36+ clock : VClock ,
3537}
3638
3739impl EpollEventInstance {
3840 pub fn new ( events : u32 , data : u64 ) -> EpollEventInstance {
39- EpollEventInstance { events, data }
41+ EpollEventInstance { events, data, clock : Default :: default ( ) }
4042 }
4143}
4244
@@ -92,7 +94,6 @@ pub struct EpollReadyEvents {
9294#[ derive( Debug , Default ) ]
9395struct ReadyList {
9496 mapping : RefCell < BTreeMap < ( FdId , i32 ) , EpollEventInstance > > ,
95- clock : RefCell < VClock > ,
9697}
9798
9899impl EpollReadyEvents {
@@ -567,11 +568,6 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
567568
568569 let epoll = epfd. downcast :: < Epoll > ( ) . unwrap ( ) ;
569570
570- // Synchronize running thread to the epoll ready list.
571- this. release_clock ( |clock| {
572- epoll. ready_list . clock . borrow_mut ( ) . join ( clock) ;
573- } ) ;
574-
575571 if let Some ( thread_id) = epoll. thread_id . borrow_mut ( ) . pop ( ) {
576572 waiter. push ( thread_id) ;
577573 } ;
@@ -627,7 +623,11 @@ fn check_and_update_one_event_interest<'tcx>(
627623 if flags != 0 {
628624 let epoll_key = ( id, epoll_event_interest. fd_num ) ;
629625 let ready_list = & mut epoll_event_interest. ready_list . mapping . borrow_mut ( ) ;
630- let event_instance = EpollEventInstance :: new ( flags, epoll_event_interest. data ) ;
626+ let mut event_instance = EpollEventInstance :: new ( flags, epoll_event_interest. data ) ;
627+ // If we are tracking data races, remember the current clock so we can sync with it later.
628+ ecx. release_clock ( |clock| {
629+ event_instance. clock . join ( clock) ;
630+ } ) ;
631631 // Triggers the notification by inserting it to the ready list.
632632 ready_list. insert ( epoll_key, event_instance) ;
633633 interp_ok ( true )
@@ -654,9 +654,6 @@ fn blocking_epoll_callback<'tcx>(
654654
655655 let ready_list = epoll_file_description. get_ready_list ( ) ;
656656
657- // Synchronize waking thread from the epoll ready list.
658- ecx. acquire_clock ( & ready_list. clock . borrow ( ) ) ;
659-
660657 let mut ready_list = ready_list. mapping . borrow_mut ( ) ;
661658 let mut num_of_events: i32 = 0 ;
662659 let mut array_iter = ecx. project_array_fields ( events) ?;
@@ -670,6 +667,9 @@ fn blocking_epoll_callback<'tcx>(
670667 ] ,
671668 & des. 1 ,
672669 ) ?;
670+ // Synchronize waking thread with the event of interest.
671+ ecx. acquire_clock ( & epoll_event_instance. clock ) ;
672+
673673 num_of_events = num_of_events. strict_add ( 1 ) ;
674674 } else {
675675 break ;
0 commit comments