fix(iroh-net): Fix a hot-loop when the probes time out #2699
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
When all the probes time out the reportgen actor went into a hot-loop.
We slow this down by resetting the timer to be in the future again.
This way the actor loop can finish normally from the probes without
entering a hot-loop. The actual timeout doesn't matter too much,
normally it should not happen twice as the actor should be finished by
the time another PROBES_TIMEOUT expires.
Breaking Changes
None
Notes & open questions
Fixes #2684.
I've never been very happy with the mainloop of the reportgen actor.
There is too much manual state-tracking also with the way
self.outstanding_tasks is structured. Also the way that
Message::ProbeWouldHelp exists is not nice, the actor should be able
to abort any probes on it's own when they are no longer needed. Maybe
I should sit down again sometime and think better about how to
structure this. Nevertheless, this is a good fix for a real problem.
I'm not sure it's possible to write tests for this in a reasonable way
without manipulating the state entirely artificially. Another reason
that this logic would be better expressed with more typesystem help.
Change checklist
[ ] Documentation updates following the style guide, if relevant.[ ] All breaking changes documented.