From 8189399e9d6a2e17e8d5b4665c86efb696792f56 Mon Sep 17 00:00:00 2001 From: Norman Maurer Date: Thu, 22 Mar 2018 14:03:46 +0100 Subject: [PATCH] Ignore EINTR on close(...) as there is nothing sane we can do. Motivation: If close(...) reports EINTR there is nothing sane we can do so it makes no sense to even report it. See also: https://github.com/apple/swift-nio/pull/217 Modifications: Just ignore EINTR when calling close(...) Result: Less noise in the logs. --- .../src/main/c/netty_unix_filedescriptor.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/transport-native-unix-common/src/main/c/netty_unix_filedescriptor.c b/transport-native-unix-common/src/main/c/netty_unix_filedescriptor.c index 36632b1cad..d13ffb0d1c 100644 --- a/transport-native-unix-common/src/main/c/netty_unix_filedescriptor.c +++ b/transport-native-unix-common/src/main/c/netty_unix_filedescriptor.c @@ -79,7 +79,15 @@ static jint _read(JNIEnv* env, jclass clazz, jint fd, void* buffer, jint pos, ji // JNI Registered Methods Begin static jint netty_unix_filedescriptor_close(JNIEnv* env, jclass clazz, jint fd) { if (close(fd) < 0) { - return -errno; + // There is really nothing "sane" we can do when EINTR was reported on close. So just ignore it and "assume" + // everything is fine == we closed the file descriptor. + // + // For more details see: + // - https://bugs.chromium.org/p/chromium/issues/detail?id=269623 + // - https://lwn.net/Articles/576478/ + if (errno != EINTR) { + return -errno; + } } return 0; }