@@ -29,15 +29,11 @@ struct SocketPair {
2929struct Buffer {
3030 buf : VecDeque < u8 > ,
3131 clock : VClock ,
32- /// Indicates if there is at least one active writer to this buffer.
33- /// If all writers of this buffer are dropped, buf_has_writer becomes false and we
34- /// indicate EOF instead of blocking.
35- buf_has_writer : bool ,
3632}
3733
3834impl Buffer {
3935 fn new ( ) -> Self {
40- Buffer { buf : VecDeque :: new ( ) , clock : VClock :: default ( ) , buf_has_writer : true }
36+ Buffer { buf : VecDeque :: new ( ) , clock : VClock :: default ( ) }
4137 }
4238}
4339
@@ -90,10 +86,6 @@ impl FileDescription for SocketPair {
9086 ecx : & mut MiriInterpCx < ' tcx > ,
9187 ) -> InterpResult < ' tcx , io:: Result < ( ) > > {
9288 if let Some ( peer_fd) = self . peer_fd ( ) . upgrade ( ) {
93- // This is used to signal socketfd of other side that there is no writer to its readbuf.
94- // If the upgrade fails, there is no need to update as all read ends have been dropped.
95- peer_fd. downcast :: < SocketPair > ( ) . unwrap ( ) . readbuf . borrow_mut ( ) . buf_has_writer = false ;
96-
9789 // Notify peer fd that closed has happened.
9890 // When any of the events happened, we check and update the status of all supported events
9991 // types of peer fd.
@@ -118,8 +110,8 @@ impl FileDescription for SocketPair {
118110
119111 let mut readbuf = self . readbuf . borrow_mut ( ) ;
120112 if readbuf. buf . is_empty ( ) {
121- if !readbuf . buf_has_writer {
122- // Socketpair with no writer and empty buffer.
113+ if self . peer_fd ( ) . upgrade ( ) . is_none ( ) {
114+ // Socketpair with no peer and empty buffer.
123115 // 0 bytes successfully read indicates end-of-file.
124116 return Ok ( Ok ( 0 ) ) ;
125117 } else {
0 commit comments