Skip to content

Commit 257a08b

Browse files
committed
detail
1 parent 34ea579 commit 257a08b

File tree

6 files changed

+20
-14
lines changed

6 files changed

+20
-14
lines changed

src/net/uds/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ mod datagram;
33
pub use self::datagram::UnixDatagram;
44

55
mod listener;
6+
#[cfg(any(unix,windows))]
67
pub use self::listener::UnixListener;
78

89
mod stream;
10+
#[cfg(any(unix,windows))]
911
pub use self::stream::UnixStream;

src/sys/windows/uds/listener.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use windows_sys::Win32::Networking::WinSock::{self, SOCKADDR_UN, SOCKET_ERROR};
2222
///
2323
/// fn main() -> io::Result<()> {
2424
/// // Bind to a socket file
25-
/// let listener = UnixListener::bind("C:/socket.sock")?;
25+
/// let listener = UnixListener::bind("/tmp/socket.sock")?;
2626
///
2727
/// // Accept incoming connections
2828
/// match listener.accept() {
@@ -68,7 +68,7 @@ impl UnixListener {
6868
/// ```no_run
6969
/// use mio::sys::uds::UnixListener;
7070
///
71-
/// let listener = UnixListener::bind("/tmp/my_socket.sock").unwrap();
71+
/// let listener = UnixListener::bind("/tmp/socket.sock").unwrap();
7272
/// ```
7373
pub fn bind<P: AsRef<Path>>(path: P) -> io::Result<Self> {
7474
unsafe {

src/sys/windows/uds/socket.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ impl SocketAddr {
208208
/// use std::path::Path;
209209
/// use mio::uds::SocketAddr;
210210
///
211-
/// let addr = SocketAddr::from_pathname("/tmp/my_socket.sock").unwrap();
211+
/// let addr = SocketAddr::from_pathname("/tmp/socket.sock").unwrap();
212212
/// ```
213213
pub fn from_pathname<P: AsRef<Path>>(path: P) -> io::Result<Self> {
214214
let (addr, addrlen) = socketaddr_un(path.as_ref())?;

src/sys/windows/uds/stream.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ impl UnixStream {
5555
/// # Examples
5656
///
5757
/// ```no_run
58-
/// let stream = UnixStream::connect("C:/my_socket")?;
58+
/// let stream = UnixStream::connect("/tmp/socket.sock")?;
5959
/// # Ok::<(), std::io::Error>(())
6060
/// ```
6161
pub fn connect<P: AsRef<Path>>(path: P) -> io::Result<Self> {
@@ -91,7 +91,7 @@ impl UnixStream {
9191
/// ```no_run
9292
/// use mio::sys::uds::SocketAddr;
9393
///
94-
/// let addr = SocketAddr::from_path("C:/my_socket")?;
94+
/// let addr = SocketAddr::from_path("/tmp/socket.sock")?;
9595
/// let stream = UnixStream::connect_addr(&addr)?;
9696
/// # Ok::<(), std::io::Error>(())
9797
/// ```

tests/unix_stream.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ fn unix_stream_peer_addr() {
233233

234234
// Close the connection to allow the remote to shutdown
235235
drop(stream);
236-
std::fs::remove_file(path).unwrap();
236+
let _ = std::fs::remove_file(path);
237237

238238
handle.join().unwrap();
239239
}
@@ -296,7 +296,7 @@ fn unix_stream_shutdown_read() {
296296

297297
// Close the connection to allow the remote to shutdown
298298
drop(stream);
299-
std::fs::remove_file(path).unwrap();
299+
let _ = std::fs::remove_file(path);
300300
handle.join().unwrap();
301301
}
302302

@@ -359,7 +359,7 @@ fn unix_stream_shutdown_write() {
359359

360360
// Close the connection to allow the remote to shutdown
361361
drop(stream);
362-
std::fs::remove_file(path).unwrap();
362+
let _ = std::fs::remove_file(path);
363363

364364
handle.join().unwrap();
365365
}
@@ -430,7 +430,7 @@ fn unix_stream_shutdown_both() {
430430

431431
// Close the connection to allow the remote to shutdown
432432
drop(stream);
433-
std::fs::remove_file(path).unwrap();
433+
let _ = std::fs::remove_file(path);
434434

435435
handle.join().unwrap();
436436
}
@@ -469,7 +469,7 @@ fn unix_stream_shutdown_listener_write() {
469469
);
470470

471471
barrier.wait();
472-
std::fs::remove_file(path).unwrap();
472+
let _ = std::fs::remove_file(path);
473473

474474
handle.join().unwrap();
475475
}
@@ -492,7 +492,7 @@ fn unix_stream_register() {
492492

493493
// Close the connection to allow the remote to shutdown
494494
drop(stream);
495-
std::fs::remove_file(path).unwrap();
495+
let _ = std::fs::remove_file(path);
496496

497497
handle.join().unwrap();
498498
}
@@ -522,7 +522,7 @@ fn unix_stream_reregister() {
522522

523523
// Close the connection to allow the remote to shutdown
524524
drop(stream);
525-
std::fs::remove_file(path).unwrap();
525+
let _ = std::fs::remove_file(path);
526526

527527
handle.join().unwrap();
528528
}
@@ -564,7 +564,7 @@ fn unix_stream_deregister() {
564564

565565
// Close the connection to allow the remote to shutdown
566566
drop(stream);
567-
std::fs::remove_file(path).unwrap();
567+
let _ = std::fs::remove_file(path);
568568

569569
handle.join().unwrap();
570570
}
@@ -636,7 +636,7 @@ where
636636

637637
// Close the connection to allow the remote to shutdown
638638
drop(stream);
639-
std::fs::remove_file(remote_addr.as_pathname().unwrap()).unwrap();
639+
let _ = std::fs::remove_file(path);
640640
handle.join().unwrap();
641641
}
642642

tests/util/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,10 @@ pub fn assert_error<T, E: fmt::Display>(result: Result<T, E>, expected_msg: &str
193193
pub fn assert_would_block<T>(result: io::Result<T>) {
194194
match result {
195195
Ok(_) => panic!("unexpected OK result, expected a `WouldBlock` error"),
196+
Err(e) if e.kind() == io::ErrorKind::WouldBlock => {}
197+
#[cfg(unix)]
198+
Err(_) => panic!("unexpected error: {e}"),
199+
#[cfg(windows)]
196200
Err(_) => {}
197201
}
198202
}

0 commit comments

Comments
 (0)