mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-06-08 21:43:44 +02:00
WHOIS retry fix.
This commit is contained in:
parent
dea30c69a7
commit
2b3862fdde
2 changed files with 13 additions and 6 deletions
|
@ -425,7 +425,7 @@ pub(crate) mod v1 {
|
||||||
pub(crate) const PACKET_RESPONSE_COUNTER_DELTA_MAX: u64 = 256;
|
pub(crate) const PACKET_RESPONSE_COUNTER_DELTA_MAX: u64 = 256;
|
||||||
|
|
||||||
/// Frequency for WHOIS retries in milliseconds.
|
/// Frequency for WHOIS retries in milliseconds.
|
||||||
pub(crate) const WHOIS_RETRY_INTERVAL: i64 = 1500;
|
pub(crate) const WHOIS_RETRY_INTERVAL: i64 = 3000;
|
||||||
|
|
||||||
/// Maximum number of WHOIS retries
|
/// Maximum number of WHOIS retries
|
||||||
pub(crate) const WHOIS_RETRY_COUNT_MAX: u16 = 3;
|
pub(crate) const WHOIS_RETRY_COUNT_MAX: u16 = 3;
|
||||||
|
|
|
@ -202,6 +202,7 @@ struct BackgroundTaskIntervals {
|
||||||
|
|
||||||
struct WhoisQueueItem<HostSystemImpl: HostSystem> {
|
struct WhoisQueueItem<HostSystemImpl: HostSystem> {
|
||||||
waiting_packets: RingBuffer<(Weak<Path<HostSystemImpl>>, PooledPacketBuffer), WHOIS_MAX_WAITING_PACKETS>,
|
waiting_packets: RingBuffer<(Weak<Path<HostSystemImpl>>, PooledPacketBuffer), WHOIS_MAX_WAITING_PACKETS>,
|
||||||
|
last_retry_time: i64,
|
||||||
retry_count: u16,
|
retry_count: u16,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -596,9 +597,12 @@ impl<HostSystemImpl: HostSystem> Node<HostSystemImpl> {
|
||||||
let mut whois_queue = self.whois_queue.lock();
|
let mut whois_queue = self.whois_queue.lock();
|
||||||
whois_queue.retain(|_, qi| qi.retry_count <= WHOIS_RETRY_COUNT_MAX);
|
whois_queue.retain(|_, qi| qi.retry_count <= WHOIS_RETRY_COUNT_MAX);
|
||||||
for (address, qi) in whois_queue.iter_mut() {
|
for (address, qi) in whois_queue.iter_mut() {
|
||||||
|
if (time_ticks - qi.last_retry_time) >= WHOIS_RETRY_INTERVAL {
|
||||||
qi.retry_count += 1;
|
qi.retry_count += 1;
|
||||||
|
qi.last_retry_time = time_ticks;
|
||||||
need_whois.push(*address);
|
need_whois.push(*address);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
need_whois
|
need_whois
|
||||||
};
|
};
|
||||||
if !need_whois.is_empty() {
|
if !need_whois.is_empty() {
|
||||||
|
@ -791,15 +795,18 @@ impl<HostSystemImpl: HostSystem> Node<HostSystemImpl> {
|
||||||
debug_event!(host_system, "[vl1] [v1] WHOIS {}", address.to_string());
|
debug_event!(host_system, "[vl1] [v1] WHOIS {}", address.to_string());
|
||||||
{
|
{
|
||||||
let mut whois_queue = self.whois_queue.lock();
|
let mut whois_queue = self.whois_queue.lock();
|
||||||
let qi = whois_queue
|
let qi = whois_queue.entry(address).or_insert_with(|| WhoisQueueItem::<HostSystemImpl> {
|
||||||
.entry(address)
|
waiting_packets: RingBuffer::new(),
|
||||||
.or_insert_with(|| WhoisQueueItem::<HostSystemImpl> { waiting_packets: RingBuffer::new(), retry_count: 0 });
|
last_retry_time: 0,
|
||||||
|
retry_count: 0,
|
||||||
|
});
|
||||||
if let Some(p) = waiting_packet {
|
if let Some(p) = waiting_packet {
|
||||||
qi.waiting_packets.add(p);
|
qi.waiting_packets.add(p);
|
||||||
}
|
}
|
||||||
if qi.retry_count > 0 {
|
if qi.retry_count > 0 {
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
|
qi.last_retry_time = time_ticks;
|
||||||
qi.retry_count += 1;
|
qi.retry_count += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue