NIO: invalid sockets are not `-1` but `INVALID_SOCKET` (#1660)

Adjust the sentinel indicating an invalid socket.

Co-authored-by: Cory Benfield <lukasa@apple.com>
This commit is contained in:
Saleem Abdulrasool 2020-09-30 02:32:52 -07:00 committed by GitHub
parent bc328cd3a8
commit 0ae9524ca8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 0 deletions

View File

@ -475,7 +475,11 @@ class BaseSocket: BaseSocketProtocol {
/// - throws: An `IOError` if the operation failed.
final func takeDescriptorOwnership() throws -> NIOBSDSocket.Handle {
return try self.withUnsafeHandle {
#if os(Windows)
self.descriptor = INVALID_SOCKET
#else
self.descriptor = -1
#endif
return $0
}
}