mirror of
https://gitlab.freedesktop.org/wayland/wayland.git
synced 2025-10-31 22:25:25 -04:00
client: Use read preparation API in wl_display_dispatch_queue()
Instead of doing things that do the equivalent of using wl_display_prepare_read() and friends, just use the public API. The only semantical difference is that we will now unlock and lock the mutex more times compared to before. Signed-off-by: Jonas Ådahl <jadahl@gmail.com> Reviewed-by: Daniel Stone <daniels@collabora.com>
This commit is contained in:
parent
c767f35b12
commit
689fff36ca
1 changed files with 10 additions and 35 deletions
|
|
@ -1488,30 +1488,17 @@ wl_display_dispatch_queue(struct wl_display *display,
|
||||||
struct pollfd pfd[2];
|
struct pollfd pfd[2];
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
pthread_mutex_lock(&display->mutex);
|
if (wl_display_prepare_read_queue(display, queue) == -1)
|
||||||
|
return wl_display_dispatch_queue_pending(display, queue);
|
||||||
|
|
||||||
ret = dispatch_queue(display, queue);
|
/* Don't stop if flushing hits an EPIPE; continue so we can read any
|
||||||
if (ret == -1)
|
* protocol error that may have triggered it. */
|
||||||
goto err_unlock;
|
ret = wl_display_flush(display);
|
||||||
if (ret > 0) {
|
|
||||||
pthread_mutex_unlock(&display->mutex);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* We ignore EPIPE here, so that we try to read events before
|
|
||||||
* returning an error. When the compositor sends an error it
|
|
||||||
* will close the socket, and if we bail out here we don't get
|
|
||||||
* a chance to process the error. */
|
|
||||||
ret = wl_connection_flush(display->connection);
|
|
||||||
if (ret < 0 && errno != EAGAIN && errno != EPIPE) {
|
if (ret < 0 && errno != EAGAIN && errno != EPIPE) {
|
||||||
display_fatal_error(display, errno);
|
wl_display_cancel_read(display);
|
||||||
goto err_unlock;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
display->reader_count++;
|
|
||||||
|
|
||||||
pthread_mutex_unlock(&display->mutex);
|
|
||||||
|
|
||||||
pfd[0].fd = display->fd;
|
pfd[0].fd = display->fd;
|
||||||
pfd[0].events = POLLIN;
|
pfd[0].events = POLLIN;
|
||||||
do {
|
do {
|
||||||
|
|
@ -1523,22 +1510,10 @@ wl_display_dispatch_queue(struct wl_display *display,
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
pthread_mutex_lock(&display->mutex);
|
if (wl_display_read_events(display) == -1)
|
||||||
|
return -1;
|
||||||
|
|
||||||
if (read_events(display) == -1)
|
return wl_display_dispatch_queue_pending(display, queue);
|
||||||
goto err_unlock;
|
|
||||||
|
|
||||||
ret = dispatch_queue(display, queue);
|
|
||||||
if (ret == -1)
|
|
||||||
goto err_unlock;
|
|
||||||
|
|
||||||
pthread_mutex_unlock(&display->mutex);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
err_unlock:
|
|
||||||
pthread_mutex_unlock(&display->mutex);
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Dispatch pending events in an event queue
|
/** Dispatch pending events in an event queue
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue