@@ -476,7 +476,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
476
476
}
477
477
if timeout == 0 || !ready_list_empty {
478
478
// If the ready list is not empty, or the timeout is 0, we can return immediately.
479
- this . blocking_epoll_callback ( epfd_value, weak_epfd, dest, & event) ?;
479
+ blocking_epoll_callback ( epfd_value, weak_epfd, dest, & event, this ) ?;
480
480
} else {
481
481
// Blocking
482
482
let timeout = match timeout {
@@ -504,7 +504,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
504
504
event: MPlaceTy <' tcx>,
505
505
}
506
506
@unblock = |this| {
507
- this . blocking_epoll_callback( epfd_value, weak_epfd, & dest, & event) ?;
507
+ blocking_epoll_callback( epfd_value, weak_epfd, & dest, & event, this ) ?;
508
508
Ok ( ( ) )
509
509
}
510
510
@timeout = |this| {
@@ -526,47 +526,6 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
526
526
Ok ( ( ) )
527
527
}
528
528
529
- /// Callback function after epoll_wait unblocks
530
- fn blocking_epoll_callback (
531
- & mut self ,
532
- epfd_value : i32 ,
533
- weak_epfd : WeakFileDescriptionRef ,
534
- dest : & MPlaceTy < ' tcx > ,
535
- events : & MPlaceTy < ' tcx > ,
536
- ) -> InterpResult < ' tcx > {
537
- let this = self . eval_context_mut ( ) ;
538
-
539
- let Some ( epfd) = weak_epfd. upgrade ( ) else {
540
- throw_unsup_format ! ( "epoll FD {epfd_value} got closed while blocking." )
541
- } ;
542
-
543
- let epoll_file_description = epfd
544
- . downcast :: < Epoll > ( )
545
- . ok_or_else ( || err_unsup_format ! ( "non-epoll FD passed to `epoll_wait`" ) ) ?;
546
-
547
- let ready_list = epoll_file_description. get_ready_list ( ) ;
548
- let mut ready_list = ready_list. borrow_mut ( ) ;
549
- let mut num_of_events: i32 = 0 ;
550
- let mut array_iter = this. project_array_fields ( events) ?;
551
-
552
- while let Some ( des) = array_iter. next ( this) ? {
553
- if let Some ( epoll_event_instance) = ready_list_next ( this, & mut ready_list) {
554
- this. write_int_fields_named (
555
- & [
556
- ( "events" , epoll_event_instance. events . into ( ) ) ,
557
- ( "u64" , epoll_event_instance. data . into ( ) ) ,
558
- ] ,
559
- & des. 1 ,
560
- ) ?;
561
- num_of_events = num_of_events. strict_add ( 1 ) ;
562
- } else {
563
- break ;
564
- }
565
- }
566
- this. write_int ( num_of_events, dest) ?;
567
- Ok ( ( ) )
568
- }
569
-
570
529
/// For a specific file description, get its ready events and update the corresponding ready
571
530
/// list. This function should be called whenever an event causes more bytes or an EOF to become
572
531
/// newly readable from an FD, and whenever more bytes can be written to an FD or no more future
@@ -665,3 +624,42 @@ fn check_and_update_one_event_interest<'tcx>(
665
624
}
666
625
return Ok ( false ) ;
667
626
}
627
+
628
+ /// Callback function after epoll_wait unblocks
629
+ fn blocking_epoll_callback < ' tcx > (
630
+ epfd_value : i32 ,
631
+ weak_epfd : WeakFileDescriptionRef ,
632
+ dest : & MPlaceTy < ' tcx > ,
633
+ events : & MPlaceTy < ' tcx > ,
634
+ ecx : & mut MiriInterpCx < ' tcx > ,
635
+ ) -> InterpResult < ' tcx > {
636
+ let Some ( epfd) = weak_epfd. upgrade ( ) else {
637
+ throw_unsup_format ! ( "epoll FD {epfd_value} got closed while blocking." )
638
+ } ;
639
+
640
+ let epoll_file_description = epfd
641
+ . downcast :: < Epoll > ( )
642
+ . ok_or_else ( || err_unsup_format ! ( "non-epoll FD passed to `epoll_wait`" ) ) ?;
643
+
644
+ let ready_list = epoll_file_description. get_ready_list ( ) ;
645
+ let mut ready_list = ready_list. borrow_mut ( ) ;
646
+ let mut num_of_events: i32 = 0 ;
647
+ let mut array_iter = ecx. project_array_fields ( events) ?;
648
+
649
+ while let Some ( des) = array_iter. next ( ecx) ? {
650
+ if let Some ( epoll_event_instance) = ready_list_next ( ecx, & mut ready_list) {
651
+ ecx. write_int_fields_named (
652
+ & [
653
+ ( "events" , epoll_event_instance. events . into ( ) ) ,
654
+ ( "u64" , epoll_event_instance. data . into ( ) ) ,
655
+ ] ,
656
+ & des. 1 ,
657
+ ) ?;
658
+ num_of_events = num_of_events. strict_add ( 1 ) ;
659
+ } else {
660
+ break ;
661
+ }
662
+ }
663
+ ecx. write_int ( num_of_events, dest) ?;
664
+ Ok ( ( ) )
665
+ }
0 commit comments