X Tutup
Skip to content

Commit f60a028

Browse files
committed
tree-wide: use ERRNO_IS_DISCONNECT() at more places
1 parent dd90e39 commit f60a028

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

src/core/manager.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3056,7 +3056,7 @@ void manager_send_unit_plymouth(Manager *m, Unit *u) {
30563056
}
30573057

30583058
if (connect(fd, &sa.sa, SOCKADDR_UN_LEN(sa.un)) < 0) {
3059-
if (!IN_SET(errno, EPIPE, EAGAIN, ENOENT, ECONNREFUSED, ECONNRESET, ECONNABORTED))
3059+
if (!IN_SET(errno, EAGAIN, ENOENT) && !ERRNO_IS_DISCONNECT(errno))
30603060
log_error_errno(errno, "connect() failed: %m");
30613061
return;
30623062
}
@@ -3068,7 +3068,7 @@ void manager_send_unit_plymouth(Manager *m, Unit *u) {
30683068

30693069
errno = 0;
30703070
if (write(fd, message, n + 1) != n + 1)
3071-
if (!IN_SET(errno, EPIPE, EAGAIN, ENOENT, ECONNREFUSED, ECONNRESET, ECONNABORTED))
3071+
if (!IN_SET(errno, EAGAIN, ENOENT) && !ERRNO_IS_DISCONNECT(errno))
30723072
log_error_errno(errno, "Failed to write Plymouth message: %m");
30733073
}
30743074

src/libsystemd/sd-bus/sd-bus.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include "bus-util.h"
2929
#include "cgroup-util.h"
3030
#include "def.h"
31+
#include "errno-util.h"
3132
#include "fd-util.h"
3233
#include "hexdecoct.h"
3334
#include "hostname-util.h"
@@ -1928,7 +1929,7 @@ _public_ int sd_bus_send(sd_bus *bus, sd_bus_message *_m, uint64_t *cookie) {
19281929

19291930
r = bus_write_message(bus, m, &idx);
19301931
if (r < 0) {
1931-
if (IN_SET(r, -ENOTCONN, -ECONNRESET, -EPIPE, -ESHUTDOWN)) {
1932+
if (ERRNO_IS_DISCONNECT(r)) {
19321933
bus_enter_closing(bus);
19331934
return -ECONNRESET;
19341935
}
@@ -2224,7 +2225,7 @@ _public_ int sd_bus_call(
22242225

22252226
r = bus_read_message(bus, false, 0);
22262227
if (r < 0) {
2227-
if (IN_SET(r, -ENOTCONN, -ECONNRESET, -EPIPE, -ESHUTDOWN)) {
2228+
if (ERRNO_IS_DISCONNECT(r)) {
22282229
bus_enter_closing(bus);
22292230
r = -ECONNRESET;
22302231
}
@@ -2257,7 +2258,7 @@ _public_ int sd_bus_call(
22572258

22582259
r = dispatch_wqueue(bus);
22592260
if (r < 0) {
2260-
if (IN_SET(r, -ENOTCONN, -ECONNRESET, -EPIPE, -ESHUTDOWN)) {
2261+
if (ERRNO_IS_DISCONNECT(r)) {
22612262
bus_enter_closing(bus);
22622263
r = -ECONNRESET;
22632264
}
@@ -3015,7 +3016,7 @@ static int bus_process_internal(sd_bus *bus, bool hint_priority, int64_t priorit
30153016
assert_not_reached("Unknown state");
30163017
}
30173018

3018-
if (IN_SET(r, -ENOTCONN, -ECONNRESET, -EPIPE, -ESHUTDOWN)) {
3019+
if (ERRNO_IS_DISCONNECT(r)) {
30193020
bus_enter_closing(bus);
30203021
r = 1;
30213022
} else if (r < 0)
@@ -3146,7 +3147,7 @@ _public_ int sd_bus_flush(sd_bus *bus) {
31463147
for (;;) {
31473148
r = dispatch_wqueue(bus);
31483149
if (r < 0) {
3149-
if (IN_SET(r, -ENOTCONN, -ECONNRESET, -EPIPE, -ESHUTDOWN)) {
3150+
if (ERRNO_IS_DISCONNECT(r)) {
31503151
bus_enter_closing(bus);
31513152
return -ECONNRESET;
31523153
}

src/socket-proxy/socket-proxyd.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "sd-resolve.h"
1717

1818
#include "alloc-util.h"
19+
#include "errno-util.h"
1920
#include "fd-util.h"
2021
#include "log.h"
2122
#include "main-func.h"
@@ -29,8 +30,8 @@
2930
#include "util.h"
3031

3132
#define BUFFER_SIZE (256 * 1024)
32-
static unsigned arg_connections_max = 256;
3333

34+
static unsigned arg_connections_max = 256;
3435
static const char *arg_remote_host = NULL;
3536

3637
typedef struct Context {
@@ -141,7 +142,7 @@ static int connection_shovel(
141142
if (z > 0) {
142143
*full += z;
143144
shoveled = true;
144-
} else if (z == 0 || IN_SET(errno, EPIPE, ECONNRESET)) {
145+
} else if (z == 0 || ERRNO_IS_DISCONNECT(errno)) {
145146
*from_source = sd_event_source_unref(*from_source);
146147
*from = safe_close(*from);
147148
} else if (!IN_SET(errno, EAGAIN, EINTR))
@@ -153,7 +154,7 @@ static int connection_shovel(
153154
if (z > 0) {
154155
*full -= z;
155156
shoveled = true;
156-
} else if (z == 0 || IN_SET(errno, EPIPE, ECONNRESET)) {
157+
} else if (z == 0 || ERRNO_IS_DISCONNECT(errno)) {
157158
*to_source = sd_event_source_unref(*to_source);
158159
*to = safe_close(*to);
159160
} else if (!IN_SET(errno, EAGAIN, EINTR))

0 commit comments

Comments
 (0)
X Tutup