Skip to content

Handle buffer end offsets as no-op. - #194

Merged
ioquatix merged 2 commits into
mainfrom
buffer-offset-boundary
Jun 25, 2026
Merged

Handle buffer end offsets as no-op.#194
ioquatix merged 2 commits into
mainfrom
buffer-offset-boundary

Conversation

@samuel-williams-shopify

Copy link
Copy Markdown
Contributor

Summary

  • add regression coverage for io_read/io_write when offset equals buffer size
  • return 0 before touching the IO for zero-capacity buffer operations
  • apply the boundary handling consistently to Select, KQueue, EPoll, and URing read/write paths

Verification

  • bundle exec rubocop
  • bundle exec bake test
  • git diff --check origin/main..HEAD

@samuel-williams-shopify samuel-williams-shopify changed the title Handle buffer end offsets as no-op Handle buffer end offsets as no-op. Jun 25, 2026
Assisted-By: devx/242ffd92-f36a-421a-88b9-270e5488162a
@samuel-williams-shopify
samuel-williams-shopify force-pushed the buffer-offset-boundary branch 4 times, most recently from a262a0f to d2dc0e3 Compare June 25, 2026 03:38
Assisted-By: devx/242ffd92-f36a-421a-88b9-270e5488162a

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR tightens boundary handling for buffered IO operations so that an offset equal to the buffer size is treated as a zero-capacity no-op (returning 0) rather than attempting to touch the underlying IO. This aligns behavior across the pure-Ruby Select selector and the native kqueue, epoll, and io_uring implementations, and adds regression coverage to prevent closed-IO side effects.

Changes:

  • Add regression tests for io_read/io_write returning 0 when offset == buffer.size.
  • Update Select selector Ruby implementation to return 0 for end-offset operations before invoking IO.
  • Update kqueue, epoll, and io_uring native paths to treat offset == size as a no-op and avoid descriptor/IO access in that case.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
test/io/event/selector/buffered_io.rb Adds regression tests covering offset == buffer.size returning 0 for read/write.
lib/io/event/selector/select.rb Adds explicit end-offset handling (offset == buffer.size => 0) for Select-based read/write.
ext/io/event/selector/uring.c Ensures end-offset returns 0 before descriptor/seek handling in io_uring read/write paths.
ext/io/event/selector/kqueue.c Refactors kqueue buffered read/write to early-return 0 on end-offset and operate on the remaining region.
ext/io/event/selector/epoll.c Refactors epoll buffered read/write similarly to handle end-offset as a no-op consistently.

@ioquatix
ioquatix merged commit 462a168 into main Jun 25, 2026
57 of 61 checks passed
@ioquatix
ioquatix deleted the buffer-offset-boundary branch June 25, 2026 03:57
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.

3 participants