Skip to content

Prevent Telnet peer disconnects from triggering the TCP watchdog - #1742

Open
figamore wants to merge 1 commit into
bdring:mainfrom
figamore:fix/telnet-write-watchdog
Open

Prevent Telnet peer disconnects from triggering the TCP watchdog#1742
figamore wants to merge 1 commit into
bdring:mainfrom
figamore:fix/telnet-write-watchdog

Conversation

@figamore

Copy link
Copy Markdown
Contributor

Problem

A stalled or dead Telnet peer could block TelnetClient::write() indefinitely,
starving the FreeRTOS TCP task watchdog and causing an unintended reboot.

Changes

  • Replaced Telnet's blocking WiFiClient::write() with ::send(..., MSG_DONTWAIT) so writes never hold the CPU.
  • Added a line-accumulation buffer so output is flushed one complete line at a time, keeping \r\n
    normalization correct across fragmented write() calls.
  • When the client's TCP send buffer is full, the code waits up to TX_IDLE_WAIT_MS (50 ms) when the
    machine is idle, but drops immediately during motion to keep jogging/running unaffected.
  • Clients that stall TX_STALL_LIMIT (10) consecutive lines are disconnected and reaped on the next
    poll(), freeing the slot for a healthy reconnect.

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