Fix crash when AGWPE connection attempt times out #622
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.
When a connection attempt via AGWPE had exhausted all retries, Direwolf would crash (segfault) on Linux. This happened because the timer expiry check (dl_timer_expiry) iterates over the state machine list in a way that assumes the list is not modified during iteration. However, recent changes to clean up AGWPE connections violated this assumption, such that a state machine might be removed from the list during iteration. Updating the iterations was missed in those earlier changes.
This change replaces the loop structure with one that allows for the modification of the list during iteration. Currently t1_expiry() is the only case in which the list may be modified; however, t3_expiry() and tm201_expiry() loops have also been changed to insure against possible future modifications.
Fixes #621