mirror of
https://github.com/rustdesk/rustdesk-server.git
synced 2026-11-27 00:04:24 +00:00
Bound console reply writes with a deadline (#746)
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. Claude-Session: https://claude.ai/code/session_01JAxkkiaGp2k8okvs4MpCUq Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
36a0996ee8
commit
98ffcee829
2 files changed
+12
-2
No files matched your search
+6
-1
@@ -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}");
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -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}");
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user