Bound console reply writes with a deadline

Since #717 the console sends its reply with write_all, which waits until
every byte is sent. A local client that sends a command and then stops
reading would hold the task and its socket forever. Give the write the
same 1 s deadline as the read above it, and log a reply that fails or
runs late instead of dropping the error.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JAxkkiaGp2k8okvs4MpCUq
This commit is contained in:
rustdeskandClaude Opus 5.5 committed 2026-11-07 13:06:42 +08:00
1 parent 36a0996ee8
commit 8affc6a237
2 files changed
+12 -2

No files matched your search

+6 -1
View File
@@ -402,7 +402,12 @@ async fn handle_connection(
if let Ok(Ok(n)) = timeout(1000, stream.read(&mut buffer[..])).await {
if let Ok(data) = std::str::from_utf8(&buffer[..n]) {
let res = check_cmd(data, limiter).await;
stream.write_all(res.as_bytes()).await.ok();
if let Err(err) = timeout(1000, stream.write_all(res.as_bytes()))
.await
.unwrap_or_else(|elapsed| Err(elapsed.into()))
{
log::warn!("Failed to send the console reply: {err}");
}
}
}
});
+6 -1
View File
@@ -1178,7 +1178,12 @@ impl RendezvousServer {
if let Ok(Ok(n)) = timeout(1000, stream.read(&mut buffer[..])).await {
if let Ok(data) = std::str::from_utf8(&buffer[..n]) {
let res = rs.check_cmd(data).await;
stream.write_all(res.as_bytes()).await.ok();
if let Err(err) = timeout(1000, stream.write_all(res.as_bytes()))
.await
.unwrap_or_else(|elapsed| Err(elapsed.into()))
{
log::warn!("Failed to send the console reply: {err}");
}
}
}
});