NIOPosix: use wrapper function for duplicating file descriptor (#2173)

Use the wrapper function for duplicating the file descriptor.  This
allows us to swap out the implementation for different targets making
the code more portable.  It additionally adds additional error handling
and checking as the wrappers are intended to perform error handling.

Co-authored-by: Cory Benfield <lukasa@apple.com>
This commit is contained in:
Saleem Abdulrasool 2022-06-07 10:08:52 -07:00 committed by GitHub
parent 65c3f576b1
commit 4f20e48a78
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions

View File

@ -1096,7 +1096,7 @@ public final class NIOPipeBootstrap {
/// - returns: an `EventLoopFuture<Channel>` to deliver the `Channel`.
public func withInputOutputDescriptor(_ fileDescriptor: CInt) -> EventLoopFuture<Channel> {
let inputFD = fileDescriptor
let outputFD = dup(fileDescriptor)
let outputFD = try! Posix.dup(descriptor: fileDescriptor)
return self.withPipes(inputDescriptor: inputFD, outputDescriptor: outputFD).flatMapErrorThrowing { error in
try! Posix.close(descriptor: outputFD)