From 916a9ec7c6ad0e58a44457f9ea832f16350f5b74 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 10 Apr 2019 19:38:37 +0200 Subject: [PATCH] errno-util: add three more error codes to ERRNO_IS_DISCONNECT() This is based on the recommendations in accept4() and the listed error codes there. --- src/basic/errno-util.h | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/basic/errno-util.h b/src/basic/errno-util.h index 615b6a806a8..f2677c7c19c 100644 --- a/src/basic/errno-util.h +++ b/src/basic/errno-util.h @@ -32,11 +32,23 @@ static inline int negative_errno(void) { * * Hint #2: The kernel sends e.g., EHOSTUNREACH or ENONET to userspace in some ICMP error cases. See the * icmp_err_convert[] in net/ipv4/icmp.c in the kernel sources */ -#define ERRNO_IS_DISCONNECT(r) \ - IN_SET(abs(r), \ - ENOTCONN, ECONNRESET, ECONNREFUSED, ECONNABORTED, EPIPE, \ - ENETUNREACH, EHOSTUNREACH, ENOPROTOOPT, EHOSTDOWN, \ - ENONET, ESHUTDOWN) +static inline bool ERRNO_IS_DISCONNECT(int r) { + return IN_SET(abs(r), + ECONNABORTED, + ECONNREFUSED, + ECONNRESET, + EHOSTDOWN, + EHOSTUNREACH, + ENETDOWN, + ENETRESET, + ENETUNREACH, + ENONET, + ENOPROTOOPT, + ENOTCONN, + EPIPE, + EPROTO, + ESHUTDOWN); +} /* Resource exhaustion, could be our fault or general system trouble */ #define ERRNO_IS_RESOURCE(r) \ -- 2.47.3