mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Prevented postal workers spinning for too long
Former-commit-id: e535f5745c817b7fd5f109711aaa65e6c78d6ecc
This commit is contained in:
parent
19e6930e67
commit
9f5aab3564
@ -174,7 +174,7 @@ impl<S: PostMsg, R: PostMsg> PostBox<S, R> {
|
||||
}
|
||||
|
||||
// Try getting messages from the send channel
|
||||
loop {
|
||||
for _ in 0..10 {
|
||||
match send_rx.try_recv() {
|
||||
Ok(Some(send_msg)) => {
|
||||
// Serialize message
|
||||
@ -206,7 +206,7 @@ impl<S: PostMsg, R: PostMsg> PostBox<S, R> {
|
||||
}
|
||||
|
||||
// Try sending bytes through the TCP stream
|
||||
loop {
|
||||
for _ in 0..10 {
|
||||
//println!("HERE! Outgoing len: {}", outgoing_chunks.len());
|
||||
match outgoing_chunks.pop_front() {
|
||||
Some(chunk) => match stream.write_all(&chunk) {
|
||||
@ -227,7 +227,7 @@ impl<S: PostMsg, R: PostMsg> PostBox<S, R> {
|
||||
}
|
||||
|
||||
// Try receiving bytes from the TCP stream
|
||||
loop {
|
||||
for _ in 0..10 {
|
||||
let mut buf = [0; 1024];
|
||||
|
||||
match stream.read(&mut buf) {
|
||||
@ -242,7 +242,7 @@ impl<S: PostMsg, R: PostMsg> PostBox<S, R> {
|
||||
}
|
||||
|
||||
// Try turning bytes into messages
|
||||
loop {
|
||||
for _ in 0..10 {
|
||||
match incoming_buf.get(0..8) {
|
||||
Some(len_bytes) => {
|
||||
let len = usize::from_le_bytes(<[u8; 8]>::try_from(len_bytes).unwrap()); // Can't fail
|
||||
|
Loading…
Reference in New Issue
Block a user