1
0
Fork 0
forked from wry/wry

Merge pull request #777 from mahkoh/jorth/shutdown-connection

clients: explicitly shutdown connection when killing client
This commit is contained in:
mahkoh 2026-03-06 15:56:07 +01:00 committed by GitHub
commit 893be823b6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -10,7 +10,9 @@ use {
},
},
futures_util::{FutureExt, select},
run_on_drop::on_drop,
std::{collections::VecDeque, mem, rc::Rc, time::Duration},
uapi::c,
};
pub async fn client(data: Rc<Client>) {
@ -42,6 +44,9 @@ pub async fn client(data: Rc<Client>) {
}
async fn receive(data: Rc<Client>) {
let _shutdown_rd = on_drop(|| {
let _ = uapi::shutdown(data.socket.raw(), c::SHUT_RD);
});
let display = data.display().unwrap();
let recv = async {
let mut buf = BufFdIn::new(&data.socket, &data.state.ring);
@ -108,6 +113,10 @@ async fn receive(data: Rc<Client>) {
}
async fn send(data: Rc<Client>) {
let socket = data.socket.clone();
let _shutdown_wr = on_drop(|| {
let _ = uapi::shutdown(socket.raw(), c::SHUT_WR);
});
let send = async {
let mut out = BufFdOut::new(&data.socket, &data.state.ring);
let mut buffers = VecDeque::new();