Fix keepalive for small timeouts

pull/67/head
Dennis Schwerdel 2020-06-17 22:53:14 +02:00
parent 2238a04cd3
commit 57c993e8d5
3 changed files with 6 additions and 4 deletions

View File

@ -7,6 +7,7 @@ This project follows [semantic versioning](http://semver.org).
- [added] Added crypto option AES128
- [changed] Updated dependencies
- [fixed] Fixed keepalive for small timeouts
### v1.4.0 (2020-06-03)

View File

@ -3,7 +3,7 @@
// This software is licensed under GPL-3 or newer (see LICENSE.md)
use std::{
cmp::min,
cmp::{min, max},
collections::HashMap,
fmt,
fs::{self, File},
@ -473,7 +473,7 @@ impl<D: Device, P: Protocol, T: Table, S: Socket, TS: TimeSource> GenericCloud<D
let mut msg = Message::Peers(peers);
self.broadcast_msg(&mut msg)?;
// Reschedule for next update
let interval = min(self.update_freq as u16, self.peers.min_peer_timeout());
let interval = min(self.update_freq as u16, max(self.peers.min_peer_timeout()/2-60, 1));
self.next_peerlist = now + Time::from(interval);
}
// Connect to those reconnect_peers that are due

View File

@ -14,7 +14,8 @@ use super::{
use siphasher::sip::SipHasher24;
use std::{
hash::{Hash, Hasher},
net::{IpAddr, Ipv6Addr, SocketAddr}
net::{IpAddr, Ipv6Addr, SocketAddr},
cmp::max
};
@ -284,7 +285,7 @@ impl Config {
pub fn get_keepalive(&self) -> Duration {
match self.keepalive {
Some(dur) => dur,
None => self.peer_timeout / 2 - 60
None => max(self.peer_timeout / 2 - 60, 1)
}
}
}