Fix TX queue deadlock on startup (TNC Mode)#41
Open
nilu96 wants to merge 1 commit into
Open
Conversation
Problem: If a packet is added to queue for TX early after startup before the first call of update_noise_floor(). Then, medium_free() calls update_modem_status() which updates last_status_update. This leads to check_modem_status() always returning without any action (especially without updating noise floor). Because medium_free() is called periodically (because of stuck TX queue), check_modem_status() will never call update_noise_floor(). Because there is no valid noise floor, medium_free() will always return false --> stuck TX queue. Easy fix: never update modem status without updating noise floor as well. This bug only appears in TNC mode, when interference avoidance is active.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The Problem
When operating in TNC mode with interference avoidance active, the TX queue can become permanently stuck immediately after startup.
Root Cause
This bug is triggered if a packet is added to the TX queue before the first execution of update_noise_floor(). This creates a deadlock loop:
The Fix
This PR resolves the deadlock by moving update_noise_floor() directly inside update_modem_status().
By coupling these two updates, we ensure that the noise floor is always calculated whenever the modem status is updated, guaranteeing that medium_free() has the data it needs to process the queue properly.