mirror of
https://github.com/systemd/systemd-stable.git
synced 2024-12-23 17:34:00 +03:00
socket-util: cache result of socket_ipv6_is_supported()
And while we are at it, log about unexpected errors.
This commit is contained in:
parent
b0ffd2760c
commit
571ec995fe
@ -277,10 +277,23 @@ const char* socket_address_get_path(const SocketAddress *a) {
|
||||
}
|
||||
|
||||
bool socket_ipv6_is_supported(void) {
|
||||
if (access("/proc/net/if_inet6", F_OK) != 0)
|
||||
return false;
|
||||
static int cached = -1;
|
||||
|
||||
return true;
|
||||
if (cached < 0) {
|
||||
|
||||
if (access("/proc/net/if_inet6", F_OK) < 0) {
|
||||
|
||||
if (errno != ENOENT) {
|
||||
log_debug_errno(errno, "Unexpected error when checking whether /proc/net/if_inet6 exists: %m");
|
||||
return false;
|
||||
}
|
||||
|
||||
cached = false;
|
||||
} else
|
||||
cached = true;
|
||||
}
|
||||
|
||||
return cached;
|
||||
}
|
||||
|
||||
bool socket_address_matches_fd(const SocketAddress *a, int fd) {
|
||||
|
Loading…
Reference in New Issue
Block a user