summaryrefslogtreecommitdiff
path: root/src/libsystemd/sd-daemon/sd-daemon.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2020-06-10 11:43:40 +0200
committerDaan De Meyer <daan.j.demeyer@gmail.com>2020-06-10 20:06:10 +0200
commit0f2d351f790516bc3f1158d964c5f83f339addb2 (patch)
treef9df08ab66c5c7be26c92e1767d39835cc9f472c /src/libsystemd/sd-daemon/sd-daemon.c
parent24bd74ae03efc98272236bd0a98a1d7d090d540c (diff)
downloadsystemd-0f2d351f790516bc3f1158d964c5f83f339addb2.tar.gz
tree-wide: port to fd_wait_for_event()
Prompted by the discussion on #16110, let's migrate more code to fd_wait_for_event(). This only leaves 7 places where we call into poll()/poll() directly in our entire codebase. (one of which is fd_wait_for_event() itself)
Diffstat (limited to 'src/libsystemd/sd-daemon/sd-daemon.c')
-rw-r--r--src/libsystemd/sd-daemon/sd-daemon.c12
1 files changed, 2 insertions, 10 deletions
diff --git a/src/libsystemd/sd-daemon/sd-daemon.c b/src/libsystemd/sd-daemon/sd-daemon.c
index 0bc0fc16ae..bbe7cd76d5 100644
--- a/src/libsystemd/sd-daemon/sd-daemon.c
+++ b/src/libsystemd/sd-daemon/sd-daemon.c
@@ -555,7 +555,6 @@ finish:
_public_ int sd_notify_barrier(int unset_environment, uint64_t timeout) {
_cleanup_close_pair_ int pipe_fd[2] = { -1, -1 };
- struct timespec ts;
int r;
if (pipe2(pipe_fd, O_CLOEXEC) < 0)
@@ -567,18 +566,11 @@ _public_ int sd_notify_barrier(int unset_environment, uint64_t timeout) {
pipe_fd[1] = safe_close(pipe_fd[1]);
- struct pollfd pfd = {
- .fd = pipe_fd[0],
- /* POLLHUP is implicit */
- .events = 0,
- };
- r = ppoll(&pfd, 1, timeout == UINT64_MAX ? NULL : timespec_store(&ts, timeout), NULL);
+ r = fd_wait_for_event(pipe_fd[0], 0 /* POLLHUP is implicit */, timeout);
if (r < 0)
- return -errno;
+ return r;
if (r == 0)
return -ETIMEDOUT;
- if (pfd.revents & POLLNVAL)
- return -EBADF;
return 1;
}