mirror of
https://github.com/systemd/systemd
synced 2024-09-06 16:56:43 +00:00
errno-util: add new ERRNO_IS_ACCEPT_AGAIN() test
This is modelled after the existing ERRNO_IS_RESOURCES() and in particular ERRNO_IS_DISCONNECT(). It returns true for all transient network errors that should be handled like EAGAIN whenever we call accept() or accept4(). This is per documentation in the accept(2) man page that explicitly says to do so in the its "RETURN VALUE" section. The error list we cover is a bit more comprehensive, and based on existing code of ours. For example EINTR is included too (since we need that to cover cases where we call accept()/accept4() on a blocking socket), and of course ERRNO_IS_DISCONNECT() is a bit more comprehensive than the list in the man page too.
This commit is contained in:
parent
7f00010601
commit
fb0302ddbc
|
@ -50,6 +50,16 @@ static inline bool ERRNO_IS_DISCONNECT(int r) {
|
|||
ESHUTDOWN);
|
||||
}
|
||||
|
||||
/* Transient errors we might get on accept() that we should ignore. As per error handling comment in
|
||||
* 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);
|
||||
}
|
||||
|
||||
/* Resource exhaustion, could be our fault or general system trouble */
|
||||
static inline bool ERRNO_IS_RESOURCE(int r) {
|
||||
return IN_SET(abs(r),
|
||||
|
|
Loading…
Reference in a new issue