Skip to content

Commit 56549d7

Browse files
committed
Port to the new polling
1 parent eb98b47 commit 56549d7

File tree

10 files changed

+188
-163
lines changed

10 files changed

+188
-163
lines changed

Cargo.toml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,6 @@ socket2 = { version = "0.5.3", features = ["all"] }
3636
tracing = { version = "0.1.37", default-features = false }
3737
waker-fn = "1.1.0"
3838

39-
[build-dependencies]
40-
autocfg = "1"
41-
4239
[dev-dependencies]
4340
async-channel = "1"
4441
async-net = "1"
@@ -54,3 +51,7 @@ timerfd = "1"
5451

5552
[target.'cfg(windows)'.dev-dependencies]
5653
uds_windows = "1"
54+
55+
[patch.crates-io]
56+
polling = { git = "https://github.com/smol-rs/polling.git", branch = "notgull/unsafe2" }
57+
async-io = { path = "." }

build.rs

Lines changed: 0 additions & 16 deletions
This file was deleted.

examples/linux-inotify.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,21 @@ fn main() -> std::io::Result<()> {
3737
future::block_on(async {
3838
// Watch events in the current directory.
3939
let mut inotify = Async::new(Inotify::init()?)?;
40-
inotify
41-
.get_mut()
42-
.watches()
43-
.add(".", WatchMask::ALL_EVENTS)?;
40+
41+
// SAFETY: We do not move the inner file descriptor out.
42+
unsafe {
43+
inotify
44+
.get_mut()
45+
.watches()
46+
.add(".", WatchMask::ALL_EVENTS)?;
47+
}
4448
println!("Watching for filesystem events in the current directory...");
4549
println!("Try opening a file to trigger some events.");
4650
println!();
4751

4852
// Wait for events in a loop and print them on the screen.
4953
loop {
50-
for event in inotify.read_with_mut(read_op).await? {
54+
for event in unsafe { inotify.read_with_mut(read_op).await? } {
5155
println!("{:?}", event);
5256
}
5357
}

examples/windows-uds.rs

Lines changed: 1 addition & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -6,54 +6,6 @@
66
//! cargo run --example windows-uds
77
//! ```
88
9-
#[cfg(windows)]
10-
fn main() -> std::io::Result<()> {
11-
use std::path::PathBuf;
12-
13-
use async_io::Async;
14-
use blocking::Unblock;
15-
use futures_lite::{future, io, prelude::*};
16-
use tempfile::tempdir;
17-
use uds_windows::{UnixListener, UnixStream};
18-
19-
async fn client(addr: PathBuf) -> io::Result<()> {
20-
// Connect to the address.
21-
let stream = Async::new(UnixStream::connect(addr)?)?;
22-
println!("Connected to {:?}", stream.get_ref().peer_addr()?);
23-
24-
// Pipe the stream to stdout.
25-
let mut stdout = Unblock::new(std::io::stdout());
26-
io::copy(&stream, &mut stdout).await?;
27-
Ok(())
28-
}
29-
30-
let dir = tempdir()?;
31-
let path = dir.path().join("socket");
32-
33-
future::block_on(async {
34-
// Create a listener.
35-
let listener = Async::new(UnixListener::bind(&path)?)?;
36-
println!("Listening on {:?}", listener.get_ref().local_addr()?);
37-
38-
future::try_zip(
39-
async {
40-
// Accept the client.
41-
let (stream, _) = listener.read_with(|l| l.accept()).await?;
42-
println!("Accepted a client");
43-
44-
// Send a message, drop the stream, and wait for the client.
45-
Async::new(stream)?.write_all(b"Hello!\n").await?;
46-
Ok(())
47-
},
48-
client(path),
49-
)
50-
.await?;
51-
52-
Ok(())
53-
})
54-
}
55-
56-
#[cfg(not(windows))]
579
fn main() {
58-
println!("This example works only on Windows!");
10+
println!("TODO: Restore this example from git once uds_windows implements I/O safety");
5911
}

0 commit comments

Comments
 (0)