Skip to content

Commit

Permalink
ozone/wayland: stop polling on any error.
Browse files Browse the repository at this point in the history
The wayland-protocols say the following about the
wl_display_get_error() method:

-----------------------------------
"Errors are fatal. If this function
returns non-zero the display can no
longer be used."
-----------------------------------

Thus, stop processing events and shutdown the browser on any error.

Bug: 1173630
Change-Id: I064d35eb65bf663bb26725fa92572da050a1eadd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2690322
Reviewed-by: Robert Kroeger <rjkroege@chromium.org>
Commit-Queue: Maksim Sisov <msisov@igalia.com>
Cr-Commit-Position: refs/heads/master@{#854071}
  • Loading branch information
msisov authored and Chromium LUCI CQ committed Feb 15, 2021
1 parent 8e47d96 commit 7e9aeaf
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions ui/ozone/platform/wayland/host/wayland_event_watcher.cc
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ void WaylandEventWatcher::OnFileCanReadWithoutBlocking(int fd) {

if (prepared_) {
prepared_ = false;
// Errors will be checked the next time OnFileCanReadWithoutBlocking calls
// CheckForErrors.
if (wl_display_read_events(display_) == -1)
return;
wl_display_dispatch_pending(display_);
Expand Down Expand Up @@ -115,17 +117,26 @@ void WaylandEventWatcher::MaybePrepareReadQueue() {
}

bool WaylandEventWatcher::CheckForErrors() {
// Errors are fatal. If this function returns non-zero the display can no
// longer be used.
int err = wl_display_get_error(display_);

// TODO(crbug.com/1172305): Wayland display_error message should be printed
// automatically by wl_log(). However, wl_log() does not print anything. Needs
// investigation.
if (err == EPROTO) {
uint32_t ec, id;
const struct wl_interface* intf;
ec = wl_display_get_protocol_error(display_, &intf, &id);
LOG(ERROR) << "Fatal Wayland protocol error " << ec << " on interface "
<< intf->name << " (object " << id << "). Shutting down..";
if (err) {
// When |err| is EPROTO, we can still use the |display_| to retrieve the
// protocol error. Otherwise, get the error string from strerror and
// shutdown the browser.
if (err == EPROTO) {
uint32_t ec, id;
const struct wl_interface* intf;
ec = wl_display_get_protocol_error(display_, &intf, &id);
LOG(ERROR) << "Fatal Wayland protocol error " << ec << " on interface "
<< intf->name << " (object " << id << "). Shutting down..";
} else {
LOG(ERROR) << "Fatal Wayland communication error: " << std::strerror(err);
}

// This can be null in tests.
if (!shutdown_cb_.is_null())
Expand Down

0 comments on commit 7e9aeaf

Please sign in to comment.