@@ -5,7 +5,6 @@ use std::io::{Error, ErrorKind, Read};
55use std:: rc:: { Rc , Weak } ;
66
77use crate :: shims:: unix:: fd:: WeakFileDescriptor ;
8- use crate :: shims:: unix:: linux:: epoll:: EpollReturn ;
98use crate :: shims:: unix:: * ;
109use crate :: { concurrency:: VClock , * } ;
1110
@@ -38,28 +37,6 @@ impl SocketPair {
3837 fn peer_is_closed ( & mut self ) {
3938 self . peer_closed = true ;
4039 }
41-
42- /// Functions to update the ready list of an epoll_event.
43- fn update_readiness ( & self , ready_flags : Vec < u32 > , epoll_events : & Vec < Weak < EpollEvent > > ) {
44- for event in epoll_events {
45- // If the current epoll_event contains the flag that is signaled as ready, we add/update
46- // the epoll_return entry in the ready list.
47- if let Some ( epoll_event) = event. upgrade ( ) {
48- if let Some ( flags) = epoll_event. contains_flag ( & ready_flags) {
49- let weak_file_descriptor = epoll_event. weak_file_descriptor . clone ( ) ;
50- let epoll_key = ( weak_file_descriptor, epoll_event. file_descriptor ) ;
51- // Retrieve the epoll return if it is already in the return list.
52- let ready_list = & mut epoll_event. ready_list . borrow_mut ( ) ;
53- // Add a new epoll entry if it doesn't exist, or update the event mask if it exists.
54- let epoll_return = EpollReturn :: new ( flags, epoll_event. data ) ;
55- let epoll_entry = ready_list. entry ( epoll_key) . or_insert ( epoll_return) ;
56- // The update here is bitwise or, so it will still be correct if we try to add
57- // a flag that already exists.
58- epoll_entry. update_events ( flags) ;
59- }
60- }
61- }
62- }
6340}
6441
6542#[ derive( Debug ) ]
@@ -109,11 +86,17 @@ impl FileDescription for SocketPair {
10986 }
11087 }
11188
89+ // Check if the peer_fd closed
90+ if self . peer_closed {
91+ ready_flags. push ( epollrdhup) ;
92+ }
93+
11294 Ok ( ready_flags)
11395 }
11496
11597 fn close < ' tcx > (
11698 self : Box < Self > ,
99+ ecx : & mut MiriInterpCx < ' tcx > ,
117100 _communicate_allowed : bool ,
118101 ) -> InterpResult < ' tcx , io:: Result < ( ) > > {
119102 // This is used to signal socketfd of other side that there is no writer to its readbuf.
@@ -129,12 +112,11 @@ impl FileDescription for SocketPair {
129112 let peer_socketpair = binding. downcast_mut :: < SocketPair > ( ) . unwrap ( ) ;
130113 peer_socketpair. peer_is_closed ( ) ;
131114 // When any of the event is happened, we check and update the status of all supported flags.
132- // peer_socketpair
133- // .check_readiness(ecx)
134- // .map(|events| ecx.update_readiness(events, self.return_epoll_events()?))??;
115+ peer_socketpair
116+ . check_readiness ( ecx)
117+ . map ( |events| ecx. update_readiness ( events, self . return_epoll_events ( ) ?) ) ??;
135118 }
136119 }
137- // TODO: invoke check readiness from other side
138120 Ok ( Ok ( ( ) ) )
139121 }
140122
@@ -182,7 +164,7 @@ impl FileDescription for SocketPair {
182164 let actual_read_size = readbuf. buf . read ( bytes) . unwrap ( ) ;
183165 // When any of the event is happened, we check and update the status of all supported flags.
184166 self . check_readiness ( ecx)
185- . map ( |events| self . update_readiness ( events, self . return_epoll_events ( ) . unwrap ( ) ) ) ?;
167+ . map ( |events| ecx . update_readiness ( events, self . return_epoll_events ( ) ? ) ) ? ?;
186168 return Ok ( Ok ( actual_read_size) ) ;
187169 }
188170
@@ -225,7 +207,7 @@ impl FileDescription for SocketPair {
225207 writebuf. buf . extend ( & bytes[ ..actual_write_size] ) ;
226208 // When any of the event is happened, we check and update the status of all supported flags.
227209 self . check_readiness ( ecx)
228- . map ( |events| self . update_readiness ( events, self . return_epoll_events ( ) . unwrap ( ) ) ) ?;
210+ . map ( |events| ecx . update_readiness ( events, self . return_epoll_events ( ) ? ) ) ? ?;
229211 return Ok ( Ok ( actual_write_size) ) ;
230212 }
231213}
0 commit comments