Skip to content

Raspberry Pi: honor the configured TCP close timeout - #11940

Open
astrodt wants to merge 1 commit into
adafruit:mainfrom
astrodt:codex/raspberrypi-tcp-close-timeout
Open

astrodt wants to merge 1 commit into
adafruit:mainfrom
astrodt:codex/raspberrypi-tcp-close-timeout

Conversation

@astrodt

@astrodt astrodt commented Nov 21, 2026

Copy link
Copy Markdown

The Raspberry Pi port schedules a TCP abort callback when a socket has not closed cleanly. It converts its 10,000 ms close timeout to lwIP poll ticks using a fixed 500 ms divisor. This port configures a 50 ms lwIP slow timer, so the callback is scheduled after 20 ticks, roughly one second.

Use TCP_SLOW_INTERVAL for the conversion and round up to a whole tick. On this port, 200 ticks give the intended ten-second timeout. Check at compile time that the tick count fits lwIP's eight-bit poll interval.

Hardware validation

Built two Pico 2 W firmware images from upstream commit 931d0ec0ec35879b156ef23dde214c40d886eea9 using separate build directories. The only source difference was this patch. Both ran the same HTTP application on the same board.

For each trial, establish the TCP connection first. Before requesting the response, temporarily drop incoming response data for that connection at the client for two seconds, while allowing control packets through. The server closes the accepted socket with response data still unacknowledged. Remove the drop rule after two seconds and record whether the client receives the complete response or a TCP reset.

Close timeout calculation Outcome Elapsed from HTTP request
Original 4 of 4 connections reset before any response bytes arrived 1.48–1.53 s
Corrected 4 of 4 complete responses 2.22–2.25 s

Earlier instrumentation on a 10.3.2-based build put the original close poll callback approximately 0.99 s after it was scheduled. The table measures from the earlier HTTP request and includes the application's 0.5 s close grace period.

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