]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
errno-util: introduce ERRNO_IS_TRANSIENT()
authorYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 29 Nov 2021 18:39:35 +0000 (03:39 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 30 Nov 2021 14:06:43 +0000 (23:06 +0900)
src/basic/errno-util.h

index 8cd7de5bc89581c4f136a49b14d23585ec81fe54..09abf0b7512dc3fb2686ea8b2e6a44fe10892c82 100644 (file)
@@ -70,6 +70,13 @@ static inline int errno_or_else(int fallback) {
         return -abs(fallback);
 }
 
+/* For send()/recv() or read()/write(). */
+static inline bool ERRNO_IS_TRANSIENT(int r) {
+        return IN_SET(abs(r),
+                      EAGAIN,
+                      EINTR);
+}
+
 /* Hint #1: ENETUNREACH happens if we try to connect to "non-existing" special IP addresses, such as ::5.
  *
  * Hint #2: The kernel sends e.g., EHOSTUNREACH or ENONET to userspace in some ICMP error cases.  See the
@@ -100,10 +107,8 @@ static inline bool ERRNO_IS_DISCONNECT(int r) {
  * the accept(2) man page. */
 static inline bool ERRNO_IS_ACCEPT_AGAIN(int r) {
         return ERRNO_IS_DISCONNECT(r) ||
-                IN_SET(abs(r),
-                       EAGAIN,
-                       EINTR,
-                       EOPNOTSUPP);
+                ERRNO_IS_TRANSIENT(r) ||
+                abs(r) == EOPNOTSUPP;
 }
 
 /* Resource exhaustion, could be our fault or general system trouble */