@@ -32,11 +32,13 @@ pub struct EpollEventInstance {
32
32
events : u32 ,
33
33
/// Original data retrieved from `epoll_event` during `epoll_ctl`.
34
34
data : u64 ,
35
+ /// The release clock associated with this event.
36
+ clock : VClock ,
35
37
}
36
38
37
39
impl EpollEventInstance {
38
40
pub fn new ( events : u32 , data : u64 ) -> EpollEventInstance {
39
- EpollEventInstance { events, data }
41
+ EpollEventInstance { events, data, clock : Default :: default ( ) }
40
42
}
41
43
}
42
44
@@ -92,7 +94,6 @@ pub struct EpollReadyEvents {
92
94
#[ derive( Debug , Default ) ]
93
95
struct ReadyList {
94
96
mapping : RefCell < BTreeMap < ( FdId , i32 ) , EpollEventInstance > > ,
95
- clock : RefCell < VClock > ,
96
97
}
97
98
98
99
impl EpollReadyEvents {
@@ -567,11 +568,6 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
567
568
568
569
let epoll = epfd. downcast :: < Epoll > ( ) . unwrap ( ) ;
569
570
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
-
575
571
if let Some ( thread_id) = epoll. thread_id . borrow_mut ( ) . pop ( ) {
576
572
waiter. push ( thread_id) ;
577
573
} ;
@@ -627,7 +623,11 @@ fn check_and_update_one_event_interest<'tcx>(
627
623
if flags != 0 {
628
624
let epoll_key = ( id, epoll_event_interest. fd_num ) ;
629
625
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
+ } ) ;
631
631
// Triggers the notification by inserting it to the ready list.
632
632
ready_list. insert ( epoll_key, event_instance) ;
633
633
interp_ok ( true )
@@ -654,9 +654,6 @@ fn blocking_epoll_callback<'tcx>(
654
654
655
655
let ready_list = epoll_file_description. get_ready_list ( ) ;
656
656
657
- // Synchronize waking thread from the epoll ready list.
658
- ecx. acquire_clock ( & ready_list. clock . borrow ( ) ) ;
659
-
660
657
let mut ready_list = ready_list. mapping . borrow_mut ( ) ;
661
658
let mut num_of_events: i32 = 0 ;
662
659
let mut array_iter = ecx. project_array_fields ( events) ?;
@@ -670,6 +667,9 @@ fn blocking_epoll_callback<'tcx>(
670
667
] ,
671
668
& des. 1 ,
672
669
) ?;
670
+ // Synchronize waking thread with the event of interest.
671
+ ecx. acquire_clock ( & epoll_event_instance. clock ) ;
672
+
673
673
num_of_events = num_of_events. strict_add ( 1 ) ;
674
674
} else {
675
675
break ;
0 commit comments