protocol: reuse session address for reconnect
When maintaining persistent connections, the config was consulted for a peer address. Multiple addresses for a single `NodeId` can be listed. This can result in a different address being used for reconnecting if the `HashSet` returns in a different order. The original address that was used for connection is in the `Session`, so this should be used instead.
This commit is contained in:
parent
589925e3a3
commit
73f9a35033
|
|
@ -2671,13 +2671,13 @@ where
|
||||||
let mut reconnect = Vec::new();
|
let mut reconnect = Vec::new();
|
||||||
|
|
||||||
for (nid, session) in self.sessions.iter_mut() {
|
for (nid, session) in self.sessions.iter_mut() {
|
||||||
if let Some(addr) = self.config.peer(nid) {
|
if self.config.is_persistent(nid) {
|
||||||
if let session::State::Disconnected { retry_at, .. } = &mut session.state {
|
if let session::State::Disconnected { retry_at, .. } = &mut session.state {
|
||||||
// TODO: Try to reconnect only if the peer was attempted. A disconnect without
|
// TODO: Try to reconnect only if the peer was attempted. A disconnect without
|
||||||
// even a successful attempt means that we're unlikely to be able to reconnect.
|
// even a successful attempt means that we're unlikely to be able to reconnect.
|
||||||
|
|
||||||
if now >= *retry_at {
|
if now >= *retry_at {
|
||||||
reconnect.push((*nid, addr.clone(), session.attempts()));
|
reconnect.push((*nid, session.addr.clone(), session.attempts()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue