Skip to content

Commit a649265

Browse files
committed
fix wrong generic
1 parent 9abface commit a649265

File tree

3 files changed

+6
-44
lines changed

3 files changed

+6
-44
lines changed

library/std/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ std_detect_dlsym_getauxval = ["std_detect/std_detect_dlsym_getauxval"]
134134
# Enable using raw-dylib for Windows imports.
135135
# This will eventually be the default.
136136
windows_raw_dylib = ["windows-targets/windows_raw_dylib"]
137-
137+
windows_unix_domain_sockets = []
138138
[package.metadata.fortanix-sgx]
139139
# Maximum possible number of threads when testing
140140
threads = 125

library/std/src/os/windows/net/listener.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use crate::sys::net::Socket;
1515
pub struct UnixListener(Socket);
1616

1717
impl UnixListener {
18-
pub fn bind<P: AsRef<Path>>(path: &Path) -> io::Result<UnixListener> {
18+
pub fn bind<P: AsRef<Path>>(path: P) -> io::Result<UnixListener> {
1919
unsafe {
2020
let inner = Socket::new_unix()?;
2121
let (addr, len) = sockaddr_un(path)?;
Lines changed: 4 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
1-
#![cfg(all(windows, feature = "windows_unix_domain_sockets"))]
2-
#![unstable(feature = "windows_unix_domain_sockets", issue = "none")]
1+
#![cfg(windows)]
2+
#![feature(windows_unix_domain_sockets)]
33

44
use std::io::{Read, Write};
55
use std::os::windows::net::{UnixListener, UnixStream};
6-
use std::path::Path;
76
use std::thread;
87

98
#[test]
109
fn smoke_bind_connect() {
1110
let tmp = std::env::temp_dir();
1211
let sock_path = tmp.join("rust-test-uds.sock");
1312

14-
let listener = UnixListener::bind(&sock_path).expect("bind failed");
13+
let listener = UnixListener::bind(sock_path.as_path()).expect("bind failed");
1514

1615
let tx = thread::spawn(move || {
1716
let mut stream = UnixStream::connect(&sock_path).expect("connect failed");
@@ -23,45 +22,8 @@ fn smoke_bind_connect() {
2322
stream.read_exact(&mut buf).expect("read failed");
2423
assert_eq!(&buf, b"hello");
2524

26-
tx.join().unwrap;
25+
tx.join().unwrap();
2726

2827
drop(listener);
2928
let _ = std::fs::remove_file(&sock_path);
3029
}
31-
32-
#[test]
33-
fn echo() {
34-
let tmp = std::env::temp_dir();
35-
let sock_path = tmp.join("rust-test-uds-echo.sock");
36-
37-
let listener = UnixListener::bind(&sock_path).unwrap();
38-
39-
let tx = thread::spawn(move || {
40-
let (mut stream, _) = listener.accept().unwrap;
41-
let mut buf = [0; 1024];
42-
loop {
43-
let n = match stream.read(&mut buf) {
44-
Ok(0) => return,
45-
Ok(n) => n,
46-
Err(e) => panic!("read error: {}", e),
47-
};
48-
stream.write_all(&buf[..n]).unwrap;
49-
}
50-
});
51-
52-
let mut client = UnixStream::connect(&sock_path).unwrap;
53-
client.write_all(b"echo").unwrap;
54-
let mut buf = [0; 4];
55-
client.read_exact(&mut buf).unwrap;
56-
assert_eq!(&buf, b"echo");
57-
58-
drop(client);
59-
tx.join().unwrap;
60-
let _ = std::fs::remove_file(&sock_path);
61-
}
62-
63-
#[test]
64-
fn path_too_long() {
65-
let long = "\\\\?\\".to_string() + &"a".repeat(300);
66-
assert!(UnixListener::bind(long).is_err());
67-
}

0 commit comments

Comments
 (0)