Stop when Wayland library has a fatal error #1153
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently, if one abruptly disconnects their Wayland connection socket (for example, by killing the compositor but not the demo program), I observe example programs getting stuck in the following lines as part of an infinite loop.
After the socket is disconnected, libwayland will start returning -1 to all subsequent calls of functions that can return an error (like
wl_display_dispatch_pending()
, but notwl_display_prepare_read()
), and silently do nothing when functions are called. As a result, it should be safe to delay checking for error and breaking out of the main loop until the finalwl_display_dispatch_pending()
call. (Eagerly checking for errors is possible but would make the code rather more complicated, aswl_display_flush()
can have transient/EAGAIN failures.)(The current code was added in commit b69f87d, which likely used the function call pattern recommended by the Wayland documentation (see wl_display_prepare_read_queue()); however, the example given there does not properly check for errors.)