From 21cab71e75e7dd0f7d91e28e310e8b59af304aa6 Mon Sep 17 00:00:00 2001
From: Přemysl Janouch
Date: Wed, 24 Sep 2014 19:03:45 +0200
Subject: Fix the epoll poller
Setting the fd to -1 broke poller_remove_from_dispatch().
---
ponymap.c | 2 +-
utils.c | 3 ++-
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/ponymap.c b/ponymap.c
index 5fc486a..edcb935 100644
--- a/ponymap.c
+++ b/ponymap.c
@@ -534,7 +534,7 @@ unit_abort (struct unit *u)
poller_timer_reset (&u->timeout_event);
// This way we avoid a syscall with epoll
- u->fd_event.fd = -1;
+ u->fd_event.closed = true;
poller_fd_reset (&u->fd_event);
u->transport_data = NULL;
diff --git a/utils.c b/utils.c
index 8be61d6..f9246db 100644
--- a/utils.c
+++ b/utils.c
@@ -873,6 +873,7 @@ struct poller_fd
int fd; ///< Our file descriptor
short events; ///< The poll() events we registered for
+ bool closed; ///< Whether fd has been closed already
poller_fd_fn dispatcher; ///< Event dispatcher
void *user_data; ///< User data
@@ -1194,7 +1195,7 @@ poller_remove_at_index (struct poller *self, size_t index)
fd->index = -1;
poller_remove_from_dispatch (self, fd);
- if (fd->fd != -1)
+ if (!fd->closed)
hard_assert (epoll_ctl (self->epoll_fd,
EPOLL_CTL_DEL, fd->fd, (void *) "") != -1);
--
cgit v1.2.3-70-g09d2