@@ -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
@@ -88,10 +84,6 @@ impl FileDescription for SocketPair {
8884 ecx : & mut MiriInterpCx < ' tcx > ,
8985 ) -> InterpResult < ' tcx , io:: Result < ( ) > > {
9086 if let Some ( peer_fd) = self . peer_fd ( ) . upgrade ( ) {
91- // This is used to signal socketfd of other side that there is no writer to its readbuf.
92- // If the upgrade fails, there is no need to update as all read ends have been dropped.
93- peer_fd. downcast :: < SocketPair > ( ) . unwrap ( ) . readbuf . borrow_mut ( ) . buf_has_writer = false ;
94-
9587 // Notify peer fd that closed has happened.
9688 // When any of the events happened, we check and update the status of all supported events
9789 // types of peer fd.
@@ -116,8 +108,8 @@ impl FileDescription for SocketPair {
116108
117109 let mut readbuf = self . readbuf . borrow_mut ( ) ;
118110 if readbuf. buf . is_empty ( ) {
119- if !readbuf . buf_has_writer {
120- // Socketpair with no writer and empty buffer.
111+ if self . peer_fd ( ) . upgrade ( ) . is_none ( ) {
112+ // Socketpair with no peer and empty buffer.
121113 // 0 bytes successfully read indicates end-of-file.
122114 return Ok ( Ok ( 0 ) ) ;
123115 } else {
0 commit comments