Skip to content

fix(io): treat a fully transferred read/write as success#319

Merged
sgerbino merged 1 commit into
cppalliance:developfrom
sgerbino:pr/read-write-full-transfer-success
Jun 17, 2026
Merged

fix(io): treat a fully transferred read/write as success#319
sgerbino merged 1 commit into
cppalliance:developfrom
sgerbino:pr/read-write-full-transfer-success

Conversation

@sgerbino

@sgerbino sgerbino commented Jun 16, 2026

Copy link
Copy Markdown
Collaborator

Resolves #257.
Resolves #258.

read and write reported any error_code surfaced by the final read_some/write_some, even when that completion delivered the last bytes and filled the buffer. A generic observer (when_any/when_all) then saw a completed transfer as a failure. The most common trigger is end-of-stream coincident with a full read (read_some returns [eof, n] that fills the buffer).

Report the contingency only when the buffer was not fully transferred: when n == buffer_size(buffers) the transfer succeeded and ec is success. Tighten the documented postcondition accordingly.

Codify the same invariant in the ReadStream and WriteStream concept contracts: a read_some/write_some that fills its buffer reports success, so n == buffer_size(buffers) implies no error (a coincident condition such as end-of-stream surfaces on a subsequent call).

Add a mock stream that reports a contingency in the same completion that transfers bytes (the test read/write streams report errors with zero bytes) and cover both the filled-is-success and short-transfer-is-reported cases.

read and write reported any error_code surfaced by the final
read_some/write_some, even when that completion delivered the last bytes
and filled the buffer. A generic observer (when_any/when_all) then saw a
completed transfer as a failure. The most common trigger is end-of-stream
coincident with a full read (read_some returns [eof, n] that fills the
buffer).

Report the contingency only when the buffer was not fully transferred:
when n == buffer_size(buffers) the transfer succeeded and ec is success.
Tighten the documented postcondition accordingly.

Codify the same invariant in the ReadStream and WriteStream concept
contracts: a read_some/write_some that fills its buffer reports success,
so n == buffer_size(buffers) implies no error (a coincident condition such
as end-of-stream surfaces on a subsequent call).

Add a mock stream that reports a contingency in the same completion that
transfers bytes (the test read/write streams report errors with zero
bytes) and cover both the filled-is-success and short-transfer-is-reported
cases.
@cppalliance-bot

Copy link
Copy Markdown

An automated preview of the documentation is available at https://319.capy.prtest3.cppalliance.org/index.html

If more commits are pushed to the pull request, the docs will rebuild at the same URL.

2026-06-16 19:25:12 UTC

@cppalliance-bot

Copy link
Copy Markdown

GCOVR code coverage report https://319.capy.prtest3.cppalliance.org/gcovr/index.html
LCOV code coverage report https://319.capy.prtest3.cppalliance.org/genhtml/index.html
Coverage Diff Report https://319.capy.prtest3.cppalliance.org/diff-report/index.html

Build time: 2026-06-16 19:41:20 UTC

@codecov

codecov Bot commented Jun 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.07%. Comparing base (4b27cdd) to head (0bccf0b).
⚠️ Report is 2 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #319      +/-   ##
===========================================
- Coverage    98.09%   98.07%   -0.03%     
===========================================
  Files          164      164              
  Lines         8873     8758     -115     
===========================================
- Hits          8704     8589     -115     
  Misses         169      169              
Flag Coverage Δ
linux 98.16% <ø> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
include/boost/capy/read.hpp 100.00% <ø> (ø)
include/boost/capy/write.hpp 100.00% <ø> (ø)

... and 10 files with indirect coverage changes


Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4b27cdd...0bccf0b. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@sgerbino sgerbino merged commit dba6a54 into cppalliance:develop Jun 17, 2026
37 of 38 checks passed
@sgerbino sgerbino deleted the pr/read-write-full-transfer-success branch June 17, 2026 13:02
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.

Nailing down read_some and write_some return values read, write return value when n == buffer_size(buffers)

2 participants