Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
wayland
wayland
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 94
    • Issues 94
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Merge Requests 24
    • Merge Requests 24
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
  • Operations
    • Operations
    • Incidents
    • Environments
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Analytics
    • Analytics
    • CI / CD
    • Repository
    • Value Stream
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • wayland
  • waylandwayland
  • Issues
  • #187

Closed
Open
Opened Jan 05, 2021 by Simon Ser@emersionOwner

Event sources marked with wl_event_source_check not dispatched after wl_event_loop_dispatch_idle

Create an event source registered with wl_event_source_check, for instance an event source for a Wayland connection to a remote compositor (code taken from Weston):

static int dispatch_events(int fd, uint32_t mask, void *data) {
	int count = 0;
	if (mask & WL_EVENT_READABLE) {
		count = wl_display_dispatch(wl->remote_display);
	}
	if (mask & WL_EVENT_WRITABLE) {
		wl_display_flush(wl->remote_display);
	}
	if (mask == 0) {
		count = wl_display_dispatch_pending(wl->remote_display);
		wl_display_flush(wl->remote_display);
	}
	return count;
}

[…]

int fd = wl_display_get_fd(remote_display);
uint32_t events = WL_EVENT_READABLE;
struct wl_event_source *event_source = wl_event_loop_add_fd(loop, fd, events, dispatch_events, NULL);
wl_event_source_check(event_source);

Setup an idle source, and send a request to the remote compositor from the idle source:

static void handle_idle(void *data) {
	wl_display_sync(remote_display);
}

wl_event_loop_add_idle(loop, handle_idle, NULL);

The request gets queued to the Wayland internal buffer, because WAYLAND_DEBUG=client shows it. The request doesn't get flushed to the parent compositor, because WAYLAND_DEBUG=server doesn't show it. Adding wl_display_flush after sending the request fixes the bug.

It seems like wl_event_loop_dispatch dispatches idle sources twice since 5ec8062d. However, checked sources are only dispatched after the second idle source dispatch, not the first. Should we dispatch checked sources twice too?

To upload designs, you'll need to enable LFS and have admin enable hashed storage. More information
Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None
Reference: wayland/wayland#187