diff options
| author | Ralf Jung <post@ralfj.de> | 2024-08-16 12:15:07 +0200 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2024-08-16 16:18:59 +0200 |
| commit | 82c39ffda785753d90d1d1b98537e7b9d2d889b3 (patch) | |
| tree | 869c1b51da498c8d2036075c44184322dd75980c | |
| parent | 17cfbc6fa37b7b82a4b4f2fb1637082fec2967ad (diff) | |
| download | rust-82c39ffda785753d90d1d1b98537e7b9d2d889b3.tar.gz rust-82c39ffda785753d90d1d1b98537e7b9d2d889b3.zip | |
buf_has_writer is not needed any more
| -rw-r--r-- | src/tools/miri/src/shims/unix/socket.rs | 14 |
1 files changed, 3 insertions, 11 deletions
diff --git a/src/tools/miri/src/shims/unix/socket.rs b/src/tools/miri/src/shims/unix/socket.rs index 2694391dfbb..fba63890dd2 100644 --- a/src/tools/miri/src/shims/unix/socket.rs +++ b/src/tools/miri/src/shims/unix/socket.rs @@ -29,15 +29,11 @@ struct SocketPair { struct Buffer { buf: VecDeque<u8>, clock: VClock, - /// Indicates if there is at least one active writer to this buffer. - /// If all writers of this buffer are dropped, buf_has_writer becomes false and we - /// indicate EOF instead of blocking. - buf_has_writer: bool, } impl Buffer { fn new() -> Self { - Buffer { buf: VecDeque::new(), clock: VClock::default(), buf_has_writer: true } + Buffer { buf: VecDeque::new(), clock: VClock::default() } } } @@ -90,10 +86,6 @@ impl FileDescription for SocketPair { ecx: &mut MiriInterpCx<'tcx>, ) -> InterpResult<'tcx, io::Result<()>> { if let Some(peer_fd) = self.peer_fd().upgrade() { - // This is used to signal socketfd of other side that there is no writer to its readbuf. - // If the upgrade fails, there is no need to update as all read ends have been dropped. - peer_fd.downcast::<SocketPair>().unwrap().readbuf.borrow_mut().buf_has_writer = false; - // Notify peer fd that closed has happened. // When any of the events happened, we check and update the status of all supported events // types of peer fd. @@ -118,8 +110,8 @@ impl FileDescription for SocketPair { let mut readbuf = self.readbuf.borrow_mut(); if readbuf.buf.is_empty() { - if !readbuf.buf_has_writer { - // Socketpair with no writer and empty buffer. + if self.peer_fd().upgrade().is_none() { + // Socketpair with no peer and empty buffer. // 0 bytes successfully read indicates end-of-file. return Ok(Ok(0)); } else { |
