From: Ray Strode Date: Tue, 16 Jul 2019 13:50:37 +0000 (+0000) Subject: Revert "Merge branch 'bugfix' into 'master'" X-Git-Tag: 0.9.5~53^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cd389d5ca304c44938599cefa3461716d0630005;p=thirdparty%2Fplymouth.git Revert "Merge branch 'bugfix' into 'master'" This reverts merge request !46 --- diff --git a/src/libply/ply-utils.c b/src/libply/ply-utils.c index 71a520f2..0cadae96 100644 --- a/src/libply/ply-utils.c +++ b/src/libply/ply-utils.c @@ -386,6 +386,36 @@ ply_read_uint32 (int fd, return true; } +bool +ply_fd_has_data (int fd) +{ + struct pollfd poll_data; + int result; + + poll_data.fd = fd; + poll_data.events = POLLIN | POLLPRI; + poll_data.revents = 0; + result = poll (&poll_data, 1, 10); + + return result == 1 + && ((poll_data.revents & POLLIN) + || (poll_data.revents & POLLPRI)); +} + +bool +ply_fd_can_take_data (int fd) +{ + struct pollfd poll_data; + int result; + + poll_data.fd = fd; + poll_data.events = POLLOUT; + poll_data.revents = 0; + result = poll (&poll_data, 1, 10); + + return result == 1; +} + bool ply_fd_may_block (int fd) { diff --git a/src/libply/ply-utils.h b/src/libply/ply-utils.h index 8295e73f..4dd9c09a 100644 --- a/src/libply/ply-utils.h +++ b/src/libply/ply-utils.h @@ -80,6 +80,8 @@ bool ply_read_uint32 (int fd, uint32_t *value); bool ply_fd_has_data (int fd); +bool ply_fd_can_take_data (int fd); +bool ply_fd_may_block (int fd); bool ply_set_fd_as_blocking (int fd); char **ply_copy_string_array (const char *const *array); void ply_free_string_array (char **array);