summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/basic/io-util.c9
-rw-r--r--src/libelogind/sd-login/sd-login.c7
2 files changed, 12 insertions, 4 deletions
diff --git a/src/basic/io-util.c b/src/basic/io-util.c
index 77c9bdc73..08ad42ed9 100644
--- a/src/basic/io-util.c
+++ b/src/basic/io-util.c
@@ -33,6 +33,7 @@ int flush_fd(int fd) {
.fd = fd,
.events = POLLIN,
};
+ int count = 0;
/* 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
@@ -52,7 +53,7 @@ int flush_fd(int fd) {
return -errno;
} else if (r == 0)
- return 0;
+ return count;
l = read(fd, buf, sizeof(buf));
if (l < 0) {
@@ -61,11 +62,13 @@ int flush_fd(int fd) {
continue;
if (errno == EAGAIN)
- return 0;
+ return count;
return -errno;
} else if (l == 0)
- return 0;
+ return count;
+
+ count += (int) l;
}
}
diff --git a/src/libelogind/sd-login/sd-login.c b/src/libelogind/sd-login/sd-login.c
index a7de8f1c1..bc5f83eb3 100644
--- a/src/libelogind/sd-login/sd-login.c
+++ b/src/libelogind/sd-login/sd-login.c
@@ -1091,10 +1091,15 @@ _public_ sd_login_monitor* sd_login_monitor_unref(sd_login_monitor *m) {
}
_public_ int sd_login_monitor_flush(sd_login_monitor *m) {
+ int r;
assert_return(m, -EINVAL);
- return flush_fd(MONITOR_TO_FD(m));
+ r = flush_fd(MONITOR_TO_FD(m));
+ if (r < 0)
+ return r;
+
+ return 0;
}
_public_ int sd_login_monitor_get_fd(sd_login_monitor *m) {