mirror of
https://github.com/apple/swift-nio-extras
synced 2026-11-27 05:04:22 +00:00
Keep zlib streams at stable addresses (#321)
### Motivation: zlib stores the address of `z_stream` in its internal state and expects that address to remain stable across calls. Storing `z_stream` inline in movable Swift value types does not provide that guarantee and can cause `Z_STREAM_ERROR` during cleanup. Fixes #308. ### Modifications: - Make the internal compressor and decompressor reference owners of separately allocated `z_stream` storage. - Pass the stable pointer to every zlib initialization, processing, and cleanup call. - Keep lifecycle state with the pointer owner and make conditional cleanup idempotent. - Add regression tests covering failed initialization recovery, multiple compression and decompression calls, repeated lifecycles, and deallocation cleanup. ### Result: zlib observes the same `z_stream` address for each complete lifecycle, while stream cleanup remains single-owner and safe against repeated shutdown.
This commit is contained in:
1 parent
aedcd7e2d4
commit
4ba1f167a7
6 files changed
+194
-59
No files matched your search
@@ -51,7 +51,7 @@ public final class NIOHTTPRequestCompressor: ChannelOutboundHandler, RemovableCh
|
||||
/// handler state
|
||||
var state: State
|
||||
/// compression handler
|
||||
var compressor: NIOCompression.Compressor
|
||||
let compressor: NIOCompression.Compressor
|
||||
/// pending write promise
|
||||
var pendingWritePromise: EventLoopPromise<Void>!
|
||||
|
||||
|
||||
Reference in new issue
Block a user