@@ -17,13 +17,13 @@ use crate::{concurrency::VClock, *};
1717/// be configured in the real system.
1818const MAX_SOCKETPAIR_BUFFER_CAPACITY : usize = 212992 ;
1919
20- /// Pair of connected sockets.
20+ /// One end of a pair of connected unnamed sockets.
2121#[ derive( Debug ) ]
22- struct SocketPair {
22+ struct AnonSocket {
2323 /// The buffer we are reading from, or `None` if this is the writing end of a pipe.
2424 /// (In that case, the peer FD will be the reading end of that pipe.)
2525 readbuf : Option < RefCell < Buffer > > ,
26- /// The `SocketPair ` file descriptor that is our "peer", and that holds the buffer we are
26+ /// The `AnonSocket ` file descriptor that is our "peer", and that holds the buffer we are
2727 /// writing to. This is a weak reference because the other side may be closed before us; all
2828 /// future writes will then trigger EPIPE.
2929 peer_fd : OnceCell < WeakFileDescriptionRef > ,
@@ -42,13 +42,13 @@ impl Buffer {
4242 }
4343}
4444
45- impl SocketPair {
45+ impl AnonSocket {
4646 fn peer_fd ( & self ) -> & WeakFileDescriptionRef {
4747 self . peer_fd . get ( ) . unwrap ( )
4848 }
4949}
5050
51- impl FileDescription for SocketPair {
51+ impl FileDescription for AnonSocket {
5252 fn name ( & self ) -> & ' static str {
5353 "socketpair"
5454 }
@@ -71,7 +71,7 @@ impl FileDescription for SocketPair {
7171
7272 // Check if is writable.
7373 if let Some ( peer_fd) = self . peer_fd ( ) . upgrade ( ) {
74- if let Some ( writebuf) = & peer_fd. downcast :: < SocketPair > ( ) . unwrap ( ) . readbuf {
74+ if let Some ( writebuf) = & peer_fd. downcast :: < AnonSocket > ( ) . unwrap ( ) . readbuf {
7575 let data_size = writebuf. borrow ( ) . buf . len ( ) ;
7676 let available_space = MAX_SOCKETPAIR_BUFFER_CAPACITY . strict_sub ( data_size) ;
7777 if available_space != 0 {
@@ -195,7 +195,7 @@ impl FileDescription for SocketPair {
195195 return Ok ( Err ( Error :: from ( ErrorKind :: BrokenPipe ) ) ) ;
196196 } ;
197197
198- let Some ( writebuf) = & peer_fd. downcast :: < SocketPair > ( ) . unwrap ( ) . readbuf else {
198+ let Some ( writebuf) = & peer_fd. downcast :: < AnonSocket > ( ) . unwrap ( ) . readbuf else {
199199 // FIXME: This should return EBADF, but there's no nice way to do that as there's no
200200 // corresponding ErrorKind variant.
201201 throw_unsup_format ! ( "writing to the reading end of a pipe" ) ;
@@ -287,20 +287,20 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
287287
288288 // Generate file descriptions.
289289 let fds = & mut this. machine . fds ;
290- let fd0 = fds. new_ref ( SocketPair {
290+ let fd0 = fds. new_ref ( AnonSocket {
291291 readbuf : Some ( RefCell :: new ( Buffer :: new ( ) ) ) ,
292292 peer_fd : OnceCell :: new ( ) ,
293293 is_nonblock : is_sock_nonblock,
294294 } ) ;
295- let fd1 = fds. new_ref ( SocketPair {
295+ let fd1 = fds. new_ref ( AnonSocket {
296296 readbuf : Some ( RefCell :: new ( Buffer :: new ( ) ) ) ,
297297 peer_fd : OnceCell :: new ( ) ,
298298 is_nonblock : is_sock_nonblock,
299299 } ) ;
300300
301301 // Make the file descriptions point to each other.
302- fd0. downcast :: < SocketPair > ( ) . unwrap ( ) . peer_fd . set ( fd1. downgrade ( ) ) . unwrap ( ) ;
303- fd1. downcast :: < SocketPair > ( ) . unwrap ( ) . peer_fd . set ( fd0. downgrade ( ) ) . unwrap ( ) ;
302+ fd0. downcast :: < AnonSocket > ( ) . unwrap ( ) . peer_fd . set ( fd1. downgrade ( ) ) . unwrap ( ) ;
303+ fd1. downcast :: < AnonSocket > ( ) . unwrap ( ) . peer_fd . set ( fd0. downgrade ( ) ) . unwrap ( ) ;
304304
305305 // Insert the file description to the fd table, generating the file descriptors.
306306 let sv0 = fds. insert ( fd0) ;
@@ -337,17 +337,17 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
337337 // Generate file descriptions.
338338 // pipefd[0] refers to the read end of the pipe.
339339 let fds = & mut this. machine . fds ;
340- let fd0 = fds. new_ref ( SocketPair {
340+ let fd0 = fds. new_ref ( AnonSocket {
341341 readbuf : Some ( RefCell :: new ( Buffer :: new ( ) ) ) ,
342342 peer_fd : OnceCell :: new ( ) ,
343343 is_nonblock : false ,
344344 } ) ;
345345 let fd1 =
346- fds. new_ref ( SocketPair { readbuf : None , peer_fd : OnceCell :: new ( ) , is_nonblock : false } ) ;
346+ fds. new_ref ( AnonSocket { readbuf : None , peer_fd : OnceCell :: new ( ) , is_nonblock : false } ) ;
347347
348348 // Make the file descriptions point to each other.
349- fd0. downcast :: < SocketPair > ( ) . unwrap ( ) . peer_fd . set ( fd1. downgrade ( ) ) . unwrap ( ) ;
350- fd1. downcast :: < SocketPair > ( ) . unwrap ( ) . peer_fd . set ( fd0. downgrade ( ) ) . unwrap ( ) ;
349+ fd0. downcast :: < AnonSocket > ( ) . unwrap ( ) . peer_fd . set ( fd1. downgrade ( ) ) . unwrap ( ) ;
350+ fd1. downcast :: < AnonSocket > ( ) . unwrap ( ) . peer_fd . set ( fd0. downgrade ( ) ) . unwrap ( ) ;
351351
352352 // Insert the file description to the fd table, generating the file descriptors.
353353 let pipefd0 = fds. insert ( fd0) ;
0 commit comments