apple / swift-nio-transport-services

Extensions for SwiftNIO to support Apple platforms as first-class citizens.
https://swiftpackageindex.com/apple/swift-nio-transport-services/main/documentation/niotransportservices
Apache License 2.0
282 stars 71 forks source link

Add defensive lifetime management for security metadata #152

Closed Lukasa closed 2 years ago

Lukasa commented 2 years ago

Motivation:

Right now we're playing a little fast and loose with the lifetimes of the sec_protocol_metadata_t. As a practical matter it is highly likely that this is owned (and so kept alive by) the NWConnection, but rather than risk that we should tighten up the lifetime management.

Modifications:

Use withExtendedLifetime to extend the lifetime.

Result:

Better lifetime management.