fix(daemon): reconnect after the server session drops
A long-running daemon that lost its TCP connection to the server reported session_loss "disconnected" and answered every command from the dead session until a manual restart. Two causes: - the daemon owned one session for its lifetime with no reconnect at all; and - the lib's ServerActor queued a Login sent while disconnected instead of dialing, so even asking it to log in again never re-established a connection. Reconnect on a dedicated thread with 1s-60s capped backoff, only for a dropped connection to a session this process owns (never a displaced or borrowed one, which would start a login war or fight another daemon). Let a Login through the disconnected guard so a parked actor dials again, and bound that dial with connect_timeout so a blackholed route cannot park the actor thread. Reset the message reader, the queued backlog and the login verdict on disconnect so a partial frame or stale Some(false) cannot wedge the reconnected session. Announce the drop once per outage and re-join rooms and re-watch users on recovery; the daemon main loop is back to save-and-stop so `daemon stop` stays responsive during an outage. Update the session_loss event summary, which no longer means the session is gone for good.
This commit is contained in:
@@ -226,7 +226,9 @@ fn event_summary(event: Event) -> &'static str {
|
||||
Event::DownloadStatus => "A transfer moved.",
|
||||
Event::Browse => "A peer answered a browse request.",
|
||||
Event::SessionLoss => {
|
||||
"The server session ended; nothing seen after this means anything."
|
||||
"The server session was lost. A disconnected session is reconnected \
|
||||
on its own and events resume; a displaced one is terminal. Read \
|
||||
daemon.status for the live state."
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user