Skip to content

Commit

Permalink
Don't quarantine the network if we were just interrupted. (#906)
Browse files Browse the repository at this point in the history
  • Loading branch information
kasperl authored Nov 17, 2023
1 parent ba4745b commit 8f5feaa
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions src/service/synchronize.toit
Original file line number Diff line number Diff line change
Expand Up @@ -348,18 +348,24 @@ class SynchronizeJob extends TaskJob:
// so we prefer using a different network for a while.
done := state_ != STATE-CONNECTED-TO-NETWORK
transition-to-disconnected_ --error=error
// The synchronization may be interrupted by doing a
// firmware upgrade or by a request to go offline. The
// latter leads to cancelation.
interrupted := firmware-is-upgrade-pending or Task.current.is-canceled
if network:
// If we are planning to retry another network,
// we quarantine the one we just tried.
if not done:
// If we are planning to retry another network, we
// quarantine the one we just tried. We don't do
// this if we were interrupted, because there is no
// evidence that there is anything wrong with the
// network in that case.
if not done and not interrupted:
with-timeout TIMEOUT-NETWORK-QUARANTINE: network.quarantine
with-timeout TIMEOUT-NETWORK-CLOSE: network.close
// If we're canceled or doing a firmware upgrade, we should
// make sure to propagate the exception and not just swallow
// it. Otherwise, the caller can easily run into a loop
// where it is repeatedly asked to retry the connect.
if not (firmware-is-upgrade-pending or Task.current.is-canceled):
return done
// If we're interrupted, we must make sure to propagate
// the exception and not just swallow it. Otherwise, the
// caller can easily run into a loop where it is repeatedly
// asked to retry the connect.
if not interrupted: return done

/**
Tries to connect to the broker and step through the
Expand Down

0 comments on commit 8f5feaa

Please sign in to comment.