aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2020-01-04 22:36:32 +0000
committerDaniel Eklöf <daniel@ekloef.se>2020-01-04 22:36:32 +0000
commitae829391586b73c2adf4559390f6803681392a99 (patch)
treecacaeb9cdf2b5ee8d252af457792af1105c575d2
parentwayland: add comment (diff)
wayland: wayl_flush: re-initialize fd array before each poll
-rw-r--r--wayland.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/wayland.c b/wayland.c
index 2e3378bf..2b950056 100644
--- a/wayland.c
+++ b/wayland.c
@@ -1004,22 +1004,30 @@ wayl_flush(struct wayland *wayl)
{
while (true) {
int r = wl_display_flush(wayl->display);
- if (r >= 0)
+ if (r >= 0) {
+ /* Most likely code path - the flush succeed */
return;
+ }
- if (errno == EINTR)
+ if (errno == EINTR) {
+ /* Unlikely */
continue;
+ }
if (errno != EAGAIN) {
LOG_ERRNO("failed to flush wayland socket");
return;
}
- struct pollfd fds[] = {
- {.fd = wl_display_get_fd(wayl->display), .events = POLLOUT}
- };
+ /* Socket buffer is full - need to wait for it to become
+ writeable again */
+ assert(errno == EAGAIN);
while (true) {
+ struct pollfd fds[] = {
+ {.fd = wl_display_get_fd(wayl->display), .events = POLLOUT},
+ };
+
r = poll(fds, sizeof(fds) / sizeof(fds[0]), -1);
if (r < 0) {