fix: retry partial writes in packet and push paths#22
Open
rmorgans wants to merge 3 commits intomobydeck:mainfrom
Open
fix: retry partial writes in packet and push paths#22rmorgans wants to merge 3 commits intomobydeck:mainfrom
rmorgans wants to merge 3 commits intomobydeck:mainfrom
Conversation
Extract write_all() and use it everywhere a socket write must be complete-or-fail. Fixes spurious disconnects under memory pressure or signal interruption that returns a short count. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
send_kill() still used a bare write() for the kill packet. Apply the same write_all() retry loop as push and attach paths. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- write_all: return -1 with errno=EIO when write() returns 0 (no progress), preventing an infinite retry loop - Include fault injection tests (preload_short_write.c) that force short socket writes to deterministically verify the retry logic in push and kill paths Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
3 tasks
rmorgans
added a commit
to rmorgans/atch
that referenced
this pull request
Mar 15, 2026
… push paths # Conflicts: # tests/test.sh
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.
Summary
write_all()retry loop and use it inwrite_packet_or_fail,push_main, andsend_killwrite()returning 0 (no progress) is treated as failure witherrno=EIOpreload_short_write.c)What bug this fixes
The old code did single
write()calls for packet-sized data and treated any short write as fatal. On a Unix domain socket under memory pressure or signal interruption,write()can return a short count. This caused spurious session disconnects.How it's tested
An
LD_PRELOAD/DYLD_INSERT_LIBRARIESshim (tests/preload_short_write.c) forces the first socket write to complete with only 1 byte. The test verifies thatpushandkillcommands still succeed despite the short write. These tests fail on the current code and pass with the fix.Test results
206/207 pass (1 pre-existing failure: test 93, macOS symlink issue). ASan+UBSan clean.