@@ -14,7 +14,7 @@ use crate::*;
1414
1515/// A unique id for file descriptions. While we could use the address, considering that
1616/// is definitely unique, the address would expose interpreter internal state when used
17- /// for sorting things. So instead we generate a unique id per file description is the name
17+ /// for sorting things. So instead we generate a unique id per file description which is the same
1818/// for all `dup`licates and is never reused.
1919#[ derive( Debug , Copy , Clone , Default , Eq , PartialEq , Ord , PartialOrd ) ]
2020pub struct FdId ( usize ) ;
@@ -107,10 +107,10 @@ impl<T: FileDescription + 'static> FileDescriptionExt for T {
107107 ) -> InterpResult < ' tcx , io:: Result < ( ) > > {
108108 match Rc :: into_inner ( self . 0 ) {
109109 Some ( fd) => {
110- // Remove entry from the global epoll_event_interest table .
111- ecx. machine . epoll_interests . remove ( fd. id ) ;
110+ // There might have been epolls interested in this FD. Remove that .
111+ ecx. machine . epoll_interests . remove_epolls ( fd. id ) ;
112112
113- fd. inner . close ( communicate_allowed, ecx)
113+ fd. inner . destroy ( fd . id , communicate_allowed, ecx)
114114 }
115115 None => {
116116 // Not the last reference.
@@ -183,9 +183,12 @@ pub trait FileDescription: std::fmt::Debug + FileDescriptionExt {
183183 throw_unsup_format ! ( "cannot seek on {}" , self . name( ) ) ;
184184 }
185185
186- /// Close the file descriptor.
187- fn close < ' tcx > (
186+ /// Destroys the file description. Only called when the last duplicate file descriptor is closed.
187+ ///
188+ /// `self_addr` is the address that this file description used to be stored at.
189+ fn destroy < ' tcx > (
188190 self ,
191+ _self_id : FdId ,
189192 _communicate_allowed : bool ,
190193 _ecx : & mut MiriInterpCx < ' tcx > ,
191194 ) -> InterpResult < ' tcx , io:: Result < ( ) > >
@@ -362,8 +365,9 @@ impl FileDescription for FileHandle {
362365 interp_ok ( ( & mut & self . file ) . seek ( offset) )
363366 }
364367
365- fn close < ' tcx > (
368+ fn destroy < ' tcx > (
366369 self ,
370+ _self_id : FdId ,
367371 communicate_allowed : bool ,
368372 _ecx : & mut MiriInterpCx < ' tcx > ,
369373 ) -> InterpResult < ' tcx , io:: Result < ( ) > > {
0 commit comments