Files
ruby/test/socket
Samuel Williams 11f6d3d68b Flush buffered data in BasicSocket#close_write before shutdown. (#18900)
When a socket has buffered output (`sync == false`) and `#close_write` is
called, the write side was shut down via `shutdown(SHUT_WR)` without first
flushing the buffer. This had two bad consequences:

- the buffered bytes were silently dropped (never delivered to the peer);
- a subsequent `#close` tried to flush the still-populated write buffer
  into the now `shutdown(SHUT_WR)` socket and raised `Errno::EPIPE`.

Flush the buffer before shutting down the write side, matching the
write-only branch (which flushes via `rb_io_close`) and the non-socket
`IO#close_write` path. `IO#close_write` for a plain `IO` wrapping a socket
fd is fixed in the same way.

Assisted-By: devx/2c064143-8655-4631-a7cd-6395bb241bdc
2026-09-18 03:36:26 +00:00
..