---
/* epoll documentation suggests that closing a FD
automatically removes it from the epoll set; however,
this is not true as if we fail to do manually remove it,
we are still seeing an event for this fd in epoll,
causing grief (use-after-free...) --- at least on my
system. */
if (0 != epoll_ctl (daemon->epoll_fd,
EPOLL_CTL_DEL,
pos->socket_fd,
NULL))
MHD_PANIC ("Failed to remove FD from epoll set\n");
pos->epoll_state &= ~MHD_EPOLL_STATE_IN_EPOLL_SET;
}
#endif
if (NULL != pos->response)
{
MHD_destroy_response (pos->response);
pos->response = NULL;
}
if (MHD_INVALID_SOCKET != pos->socket_fd)
{
#ifdef WINDOWS
shutdown (pos->socket_fd, SHUT_WR);
#endif
if (0 != MHD_socket_close_ (pos->socket_fd))
MHD_PANIC ("close failed\n"); }
---
Thanks, Mark