@@ -29,15 +29,11 @@ struct SocketPair {
29
29
struct Buffer {
30
30
buf : VecDeque < u8 > ,
31
31
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 ,
36
32
}
37
33
38
34
impl Buffer {
39
35
fn new ( ) -> Self {
40
- Buffer { buf : VecDeque :: new ( ) , clock : VClock :: default ( ) , buf_has_writer : true }
36
+ Buffer { buf : VecDeque :: new ( ) , clock : VClock :: default ( ) }
41
37
}
42
38
}
43
39
@@ -90,10 +86,6 @@ impl FileDescription for SocketPair {
90
86
ecx : & mut MiriInterpCx < ' tcx > ,
91
87
) -> InterpResult < ' tcx , io:: Result < ( ) > > {
92
88
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
-
97
89
// Notify peer fd that closed has happened.
98
90
// When any of the events happened, we check and update the status of all supported events
99
91
// types of peer fd.
@@ -118,8 +110,8 @@ impl FileDescription for SocketPair {
118
110
119
111
let mut readbuf = self . readbuf . borrow_mut ( ) ;
120
112
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.
123
115
// 0 bytes successfully read indicates end-of-file.
124
116
return Ok ( Ok ( 0 ) ) ;
125
117
} else {
0 commit comments