Files
swift-nio-ssl/Sources
SteveandCory Benfield 71034b87bc Avoid unconditional plaintext read buffer reallocations (#598)
### Motivation

Fixes #227.

`NIOSSLHandler` initially reserves one maximum TLS record, while the
read loop immediately asks for another record's worth of writable space
after consuming the first. Reserve two records up front so the normal
loop does not force an unconditional buffer growth.

The test-only capacity accessor follows the existing `ByteBufferBIO`
test seam pattern and verifies the reservation at handler installation.

### Testing

- Negative control on current `main`: expected 32768 bytes, received
16384
- Focused regression: passed
- Full macOS suite: 325 tests passed
- Production build with the Swift 6.3 CI warning, dependency-import, and
explicit-Sendable flags: passed
- Release benchmark package build: passed
- Renegotiation integration test: passed
- `git diff --check`: passed
- Commit signature: verified

### Maintainer note

This is a patch-level performance fix. The fork author cannot apply the
required `🔨 semver/patch` label to the upstream PR, so a maintainer will
need to add it.

Co-authored-by: Cory Benfield <lukasa@apple.com>
2026-09-07 17:52:56 +01:00
..