From 82c39ffda785753d90d1d1b98537e7b9d2d889b3 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Fri, 16 Aug 2024 12:15:07 +0200 Subject: [PATCH] buf_has_writer is not needed any more --- src/tools/miri/src/shims/unix/socket.rs | 14 +++----------- 1 file 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, 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::().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 {