Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SimplexStream does not close other half on drop #1

Open
SteveLauC opened this issue Oct 23, 2024 · 0 comments
Open

SimplexStream does not close other half on drop #1

SteveLauC opened this issue Oct 23, 2024 · 0 comments

Comments

@SteveLauC
Copy link
Owner

Upstream tokio issue: tokio-rs/tokio#6914

Root cause

Tokio duplex (or monoio-duplex) uses Arc or Rc when being split, the read half and write half are the same SimplexStream structure, dropping one side does nothing to the SimpleStream structure, and reading/writing through the Rc/Arc wrapper won't check its reference count.

Code snippet

#[monoio::main]
async fn main() {
    use monoio::io::AsyncWriteRentExt;

    let (rx, mut tx) = monoio_duplex::simplex::simplex(64);
    drop(rx);
    let buf = [0; 1024];
    println!("write starting");
    let (write_result, _buf)  = tx.write_all(buf.to_vec()).await;
    write_result.unwrap();
    println!("write finished")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant