summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Franzke <benjaminfranzke@googlemail.com>2011-09-17 15:44:50 +0200
committerBenjamin Franzke <benjaminfranzke@googlemail.com>2011-09-17 15:44:50 +0200
commit8924cca09b0dc2c339b8a07743e25f28428c80e7 (patch)
treef4a2275467fd0d1efc53db92443c666a45a448ed
parent3198c2ad85115a14e0f7f0674d3506e58d6b8907 (diff)
wfdevent: Fix initialization of event queue
-rw-r--r--src/wfdevent.c60
1 files changed, 30 insertions, 30 deletions
diff --git a/src/wfdevent.c b/src/wfdevent.c
index 4868684..e15cac5 100644
--- a/src/wfdevent.c
+++ b/src/wfdevent.c
@@ -153,6 +153,20 @@ wfd_event_update(struct wfd_device *device,
return -1;
}
+ memset(&ep, 0, sizeof ep);
+ event->source_bind_event_queue_fd =
+ eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK | EFD_SEMAPHORE);
+ ep.events = EPOLLIN;
+ ep.data.fd = event->source_bind_event_queue_fd;
+ ret = epoll_ctl(event->epoll_fd, EPOLL_CTL_ADD,
+ ep.data.fd, &ep);
+ if (ret == -1) {
+ fprintf(stderr, "failed to add fd to epoll: %m\n");
+ return -1;
+ }
+
+ wf_list_init(&event->bind_event_queue);
+
event->filter |= WFD_EVENT_PIPELINE_BIND_SOURCE_COMPLETE_MASK;
} else if (removals & WFD_EVENT_PIPELINE_BIND_SOURCE_COMPLETE_MASK) {
ret = epoll_ctl(event->epoll_fd, EPOLL_CTL_DEL,
@@ -163,6 +177,22 @@ wfd_event_update(struct wfd_device *device,
}
close (event->drm_fd);
+
+ ret = epoll_ctl(event->epoll_fd, EPOLL_CTL_DEL,
+ event->source_bind_event_queue_fd, NULL);
+ if (ret) {
+ fprintf(stderr, "failed to del fd form epoll: %m\n");
+ return -1;
+ }
+ close(event->source_bind_event_queue_fd);
+
+ struct bind_event *entry, *next;
+ wf_list_for_each_safe(entry, next,
+ &event->bind_event_queue, link) {
+ wf_list_remove(&entry->link);
+ free(entry);
+
+ }
event->filter &= ~WFD_EVENT_PIPELINE_BIND_SOURCE_COMPLETE_MASK;
}
@@ -184,19 +214,6 @@ wfd_event_update(struct wfd_device *device,
}
}
- memset(&ep, 0, sizeof ep);
- event->source_bind_event_queue_fd =
- eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK | EFD_SEMAPHORE);
- ep.events = EPOLLIN;
- ep.data.fd = event->source_bind_event_queue_fd;
- ret = epoll_ctl(event->epoll_fd, EPOLL_CTL_ADD,
- ep.data.fd, &ep);
- if (ret == -1) {
- fprintf(stderr, "failed to add fd to epoll: %m\n");
- return -1;
- }
-
- wf_list_init(&event->bind_event_queue);
event->filter |= WFD_EVENT_PORT_ATTACH_DETACH;
} else if (removals & WFD_EVENT_PORT_ATTACH_DETACH) {
ret = epoll_ctl(event->epoll_fd, EPOLL_CTL_DEL,
@@ -209,23 +226,6 @@ wfd_event_update(struct wfd_device *device,
udev_monitor_unref(event->udev_monitor);
event->udev_monitor_fd = -1;
- ret = epoll_ctl(event->epoll_fd, EPOLL_CTL_DEL,
- event->source_bind_event_queue_fd, NULL);
- if (ret) {
- fprintf(stderr, "failed to del fd form epoll: %m\n");
- return -1;
- }
-
- close(event->source_bind_event_queue_fd);
-
- struct bind_event *entry, *next;
- wf_list_for_each_safe(entry, next,
- &event->bind_event_queue, link) {
- wf_list_remove(&entry->link);
- free(entry);
-
- }
-
event->filter &= ~WFD_EVENT_PORT_ATTACH_DETACH;
}