mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-18 08:52:45 +00:00
implement deferred close on drop for TcpStream
streams are not closed until the txbuffer is empty
This commit is contained in:
parent
6f1597b1e7
commit
4ec84bf4dc
1 changed files with 6 additions and 6 deletions
|
|
@ -654,12 +654,12 @@ fn xmain() -> ! {
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
if !std_tcp_can_close(&tcp_tx_waiting, handle) {
|
if !std_tcp_can_close(&tcp_tx_waiting, handle) {
|
||||||
log::info!("def");
|
log::trace!("def"); // these are short because the extra delay of a long message affects the computation
|
||||||
tcp_tx_closing.push((handle, msg.sender));
|
tcp_tx_closing.push((handle, msg.sender));
|
||||||
} else {
|
} else {
|
||||||
let socket = iface.get_socket::<TcpSocket>(handle);
|
let socket = iface.get_socket::<TcpSocket>(handle);
|
||||||
if socket.may_send() {
|
if socket.may_send() && socket.send_queue() == 0 {
|
||||||
log::info!("imm");
|
log::trace!("imm");
|
||||||
socket.close();
|
socket.close();
|
||||||
iface.remove_socket(handle);
|
iface.remove_socket(handle);
|
||||||
if let Some(response) = msg.body.memory_message_mut() {
|
if let Some(response) = msg.body.memory_message_mut() {
|
||||||
|
|
@ -668,7 +668,7 @@ fn xmain() -> ! {
|
||||||
xous::return_scalar(msg.sender, 0).ok();
|
xous::return_scalar(msg.sender, 0).ok();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
log::info!("def2");
|
log::trace!("def2");
|
||||||
tcp_tx_closing.push((handle, msg.sender));
|
tcp_tx_closing.push((handle, msg.sender));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1446,10 +1446,10 @@ fn xmain() -> ! {
|
||||||
for (index, &(handle, sender)) in tcp_tx_closing.iter().enumerate() {
|
for (index, &(handle, sender)) in tcp_tx_closing.iter().enumerate() {
|
||||||
if std_tcp_can_close(&tcp_tx_waiting, handle) {
|
if std_tcp_can_close(&tcp_tx_waiting, handle) {
|
||||||
let socket = iface.get_socket::<TcpSocket>(handle);
|
let socket = iface.get_socket::<TcpSocket>(handle);
|
||||||
if socket.may_send() {
|
if socket.may_send() && socket.send_queue() == 0 {
|
||||||
socket.close();
|
socket.close();
|
||||||
iface.remove_socket(handle);
|
iface.remove_socket(handle);
|
||||||
log::info!("deferred close, socket is not active");
|
log::debug!("deferred close, socket is not active");
|
||||||
xous::return_scalar(sender, 0).ok();
|
xous::return_scalar(sender, 0).ok();
|
||||||
closed.push(index);
|
closed.push(index);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue