fix(connection): reconnect decision closes the failed socket (health_check's documented role) + symmetric backoff-bound test assertion (F3, F5)
This commit is contained in:
1 parent
24981d84a8
commit
9c409b3805
2 files changed
+27
-5
No files matched your search
@@ -276,7 +276,7 @@ class ShieldConnectionManager:
|
||||
|
||||
try:
|
||||
if not self.connected and not await self._poller.connect():
|
||||
self._note_failure(backoff)
|
||||
await self._note_failure(backoff)
|
||||
return self._jitter(backoff)
|
||||
if self._failures:
|
||||
self._failures = 0
|
||||
@@ -285,11 +285,11 @@ class ShieldConnectionManager:
|
||||
await self._refresh()
|
||||
return ADB_POLL_INTERVAL
|
||||
except Exception as err:
|
||||
self._note_failure(backoff)
|
||||
await self._note_failure(backoff)
|
||||
_LOGGER.debug("Watchdog cycle failed: %s", err)
|
||||
return self._jitter(backoff)
|
||||
|
||||
def _note_failure(self, backoff: float) -> None:
|
||||
async def _note_failure(self, backoff: float) -> None:
|
||||
"""Bookkeep a failed cycle: log sparingly, drop stale store, notify."""
|
||||
self._failures += 1
|
||||
if self._failures == 1 or self._failures % 6 == 0:
|
||||
@@ -300,6 +300,13 @@ class ShieldConnectionManager:
|
||||
)
|
||||
if not self._down_since:
|
||||
self._down_since = True
|
||||
# Reconnect decision (health_check's documented role): close the
|
||||
# socket so the next cycle rebuilds it from scratch instead of
|
||||
# trusting shell()'s auto-reconnect on a broken transport.
|
||||
try:
|
||||
await self._poller.disconnect()
|
||||
except Exception:
|
||||
_LOGGER.debug("disconnect during reconnect decision failed", exc_info=True)
|
||||
self.store.clear(*ALL_FIELDS)
|
||||
self._notify()
|
||||
|
||||
|
||||
Reference in new issue
Block a user