Fix reading bug
This commit is contained in:
@@ -76,9 +76,11 @@ impl TerminalServer {
|
|||||||
) -> tokio::io::Result<()> {
|
) -> tokio::io::Result<()> {
|
||||||
let msg = message.to_com();
|
let msg = message.to_com();
|
||||||
|
|
||||||
for i in (0..self.clients.lock().await.len()).rev() {
|
let mut clients = self.clients.lock().await;
|
||||||
if let Err(e) = self.clients.lock().await[i].write(&msg).await {
|
|
||||||
self.clients.lock().await.remove(i);
|
for i in (0..clients.len()).rev() {
|
||||||
|
if let Err(e) = clients[i].write(&msg).await {
|
||||||
|
clients.remove(i);
|
||||||
println!("{e:?}");
|
println!("{e:?}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ impl TerminalClient {
|
|||||||
|
|
||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
loop {
|
loop {
|
||||||
let mut buffer = Vec::new();
|
let mut buffer = vec![0u8; 4096];
|
||||||
|
|
||||||
let len = reader
|
let len = reader
|
||||||
.read(&mut buffer)
|
.read(&mut buffer)
|
||||||
|
|||||||
Reference in New Issue
Block a user