From f60a028a4e8633245592370264665ba203a56193 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 19 Mar 2019 15:39:34 +0100 Subject: [PATCH] tree-wide: use ERRNO_IS_DISCONNECT() at more places --- src/core/manager.c | 4 ++-- src/libsystemd/sd-bus/sd-bus.c | 11 ++++++----- src/socket-proxy/socket-proxyd.c | 7 ++++--- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/core/manager.c b/src/core/manager.c index eecf48dea5..22d1fda2dc 100644 --- a/src/core/manager.c +++ b/src/core/manager.c @@ -3056,7 +3056,7 @@ void manager_send_unit_plymouth(Manager *m, Unit *u) { } if (connect(fd, &sa.sa, SOCKADDR_UN_LEN(sa.un)) < 0) { - if (!IN_SET(errno, EPIPE, EAGAIN, ENOENT, ECONNREFUSED, ECONNRESET, ECONNABORTED)) + if (!IN_SET(errno, EAGAIN, ENOENT) && !ERRNO_IS_DISCONNECT(errno)) log_error_errno(errno, "connect() failed: %m"); return; } @@ -3068,7 +3068,7 @@ void manager_send_unit_plymouth(Manager *m, Unit *u) { errno = 0; if (write(fd, message, n + 1) != n + 1) - if (!IN_SET(errno, EPIPE, EAGAIN, ENOENT, ECONNREFUSED, ECONNRESET, ECONNABORTED)) + if (!IN_SET(errno, EAGAIN, ENOENT) && !ERRNO_IS_DISCONNECT(errno)) log_error_errno(errno, "Failed to write Plymouth message: %m"); } diff --git a/src/libsystemd/sd-bus/sd-bus.c b/src/libsystemd/sd-bus/sd-bus.c index f7177963c2..3df7c86b89 100644 --- a/src/libsystemd/sd-bus/sd-bus.c +++ b/src/libsystemd/sd-bus/sd-bus.c @@ -28,6 +28,7 @@ #include "bus-util.h" #include "cgroup-util.h" #include "def.h" +#include "errno-util.h" #include "fd-util.h" #include "hexdecoct.h" #include "hostname-util.h" @@ -1928,7 +1929,7 @@ _public_ int sd_bus_send(sd_bus *bus, sd_bus_message *_m, uint64_t *cookie) { r = bus_write_message(bus, m, &idx); if (r < 0) { - if (IN_SET(r, -ENOTCONN, -ECONNRESET, -EPIPE, -ESHUTDOWN)) { + if (ERRNO_IS_DISCONNECT(r)) { bus_enter_closing(bus); return -ECONNRESET; } @@ -2224,7 +2225,7 @@ _public_ int sd_bus_call( r = bus_read_message(bus, false, 0); if (r < 0) { - if (IN_SET(r, -ENOTCONN, -ECONNRESET, -EPIPE, -ESHUTDOWN)) { + if (ERRNO_IS_DISCONNECT(r)) { bus_enter_closing(bus); r = -ECONNRESET; } @@ -2257,7 +2258,7 @@ _public_ int sd_bus_call( r = dispatch_wqueue(bus); if (r < 0) { - if (IN_SET(r, -ENOTCONN, -ECONNRESET, -EPIPE, -ESHUTDOWN)) { + if (ERRNO_IS_DISCONNECT(r)) { bus_enter_closing(bus); r = -ECONNRESET; } @@ -3015,7 +3016,7 @@ static int bus_process_internal(sd_bus *bus, bool hint_priority, int64_t priorit assert_not_reached("Unknown state"); } - if (IN_SET(r, -ENOTCONN, -ECONNRESET, -EPIPE, -ESHUTDOWN)) { + if (ERRNO_IS_DISCONNECT(r)) { bus_enter_closing(bus); r = 1; } else if (r < 0) @@ -3146,7 +3147,7 @@ _public_ int sd_bus_flush(sd_bus *bus) { for (;;) { r = dispatch_wqueue(bus); if (r < 0) { - if (IN_SET(r, -ENOTCONN, -ECONNRESET, -EPIPE, -ESHUTDOWN)) { + if (ERRNO_IS_DISCONNECT(r)) { bus_enter_closing(bus); return -ECONNRESET; } diff --git a/src/socket-proxy/socket-proxyd.c b/src/socket-proxy/socket-proxyd.c index bac5c164d4..fc7e4958be 100644 --- a/src/socket-proxy/socket-proxyd.c +++ b/src/socket-proxy/socket-proxyd.c @@ -16,6 +16,7 @@ #include "sd-resolve.h" #include "alloc-util.h" +#include "errno-util.h" #include "fd-util.h" #include "log.h" #include "main-func.h" @@ -29,8 +30,8 @@ #include "util.h" #define BUFFER_SIZE (256 * 1024) -static unsigned arg_connections_max = 256; +static unsigned arg_connections_max = 256; static const char *arg_remote_host = NULL; typedef struct Context { @@ -141,7 +142,7 @@ static int connection_shovel( if (z > 0) { *full += z; shoveled = true; - } else if (z == 0 || IN_SET(errno, EPIPE, ECONNRESET)) { + } else if (z == 0 || ERRNO_IS_DISCONNECT(errno)) { *from_source = sd_event_source_unref(*from_source); *from = safe_close(*from); } else if (!IN_SET(errno, EAGAIN, EINTR)) @@ -153,7 +154,7 @@ static int connection_shovel( if (z > 0) { *full -= z; shoveled = true; - } else if (z == 0 || IN_SET(errno, EPIPE, ECONNRESET)) { + } else if (z == 0 || ERRNO_IS_DISCONNECT(errno)) { *to_source = sd_event_source_unref(*to_source); *to = safe_close(*to); } else if (!IN_SET(errno, EAGAIN, EINTR))