From d93ee5f7009bbd81631bd7f8493486051a732a23 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Mon, 21 May 2018 16:29:33 +0300 Subject: events: Extend the events_unwatch_fd() API with an event type If a single file descriptor is being watch for multiple event types, it will be present in multiple entries in the watch list. The events_unwatch_fd() function will remove the first entry regardless of its type, not allowing removal of a particular event type. Fix this by extending the events_unwatch_fd() API to take an event type, and remove the corresponding entry. Signed-off-by: Laurent Pinchart --- events.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'events.c') diff --git a/events.c b/events.c index 6fcca7d..dba054a 100644 --- a/events.c +++ b/events.c @@ -66,14 +66,14 @@ void events_watch_fd(struct events *events, int fd, enum event_type type, list_append(&event->list, &events->events); } -void events_unwatch_fd(struct events *events, int fd) +void events_unwatch_fd(struct events *events, int fd, enum event_type type) { struct event_fd *event = NULL; struct event_fd *entry; int maxfd = 0; list_for_each_entry(entry, &events->events, list) { - if (entry->fd == fd) + if (entry->fd == fd && entry->type == type) event = entry; else maxfd = max(maxfd, entry->fd); -- cgit v1.2.3