Only close listener connection on failure if it has been open for
a long time. This will protect against the case where the message itself is the cause of the problem.
This commit is contained in:
parent
729a218b36
commit
ac10d7db84
@ -12,6 +12,7 @@ use std::sync::Arc;
|
|||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
use crate::DResult;
|
use crate::DResult;
|
||||||
|
use std::time::Instant;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct ListenerSend {
|
pub struct ListenerSend {
|
||||||
@ -65,6 +66,7 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let connected_at = Instant::now();
|
||||||
let (sender, mut receiver) = mpsc::channel(1);
|
let (sender, mut receiver) = mpsc::channel(1);
|
||||||
listener_map.lock().await.insert(listener_id, sender);
|
listener_map.lock().await.insert(listener_id, sender);
|
||||||
|
|
||||||
@ -129,11 +131,17 @@ where
|
|||||||
match handle_fut.await {
|
match handle_fut.await {
|
||||||
Ok(_) => {}
|
Ok(_) => {}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
|
if connected_at.elapsed() > std::time::Duration::from_secs(60) {
|
||||||
// On the assumption errors that get here are bad enough that they are a
|
// On the assumption errors that get here are bad enough that they are a
|
||||||
// problem with the system rather than the message, so we want to log and
|
// problem with the system rather than the message, so we want to log and
|
||||||
// retry later.
|
// retry later.
|
||||||
warn!("Error from message handler - closing listener connection: {}", e);
|
warn!("Error from message handler - closing listener connection: {}", e);
|
||||||
break 'listener_loop;
|
break 'listener_loop;
|
||||||
|
} else {
|
||||||
|
warn!("Error from message handler, but we only just connected, so \
|
||||||
|
acknowledging it anyway as a safety measure against reconnect \
|
||||||
|
loops: {}", e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user