fix a rare connection glitch
This commit is contained in:
parent
bd3e770a0d
commit
2a675aa9d5
2 changed files with 17 additions and 17 deletions
|
@ -204,11 +204,11 @@ pub fn gui() -> Result<(), iui::UIError> {
|
|||
let uib = uib1.clone();
|
||||
let barb = barb1.clone();
|
||||
uib1.get().queue_main(move || {
|
||||
let percentage = (f * 100 as f32) as u32;
|
||||
let percentage = (f * 100 as f32) as i32;
|
||||
if percentage != *lpb1.get() {
|
||||
barb.get().set_value(
|
||||
uib.get(),
|
||||
ProgressBarValue::Determinate(percentage),
|
||||
ProgressBarValue::Determinate(percentage as u32),
|
||||
);
|
||||
*lpb1.get() = percentage;
|
||||
}
|
||||
|
@ -240,11 +240,11 @@ pub fn gui() -> Result<(), iui::UIError> {
|
|||
let uib = uib1.clone();
|
||||
let barb = barb1.clone();
|
||||
uib1.get().queue_main(move || {
|
||||
let percentage = (f * 100 as f32) as u32;
|
||||
let percentage = (f * 100 as f32) as i32;
|
||||
if percentage != *lpb1.get() {
|
||||
barb.get().set_value(
|
||||
uib.get(),
|
||||
ProgressBarValue::Determinate(percentage),
|
||||
ProgressBarValue::Determinate(percentage as u32),
|
||||
);
|
||||
*lpb1.get() = percentage;
|
||||
}
|
||||
|
|
26
src/main.rs
26
src/main.rs
|
@ -226,24 +226,24 @@ impl SafeReadWrite {
|
|||
}
|
||||
if unix_millis() - start > 10000 {
|
||||
println!("\r\x1b[K10s passed since last packet ==> Contact broke. Trying to resend packet...");
|
||||
let buf = self
|
||||
.last_transmitted
|
||||
.get(&idn)
|
||||
.expect("Unable to recover from connection loss.");
|
||||
loop {
|
||||
match self.socket.send(buf) {
|
||||
Ok(x) => {
|
||||
if x != buf.len() {
|
||||
if let Some(buf) = self.last_transmitted.get(&idn) {
|
||||
loop {
|
||||
match self.socket.send(buf) {
|
||||
Ok(x) => {
|
||||
if x != buf.len() {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
Err(_) => {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
Err(_) => {
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
start = unix_millis();
|
||||
} else {
|
||||
break; // Latest packet was already ACK'd ==> No packets properly lost ==> Can continue with next packet.
|
||||
}
|
||||
start = unix_millis();
|
||||
}
|
||||
if !wait {
|
||||
break;
|
||||
|
|
Loading…
Add table
Reference in a new issue