summaryrefslogtreecommitdiff
path: root/src/basic/io-util.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2016-05-06 13:29:26 +0200
committerSven Eden <yamakuzure@gmx.net>2017-06-16 10:12:58 +0200
commit5489ba3e334d21609a042d5dc1615323f2903181 (patch)
tree74a66114654c4971d320566b698457af03cb9430 /src/basic/io-util.c
parent0cac4e30259e4d9b8654f19bc252042a575705ba (diff)
core: rework how we flush incoming traffic when a socket unit goes down
Previously, we'd simply close and reopen the socket file descriptors. This is problematic however, as we won't transition through the SOCKET_CHOWN state then, and thus the file ownership won't be correct for the sockets. Rework the flushing logic, and actually read any queued data from the sockets for flushing, and accept any queued messages and disconnect them.
Diffstat (limited to 'src/basic/io-util.c')
-rw-r--r--src/basic/io-util.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/basic/io-util.c b/src/basic/io-util.c
index 0037a37f2..cc6dfa8c1 100644
--- a/src/basic/io-util.c
+++ b/src/basic/io-util.c
@@ -33,6 +33,11 @@ int flush_fd(int fd) {
.events = POLLIN,
};
+ /* Read from the specified file descriptor, until POLLIN is not set anymore, throwing away everything
+ * read. Note that some file descriptors (notable IP sockets) will trigger POLLIN even when no data can be read
+ * (due to IP packet checksum mismatches), hence this function is only safe to be non-blocking if the fd used
+ * was set to non-blocking too. */
+
for (;;) {
char buf[LINE_MAX];
ssize_t l;