Repository navigation
refactor: delete the unused stream-compression reader and writer - #8260
Merged
oferchen merged 4 commits intoOct 28, 2026
Merged
Conversation
The goodbye handshake ran a finalizer between writing the sender's NDX_DONE and reading the receiver's reply. It only called finalize_compression(), which is a plain flush in production: no production path builds a Compressed ServerWriter, since compression is token-level as in upstream token.c. It also ran directly after the flush that follows NDX_DONE, so it could never move a byte. Upstream has no counterpart either. read_ndx_and_attrs() drains output in perform_io() before it blocks, which is the existing flush, and handle_goodbye_proto31_flushes_ndx_done_before_close already guards it. Remove the finalizer parameter from the goodbye methods. The orchestrator's exit flush is what upstream requires: main.c:1011 runs io_flush(FULL_FLUSH) after read_final_goodbye(), and cleanup.c:194-195 flushes again on exit_cleanup(0). That includes the empty-file-list early return at main.c:996-1001. Below protocol 30, send_file_list() leaves the list end and the io_error word buffered, and the multiplex writer has no flushing Drop. Without the flush the client never receives them. A new run()-level test fails with an empty wire when that flush is removed.
kill_process_group on Apple treated EPERM as success only once waitid already reported the leader as ended. A leader that has begun exiting but is not yet waitable is skipped by XNU's killpg1() too, so the EPERM can arrive first, and the test harness's Drop panicked with "stop the test daemon N: Operation not permitted". This was seen on master's macOS tracing row (daemon_pull_default_send_zc_byte_identical) and on the iconv row here. EPERM for our own child now blocks in waitid until the leader has ended, without reaping it. The empty-file-list flush test relied on ENOTDIR from a path through a regular file, which Windows reports as not-found, so no io_error was raised there. Use a missing operand instead. The word is then 0, but the list end plus four io_error bytes still have to reach the wire, and with the early-return flush removed the wire carries no data at all.
XNU's killpg1() (bsd/kern/kern_sig.c) returns EPERM for a POSIX caller whenever it signalled no member of the group. That covers two cases. In the first, the leader is a zombie or is still exiting and not yet waitable. In the second, the leader is alive and the only other member belongs to a different uid. The previous change blocked in waitid(WEXITED|WNOWAIT) on any EPERM for our own child. In the second case the leader never exits, so that wait would hang forever. Now a non-blocking waitid probe first confirms the pid is our own child; any other pid is never signalled and keeps the EPERM error. The leader is then killed directly, which is always permitted on one's own child and harmless on a zombie, and only then awaited without reaping, so the wait has a bounded end. Neither case has a deterministic reproduction: the first is a scheduling window inside process exit, and the second needs a cross-uid group member. Both follow from the killpg1() return rule.
Compression is token-level, as in upstream token.c, so no production path ever wrapped the multiplexed stream in a compressor. Nothing outside tests called ServerWriter::activate_compression*, ServerReader::activate_compression, CompressedWriter or CompressedReader. Delete them, their Compressed variants and match arms, finalize_compression (flush_all_pending is now a flush that tolerates a closed peer), and the tests that existed only to exercise them. ZstdStrategy::with_workers lost its only caller with CompressedWriter, so it goes too; the strategy builds its encoder single-threaded, which is what it already did for every caller.
oferchen
force-pushed
the
fix/goodbye-barriers
branch
from
October 28, 2026 22:25
429ee46 to
b5b22a5
Compare
oferchen
added a commit
that referenced
this pull request
Oct 29, 2026
* fix: guard the sender exit flush and drop the goodbye finalizer The goodbye handshake ran a finalizer between writing the sender's NDX_DONE and reading the receiver's reply. It only called finalize_compression(), which is a plain flush in production: no production path builds a Compressed ServerWriter, since compression is token-level as in upstream token.c. It also ran directly after the flush that follows NDX_DONE, so it could never move a byte. Upstream has no counterpart either. read_ndx_and_attrs() drains output in perform_io() before it blocks, which is the existing flush, and handle_goodbye_proto31_flushes_ndx_done_before_close already guards it. Remove the finalizer parameter from the goodbye methods. The orchestrator's exit flush is what upstream requires: main.c:1011 runs io_flush(FULL_FLUSH) after read_final_goodbye(), and cleanup.c:194-195 flushes again on exit_cleanup(0). That includes the empty-file-list early return at main.c:996-1001. Below protocol 30, send_file_list() leaves the list end and the io_error word buffered, and the multiplex writer has no flushing Drop. Without the flush the client never receives them. A new run()-level test fails with an empty wire when that flush is removed. * fix: wait out an exiting leader on macOS killpg; portable flush fixture kill_process_group on Apple treated EPERM as success only once waitid already reported the leader as ended. A leader that has begun exiting but is not yet waitable is skipped by XNU's killpg1() too, so the EPERM can arrive first, and the test harness's Drop panicked with "stop the test daemon N: Operation not permitted". This was seen on master's macOS tracing row (daemon_pull_default_send_zc_byte_identical) and on the iconv row here. EPERM for our own child now blocks in waitid until the leader has ended, without reaping it. The empty-file-list flush test relied on ENOTDIR from a path through a regular file, which Windows reports as not-found, so no io_error was raised there. Use a missing operand instead. The word is then 0, but the list end plus four io_error bytes still have to reach the wire, and with the early-return flush removed the wire carries no data at all. * fix: SIGKILL the leader before awaiting it on a macOS killpg EPERM XNU's killpg1() (bsd/kern/kern_sig.c) returns EPERM for a POSIX caller whenever it signalled no member of the group. That covers two cases. In the first, the leader is a zombie or is still exiting and not yet waitable. In the second, the leader is alive and the only other member belongs to a different uid. The previous change blocked in waitid(WEXITED|WNOWAIT) on any EPERM for our own child. In the second case the leader never exits, so that wait would hang forever. Now a non-blocking waitid probe first confirms the pid is our own child; any other pid is never signalled and keeps the EPERM error. The leader is then killed directly, which is always permitted on one's own child and harmless on a zombie, and only then awaited without reaping, so the wait has a bounded end. Neither case has a deterministic reproduction: the first is a scheduling window inside process exit, and the second needs a cross-uid group member. Both follow from the killpg1() return rule. * fix: accept a child that already leads its group on setpgid races The forking test harnesses call lead_process_group() on both sides of the fork, and the parent's setpgid(child, child) can lose the race. Once the child has exec'd, setpgid() answers EACCES. Once it is exiting, has become a session leader or has left our session, it answers EPERM (xnu kern_prot.c setpgid()). macOS CI hits the EPERM case as "put the test daemon in its own group: Operation not permitted". The child makes the group itself first, so either error now counts as success when getpgid(child) == child. ESRCH from getpgid() means the child ended in between, which is success as it already is for setpgid(). Any other outcome is returned. There are two deterministic tests. Both spawn an exec'd child, so the parent's setpgid() is refused with EACCES: - a child that set its own group before exec is accepted; - a child left in our group is refused. Inverting the getpgid() comparison fails both. * refactor: delete the unused stream-compression reader and writer (#8260) * fix: guard the sender exit flush and drop the goodbye finalizer The goodbye handshake ran a finalizer between writing the sender's NDX_DONE and reading the receiver's reply. It only called finalize_compression(), which is a plain flush in production: no production path builds a Compressed ServerWriter, since compression is token-level as in upstream token.c. It also ran directly after the flush that follows NDX_DONE, so it could never move a byte. Upstream has no counterpart either. read_ndx_and_attrs() drains output in perform_io() before it blocks, which is the existing flush, and handle_goodbye_proto31_flushes_ndx_done_before_close already guards it. Remove the finalizer parameter from the goodbye methods. The orchestrator's exit flush is what upstream requires: main.c:1011 runs io_flush(FULL_FLUSH) after read_final_goodbye(), and cleanup.c:194-195 flushes again on exit_cleanup(0). That includes the empty-file-list early return at main.c:996-1001. Below protocol 30, send_file_list() leaves the list end and the io_error word buffered, and the multiplex writer has no flushing Drop. Without the flush the client never receives them. A new run()-level test fails with an empty wire when that flush is removed. * fix: wait out an exiting leader on macOS killpg; portable flush fixture kill_process_group on Apple treated EPERM as success only once waitid already reported the leader as ended. A leader that has begun exiting but is not yet waitable is skipped by XNU's killpg1() too, so the EPERM can arrive first, and the test harness's Drop panicked with "stop the test daemon N: Operation not permitted". This was seen on master's macOS tracing row (daemon_pull_default_send_zc_byte_identical) and on the iconv row here. EPERM for our own child now blocks in waitid until the leader has ended, without reaping it. The empty-file-list flush test relied on ENOTDIR from a path through a regular file, which Windows reports as not-found, so no io_error was raised there. Use a missing operand instead. The word is then 0, but the list end plus four io_error bytes still have to reach the wire, and with the early-return flush removed the wire carries no data at all. * fix: SIGKILL the leader before awaiting it on a macOS killpg EPERM XNU's killpg1() (bsd/kern/kern_sig.c) returns EPERM for a POSIX caller whenever it signalled no member of the group. That covers two cases. In the first, the leader is a zombie or is still exiting and not yet waitable. In the second, the leader is alive and the only other member belongs to a different uid. The previous change blocked in waitid(WEXITED|WNOWAIT) on any EPERM for our own child. In the second case the leader never exits, so that wait would hang forever. Now a non-blocking waitid probe first confirms the pid is our own child; any other pid is never signalled and keeps the EPERM error. The leader is then killed directly, which is always permitted on one's own child and harmless on a zombie, and only then awaited without reaping, so the wait has a bounded end. Neither case has a deterministic reproduction: the first is a scheduling window inside process exit, and the second needs a cross-uid group member. Both follow from the killpg1() return rule. * refactor: delete the unused stream-compression reader and writer Compression is token-level, as in upstream token.c, so no production path ever wrapped the multiplexed stream in a compressor. Nothing outside tests called ServerWriter::activate_compression*, ServerReader::activate_compression, CompressedWriter or CompressedReader. Delete them, their Compressed variants and match arms, finalize_compression (flush_all_pending is now a flush that tolerates a closed peer), and the tests that existed only to exercise them. ZstdStrategy::with_workers lost its only caller with CompressedWriter, so it goes too; the strategy builds its encoder single-threaded, which is what it already did for every caller.
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
Compression is token-level, as in upstream
token.c, so no production path ever wraps the multiplexed stream in a compressor. Nothing outside tests reaches the stream-compression layer.ServerWriter::Compressed,activate_compressionandactivate_compression_with_workers.ServerReader'sCompressedinner state andactivate_compression.CompressedWriterandCompressedReadermodules, and every match arm forwarding to them.finalize_compressionis gone.flush_all_pendingis now a flush that tolerates a closed peer, which is what it already did in production.ZstdStrategy::with_workersis gone. It lost its only caller withCompressedWriter, and the dead-code census flags it. The strategy builds its zstd encoder single-threaded, as it already did for every remaining caller.Test plan
cargo clippy --workspace --all-targets --all-features --no-deps -- -D warningscargo clippy -p transfer -p compress --all-targets --no-default-features -- -D warningscargo fmt --all -- --check;dead_code_census.py: OKcargo nextest run -p transfer -p compress -p core --all-features: 6911/6911Coordination
finalize_compression.Conventional commit prefix
refactor:Pre-merge checklist