Skip to content

Fix TX queue deadlock on startup (TNC Mode)#41

Open
nilu96 wants to merge 1 commit into
attermann:masterfrom
nilu96:fix-tx
Open

Fix TX queue deadlock on startup (TNC Mode)#41
nilu96 wants to merge 1 commit into
attermann:masterfrom
nilu96:fix-tx

Conversation

@nilu96
Copy link
Copy Markdown

@nilu96 nilu96 commented May 8, 2026

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:

  1. A pending TX packet causes medium_free() to be called.
  2. medium_free() calls update_modem_status(), which resets the last_status_update timer.
  3. Because the TX queue is stuck, medium_free() is called continuously.
  4. Consequently, check_modem_status() always sees a recent last_status_update, causing it to exit early without ever reaching the update_noise_floor() call.
  5. Without a valid noise floor measurement, medium_free() permanently returns false, keeping the TX queue indefinitely stuck.

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.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant