Commit baa4d2f6 authored by Dag Erling Smørgrav's avatar Dag Erling Smørgrav

On Linux 2.6.8 and older, epoll_ctl(EPOLL_CTL_DEL) requires a poll_event

even though it is not used, and will return EFAULT if one is not provided.

Also, instead of silently accepting EBADF from epoll_ctl(), check that
sp->fd != -1 before calling vca_del().  This can happen in some cases
where vca_pollsession() closes the session before returning.  This way,
we will still get an assertion failure if epoll_ctl() fails for some
other (unexpected) reason.

Thanks to airmax for his assistance in tracking this down.

git-svn-id: http://www.varnish-cache.org/svn/trunk@1143 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 9bd5dd68
...@@ -62,10 +62,8 @@ vca_add(int fd, void *data) ...@@ -62,10 +62,8 @@ vca_add(int fd, void *data)
static void static void
vca_del(int fd) vca_del(int fd)
{ {
int i; struct epoll_event ev = { 0, { 0 } };
AZ(epoll_ctl(epfd, EPOLL_CTL_DEL, fd, &ev));
i = epoll_ctl(epfd, EPOLL_CTL_DEL, fd, NULL);
assert(i == 0 || errno == EBADF);
} }
static void static void
...@@ -103,6 +101,7 @@ vca_main(void *arg) ...@@ -103,6 +101,7 @@ vca_main(void *arg)
i = vca_pollsession(sp); i = vca_pollsession(sp);
if (i >= 0) { if (i >= 0) {
TAILQ_REMOVE(&sesshead, sp, list); TAILQ_REMOVE(&sesshead, sp, list);
if (sp->fd != -1)
vca_del(sp->fd); vca_del(sp->fd);
if (i == 0) if (i == 0)
vca_handover(sp, i); vca_handover(sp, i);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment