@@ -17,13 +17,13 @@ use crate::{concurrency::VClock, *};
17
17
/// be configured in the real system.
18
18
const MAX_SOCKETPAIR_BUFFER_CAPACITY : usize = 212992 ;
19
19
20
- /// Pair of connected sockets.
20
+ /// One end of a pair of connected unnamed sockets.
21
21
#[ derive( Debug ) ]
22
- struct SocketPair {
22
+ struct AnonSocket {
23
23
/// The buffer we are reading from, or `None` if this is the writing end of a pipe.
24
24
/// (In that case, the peer FD will be the reading end of that pipe.)
25
25
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
27
27
/// writing to. This is a weak reference because the other side may be closed before us; all
28
28
/// future writes will then trigger EPIPE.
29
29
peer_fd : OnceCell < WeakFileDescriptionRef > ,
@@ -42,13 +42,13 @@ impl Buffer {
42
42
}
43
43
}
44
44
45
- impl SocketPair {
45
+ impl AnonSocket {
46
46
fn peer_fd ( & self ) -> & WeakFileDescriptionRef {
47
47
self . peer_fd . get ( ) . unwrap ( )
48
48
}
49
49
}
50
50
51
- impl FileDescription for SocketPair {
51
+ impl FileDescription for AnonSocket {
52
52
fn name ( & self ) -> & ' static str {
53
53
"socketpair"
54
54
}
@@ -71,7 +71,7 @@ impl FileDescription for SocketPair {
71
71
72
72
// Check if is writable.
73
73
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 {
75
75
let data_size = writebuf. borrow ( ) . buf . len ( ) ;
76
76
let available_space = MAX_SOCKETPAIR_BUFFER_CAPACITY . strict_sub ( data_size) ;
77
77
if available_space != 0 {
@@ -195,7 +195,7 @@ impl FileDescription for SocketPair {
195
195
return Ok ( Err ( Error :: from ( ErrorKind :: BrokenPipe ) ) ) ;
196
196
} ;
197
197
198
- let Some ( writebuf) = & peer_fd. downcast :: < SocketPair > ( ) . unwrap ( ) . readbuf else {
198
+ let Some ( writebuf) = & peer_fd. downcast :: < AnonSocket > ( ) . unwrap ( ) . readbuf else {
199
199
// FIXME: This should return EBADF, but there's no nice way to do that as there's no
200
200
// corresponding ErrorKind variant.
201
201
throw_unsup_format ! ( "writing to the reading end of a pipe" ) ;
@@ -287,20 +287,20 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
287
287
288
288
// Generate file descriptions.
289
289
let fds = & mut this. machine . fds ;
290
- let fd0 = fds. new_ref ( SocketPair {
290
+ let fd0 = fds. new_ref ( AnonSocket {
291
291
readbuf : Some ( RefCell :: new ( Buffer :: new ( ) ) ) ,
292
292
peer_fd : OnceCell :: new ( ) ,
293
293
is_nonblock : is_sock_nonblock,
294
294
} ) ;
295
- let fd1 = fds. new_ref ( SocketPair {
295
+ let fd1 = fds. new_ref ( AnonSocket {
296
296
readbuf : Some ( RefCell :: new ( Buffer :: new ( ) ) ) ,
297
297
peer_fd : OnceCell :: new ( ) ,
298
298
is_nonblock : is_sock_nonblock,
299
299
} ) ;
300
300
301
301
// 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 ( ) ;
304
304
305
305
// Insert the file description to the fd table, generating the file descriptors.
306
306
let sv0 = fds. insert ( fd0) ;
@@ -337,17 +337,17 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
337
337
// Generate file descriptions.
338
338
// pipefd[0] refers to the read end of the pipe.
339
339
let fds = & mut this. machine . fds ;
340
- let fd0 = fds. new_ref ( SocketPair {
340
+ let fd0 = fds. new_ref ( AnonSocket {
341
341
readbuf : Some ( RefCell :: new ( Buffer :: new ( ) ) ) ,
342
342
peer_fd : OnceCell :: new ( ) ,
343
343
is_nonblock : false ,
344
344
} ) ;
345
345
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 } ) ;
347
347
348
348
// 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 ( ) ;
351
351
352
352
// Insert the file description to the fd table, generating the file descriptors.
353
353
let pipefd0 = fds. insert ( fd0) ;
0 commit comments