Repository navigation
fix(rw): fix WritePort retirement busy race and Stream zero-length << - #368
Merged
Merged
Conversation
[Medium impact] The PR appears safe to merge; no actionable issues were found.
|
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
Three commits separating the two behavior fixes from the cleanup/consistency refactor:
0e8b4fdfb—fix(rw): close BLOCK_DETACHED to IDLE busy race in WritePortWritePort::TryClaimProducer(Phase* failed_phase = nullptr)to record the observed non-IDLEphase on failure.failed_phase == Phase::BLOCK_DETACHEDinWritePort::operator()so a concurrentBLOCK_DETACHED -> IDLEretirement betweenTryClaimProducerandWaitForRetirementno longer falsely returnsErrorCode::BUSY, while preserving oversizedBLOCK_DETACHED -> BUSYprecedence and leaving non-BLOCK_DETACHEDphases returningErrorCode::BUSYwithout touchingadmission_waiter_.WaitForRetirementfallback fromLoadPhase() == Phase::IDLE && TryClaimProducer()toTryClaimProducer().test_rw_write_port_block_detached_retirement_raceintest/automatic/core/rw/write_port/test_write_port.cpp.fc5c3fcf2—fix(rw): align WritePort::Stream operator<< zero-length behavior with WriteWritePort::Stream::operator<<(const ConstRawData&)directly toUNUSED(Write(data)); return *this;so zero-length<<without port ownership neither claimsLOCKEDnor triggers empty completion/callback/POLLINGDONEtransitions on laterCommit()or destruction.port_->queue_data_ == nullptrchecks inWritePort::Stream::WriteandWritePort::Stream::EmptySize().VerifyStreamZeroShiftWithoutOwnershipintest/automatic/core/rw/write_stream/test_write_stream.cpp.16d60ab7a—refactor(rw): use PopBatch in WriteQueue::PopAll and hoist CAS initial loadsConsumeWithReader+std::memcpyinWritePort::WriteQueue::PopAllwithSPSCQueue::PopBatchand remove unused<cstring>.observed = state_.load(std::memory_order_acquire)loads outsidefor (;;)loops inCompleteRequest,WaitForRetirement, andWaitForBlock.Verification
ctest(Debug/ON,Release/ON,Release/OFF,LIBXR_TEST_BUILD=ON):9/10passed (test_linux_canskipped withoutCAP_NET_ADMINvcan),0failed; direct./test/libxr_test --case write_portand--case write_streampassed in all 3 configs (including repeatedwrite_portrace stress runs).LIBXR_SYSTEM=none(DebugandRelease,xrtarget): built cleanly with 0 warnings.tools/format_cpp_files.sh --check(clang-format 21.1.8) on touched files: passed.tools/check_doxygen_warnings.sh(doxygen 1.12.0): 933 warnings (matches baseline 933).git diff --check origin/dev..HEAD: clean.