Repository navigation
Backport TcpServer shutdown-hang fix - #5687
Merged
LeStarch merged 4 commits intoAug 17, 2026
Merged
Conversation
…ards (nasa#5336) * TcpServer now reliably shuts down instead of reliably hanging on accept() - Note: previously, calling TcpServerComponentImpl::terminate() would release the listening port, but allow an established connection to continue. Now, it drops any active client connections too. * IP close() calls now guard against invalid file descriptors * Fixed documentation regarding TcpServerSocket::shutdown which was renamed to "terminate" in nasa#2950 Co-authored-by: M Starch <LeStarch@googlemail.com> Co-authored-by: lestarch-autobot <lestarch+autobot@gmail.com> Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: michael.d.starch <michael.d.starch@jpl.nasa.gov>
* v4 deployments can exit cleanly with stop() because their read task no longer performs accept(). In v3.6, the read task still performs accept(), so stop() must also tear down the listening socket to keep that task from blocking on accept() indefinitely. * Note: stop() is now equivalent to terminate() for TcpServer. It releases the listening port even when the read task was never started.
* Speeds up topology teardown by removing SOCKET_RETRY_INTERVAL delay when terminating socket component (e.g. TcpServer)
nathancheek
force-pushed
the
release/v3.6.0-hotfixes
branch
from
August 14, 2026 05:12
fd69289 to
e31223b
Compare
LeStarch
approved these changes
Aug 14, 2026
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.
Change Description
Backports the TcpServer shutdown-hang fix and the IP
close()file descriptor guards fromdeveltorelease/v3.6.0-hotfixes, plus a change to TcpServerstop()needed to keep the v3.6 teardown API working.Also removes a delay at shutdown by checking if thread is running before a
delay(SOCKET_RETRY_INTERVAL).Updates documentation of affected functions (note that socket documentation in
develis outdated, I will open a separate PR to tackle that).Rationale
Currently, v3.6 deployments hang when exiting, if a TcpServer has no active client connection.
Testing/Review Recommendations
Verified against four teardown scenarios:
join()hangsjoin()hangsI tested all 8 iterations of this before/after test on two deployments: an internal project deployment plus a modified
fprime-tutorial-hello-world. In order to getfprime-tutorial-hello-worldto demonstrate this fix, I made 3 changes to the v3.6.0 deployment:Drv.TcpClienttoDrv.TcpServerin instances.fppcomm.stop()andcomm.join()abovestopTasks()(order matters to keep the deployment from hanging at shutdown, at least in v3.6)Svc.ComQueuein the downlink path (a different unresolved bug causes a thread sending via TcpServer to hang onaccept()when no client is connected. Without this ComQueue in the middle, the tlm-generating rategroup sits inaccept()until it eventually asserts due to full component queue atTlmChanComponentAc.cpp:483).Future Work
Claude proposed some unit tests, which I did not include, because they would hang indefinitely if failing, which didn't seem ideal. But it may be possible to write unit tests to demonstrate this behavior, if desired.
AI Usage (see policy)
Claude helped me compare v3.6 socket components to v4 in order to properly backport this change. It provided some initial documentation and commit message examples which I used as inspiration. Finally, it reviewed my work and provided recommendations before I submitted this PR.