diff options
Diffstat (limited to 'src/shared')
-rw-r--r-- | src/shared/util.c | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/src/shared/util.c b/src/shared/util.c index 5ad206a6c2..691a876872 100644 --- a/src/shared/util.c +++ b/src/shared/util.c @@ -829,6 +829,26 @@ bool nulstr_contains(const char*nulstr, const char *needle) { return false; } +int fd_wait_for_event(int fd, int event, usec_t t) { + + struct pollfd pollfd = { + .fd = fd, + .events = event, + }; + + struct timespec ts; + int r; + + r = ppoll(&pollfd, 1, t == USEC_INFINITY ? NULL : timespec_store(&ts, t), NULL); + if (r < 0) + return -errno; + + if (r == 0) + return 0; + + return pollfd.revents; +} + int fopen_temporary(const char *path, FILE **_f, char **_temp_path) { FILE *f; char *t; @@ -1190,26 +1210,6 @@ const char *signal_to_string(int signo) { return buf; } -int fd_wait_for_event(int fd, int event, usec_t t) { - - struct pollfd pollfd = { - .fd = fd, - .events = event, - }; - - struct timespec ts; - int r; - - r = ppoll(&pollfd, 1, t == USEC_INFINITY ? NULL : timespec_store(&ts, t), NULL); - if (r < 0) - return -errno; - - if (r == 0) - return 0; - - return pollfd.revents; -} - int fd_inc_sndbuf(int fd, size_t n) { int r, value; socklen_t l = sizeof(value); |