Skip to content

Commit 0dd3005

Browse files
committed
fix safe_io blocking issue and use latest monoio version
1 parent 6ff8a1b commit 0dd3005

File tree

4 files changed

+13
-8
lines changed

4 files changed

+13
-8
lines changed

example/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ name = "monoio-tls-example"
44
version = "0.1.0"
55

66
[dependencies]
7-
monoio = {version = "0.0.7", path = "../../monoio/monoio"}
7+
monoio = {version = "0.0.8"}
88
rustls = {version = "0.20", features = ["tls12"]}
99
rustls-pemfile = "1"
1010
webpki-roots = "0.22"
1111

12-
monoio-rustls = {version = "0.0.3", path = "../monoio-rustls", features = ["tls12"]}
12+
monoio-rustls = {version = "0.0.4", path = "../monoio-rustls", features = ["tls12"]}
1313

1414
[[bin]]
1515
name = "server"

monoio-rustls/Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,23 @@ license = "MIT/Apache-2.0"
88
name = "monoio-rustls"
99
readme = "README.md"
1010
repository = "https://github.com/monoio-rs/monoio-tls"
11-
version = "0.0.3"
11+
version = "0.0.4"
1212

1313
[dependencies]
1414
bytes = {version = "1"}
15-
monoio = {version = "0.0.7", default-features = false}
15+
monoio = {version = "0.0.8", default-features = false, features = ["bytes"]}
1616
rustls = {version = "0.20", default-features = false}
1717
thiserror = {version = "1"}
1818

1919
[features]
2020
dangerous_configuration = ["rustls/dangerous_configuration"]
21-
default = ["logging", "tls12", "unsafe_io"]
21+
default = ["logging", "tls12"]
2222
logging = ["rustls/logging"]
2323
tls12 = ["rustls/tls12"]
2424
# Once unsafe_io is enabled, you may not drop the future before it returns ready.
2525
# It saves one buffer copy than disabled.
2626
unsafe_io = []
2727

2828
[dev-dependencies]
29-
monoio = "0.0.7"
29+
monoio = {version = "0.0.8", features = ["bytes"]}
3030
webpki-roots = "0.22"

monoio-rustls/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![allow(stable_features)]
12
#![feature(generic_associated_types)]
23
#![feature(type_alias_impl_trait)]
34

monoio-rustls/src/safe_io.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::io;
22

33
use bytes::{Buf, BufMut, BytesMut};
4-
use monoio::io::{AsyncReadRent, AsyncWriteRent};
4+
use monoio::io::{AsyncReadRent, AsyncWriteRent, AsyncWriteRentExt};
55

66
const BUFFER_SIZE: usize = 16 * 1024;
77

@@ -75,7 +75,7 @@ impl SafeWrite {
7575

7676
// buffer is not empty now. write it.
7777
let buffer = self.buffer.take().expect("buffer ownership expected");
78-
let (result, buffer) = io.write(buffer).await;
78+
let (result, buffer) = io.write_all(buffer).await;
7979
self.buffer = Some(buffer);
8080
let written_len = result?;
8181
unsafe { self.buffer.as_mut().unwrap_unchecked().advance(written_len) };
@@ -102,6 +102,10 @@ impl io::Write for SafeWrite {
102102
}
103103

104104
fn flush(&mut self) -> io::Result<()> {
105+
let buffer = self.buffer.as_mut().expect("buffer mut expected");
106+
if !buffer.is_empty() {
107+
return Err(io::ErrorKind::WouldBlock.into());
108+
}
105109
Ok(())
106110
}
107111
}

0 commit comments

Comments
 (0)