Close timer file descriptors in event loop on remove and failure.

When the timer is removed the corresponding fd is closed. This should
automatically remove it from the epoll set.
This commit is contained in:
Iskren Chernev 2011-03-13 21:05:14 +02:00
parent 61ce8749a7
commit 1081bca2a8

View file

@ -171,13 +171,10 @@ wl_event_source_timer_remove(struct wl_event_source *source)
{ {
struct wl_event_source_timer *timer_source = struct wl_event_source_timer *timer_source =
(struct wl_event_source_timer *) source; (struct wl_event_source_timer *) source;
struct wl_event_loop *loop = source->loop;
int fd;
fd = timer_source->fd; close(timer_source->fd);
free(source); free(source);
return 0;
return epoll_ctl(loop->epoll_fd, EPOLL_CTL_DEL, fd, NULL);
} }
struct wl_event_source_interface timer_source_interface = { struct wl_event_source_interface timer_source_interface = {
@ -215,6 +212,7 @@ wl_event_loop_add_timer(struct wl_event_loop *loop,
ep.data.ptr = source; ep.data.ptr = source;
if (epoll_ctl(loop->epoll_fd, EPOLL_CTL_ADD, source->fd, &ep) < 0) { if (epoll_ctl(loop->epoll_fd, EPOLL_CTL_ADD, source->fd, &ep) < 0) {
close(source->fd);
free(source); free(source);
return NULL; return NULL;
} }