From be97c8e5bc8d32edaf969412a91abac93442cfc3 Mon Sep 17 00:00:00 2001 From: Johannes Weiss Date: Thu, 16 Aug 2018 15:13:02 +0100 Subject: [PATCH] output a hint if we get a reset connection w/o error set (#573) Motivation: We have one case in the code where we expect a socket error to be set when we hit a connection that got the `.reset` event. On Linux that's expected and therefore we just map this to `ECONNRESET`. On other platforms however that is unexpected. Now I just found an [Envoy commit](https://github.com/envoyproxy/envoy/commit/62f8e51bdd2d72cbac739087dabd3f51bdfc5cbd#diff-3315c7b2 91f78a482ebd4cbfc0545362R345) which suggests this might not work on FreeBSD. This should prompt our users to let us know if we ever see this error on non-Linux systems. Modifications: Add a message that makes it clear this is unexpected and link our ticket. Result: we should learn if this actually happens on macOS. Motivation: Explain here the context, and why you're making that change. What is the problem you're trying to solve. Modifications: Describe the modifications you've done. Result: After your change, what will change. --- Sources/NIO/BaseSocketChannel.swift | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Sources/NIO/BaseSocketChannel.swift b/Sources/NIO/BaseSocketChannel.swift index c9773a639..45a86c982 100644 --- a/Sources/NIO/BaseSocketChannel.swift +++ b/Sources/NIO/BaseSocketChannel.swift @@ -921,7 +921,12 @@ class BaseSocketChannel: SelectableChannel, ChannelCore { } else { // we don't have a socket error, this must be connection reset without an error then // this path should only be executed on Linux (EPOLLHUP, no EPOLLERR) - error = IOError(errnoCode: ECONNRESET, reason: "connection reset (no error set)") + #if os(Linux) + let message: String = "connection reset (no error set)" + #else + let message: String = "BUG IN SwiftNIO (possibly #572), please report! Connection reset (no error set)." + #endif + error = IOError(errnoCode: ECONNRESET, reason: message) } self.close0(error: error, mode: .all, promise: nil) } catch {