summaryrefslogtreecommitdiff
path: root/src/core/socket.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/socket.c')
-rw-r--r--src/core/socket.c44
1 files changed, 14 insertions, 30 deletions
diff --git a/src/core/socket.c b/src/core/socket.c
index b39bec2f26..b2a3e954cb 100644
--- a/src/core/socket.c
+++ b/src/core/socket.c
@@ -121,9 +121,7 @@ void socket_free_ports(Socket *s) {
sd_event_source_unref(p->event_source);
- if (p->fd >= 0)
- close_nointr_nofail(p->fd);
-
+ safe_close(p->fd);
free(p->path);
free(p);
}
@@ -700,7 +698,7 @@ static void socket_close_fds(Socket *s) {
if (p->fd < 0)
continue;
- close_nointr_nofail(p->fd);
+ p->fd = safe_close(p->fd);
/* One little note: we should never delete any sockets
* in the file system here! After all some other
@@ -709,8 +707,6 @@ static void socket_close_fds(Socket *s) {
* we delete sockets in the file system before we
* create a new one, not after we stopped using
* one! */
-
- p->fd = -1;
}
}
@@ -880,9 +876,7 @@ static int fifo_address_create(
fail:
label_context_clear();
-
- if (fd >= 0)
- close_nointr_nofail(fd);
+ safe_close(fd);
return r;
}
@@ -917,8 +911,7 @@ static int special_address_create(
return 0;
fail:
- if (fd >= 0)
- close_nointr_nofail(fd);
+ safe_close(fd);
return r;
}
@@ -977,9 +970,7 @@ static int mq_address_create(
return 0;
fail:
- if (fd >= 0)
- close_nointr_nofail(fd);
-
+ safe_close(fd);
return r;
}
@@ -1472,7 +1463,7 @@ static void socket_enter_running(Socket *s, int cfd) {
log_debug_unit(UNIT(s)->id, "Suppressing connection request on %s since unit stop is scheduled.", UNIT(s)->id);
if (cfd >= 0)
- close_nointr_nofail(cfd);
+ safe_close(cfd);
else {
/* Flush all sockets by closing and reopening them */
socket_close_fds(s);
@@ -1520,7 +1511,7 @@ static void socket_enter_running(Socket *s, int cfd) {
if (s->n_connections >= s->max_connections) {
log_warning_unit(UNIT(s)->id, "%s: Too many incoming connections (%u)", UNIT(s)->id, s->n_connections);
- close_nointr_nofail(cfd);
+ safe_close(cfd);
return;
}
@@ -1535,7 +1526,7 @@ static void socket_enter_running(Socket *s, int cfd) {
/* ENOTCONN is legitimate if TCP RST was received.
* This connection is over, but the socket unit lives on. */
- close_nointr_nofail(cfd);
+ safe_close(cfd);
return;
}
@@ -1586,9 +1577,7 @@ fail:
bus_error_message(&error, r));
socket_enter_stop_pre(s, SOCKET_FAILURE_RESOURCES);
-
- if (cfd >= 0)
- close_nointr_nofail(cfd);
+ safe_close(cfd);
}
static void socket_run_next(Socket *s) {
@@ -1819,8 +1808,7 @@ static int socket_deserialize_item(Unit *u, const char *key, const char *value,
break;
if (p) {
- if (p->fd >= 0)
- close_nointr_nofail(p->fd);
+ safe_close(p->fd);
p->fd = fdset_remove(fds, fd);
}
}
@@ -1839,8 +1827,7 @@ static int socket_deserialize_item(Unit *u, const char *key, const char *value,
break;
if (p) {
- if (p->fd >= 0)
- close_nointr_nofail(p->fd);
+ safe_close(p->fd);
p->fd = fdset_remove(fds, fd);
}
}
@@ -1859,8 +1846,7 @@ static int socket_deserialize_item(Unit *u, const char *key, const char *value,
break;
if (p) {
- if (p->fd >= 0)
- close_nointr_nofail(p->fd);
+ safe_close(p->fd);
p->fd = fdset_remove(fds, fd);
}
}
@@ -1878,8 +1864,7 @@ static int socket_deserialize_item(Unit *u, const char *key, const char *value,
break;
if (p) {
- if (p->fd >= 0)
- close_nointr_nofail(p->fd);
+ safe_close(p->fd);
p->fd = fdset_remove(fds, fd);
}
}
@@ -1897,8 +1882,7 @@ static int socket_deserialize_item(Unit *u, const char *key, const char *value,
break;
if (p) {
- if (p->fd >= 0)
- close_nointr_nofail(p->fd);
+ safe_close(p->fd);
p->fd = fdset_remove(fds, fd);
}
}