1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2025-01-22 22:03:43 +03:00

errno-util: introduce ERRNO_IS_TRANSIENT()

This commit is contained in:
Yu Watanabe 2021-11-30 03:39:35 +09:00
parent 16edfadc67
commit 7aad83580f

View 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 */