"EPOLL_CTL_MOD EBADF for "
"add_fde[%p] mpx_fde[%p] fd[%d] - disabling\n",
add_fde, mpx_fde, add_fde->fd);
- DLIST_REMOVE(epoll_ev->ev->fd_events, mpx_fde);
- mpx_fde->wrapper = NULL;
- mpx_fde->event_ctx = NULL;
- DLIST_REMOVE(epoll_ev->ev->fd_events, add_fde);
- add_fde->wrapper = NULL;
- add_fde->event_ctx = NULL;
+ tevent_common_fd_disarm(mpx_fde);
+ tevent_common_fd_disarm(add_fde);
return 0;
} else if (ret != 0) {
return ret;
"EPOLL_CTL_ADD EBADF for "
"fde[%p] mpx_fde[%p] fd[%d] - disabling\n",
fde, mpx_fde, fde->fd);
- DLIST_REMOVE(epoll_ev->ev->fd_events, fde);
- fde->wrapper = NULL;
- fde->event_ctx = NULL;
+ tevent_common_fd_disarm(fde);
if (mpx_fde != NULL) {
- DLIST_REMOVE(epoll_ev->ev->fd_events, mpx_fde);
- mpx_fde->wrapper = NULL;
- mpx_fde->event_ctx = NULL;
+ tevent_common_fd_disarm(mpx_fde);
}
return;
} else if (ret != 0 && errno == EEXIST && mpx_fde == NULL) {
"EPOLL_CTL_DEL EBADF for "
"fde[%p] mpx_fde[%p] fd[%d] - disabling\n",
fde, mpx_fde, fde->fd);
- DLIST_REMOVE(epoll_ev->ev->fd_events, fde);
- fde->wrapper = NULL;
- fde->event_ctx = NULL;
+ tevent_common_fd_disarm(fde);
if (mpx_fde != NULL) {
- DLIST_REMOVE(epoll_ev->ev->fd_events, mpx_fde);
- mpx_fde->wrapper = NULL;
- mpx_fde->event_ctx = NULL;
+ tevent_common_fd_disarm(mpx_fde);
}
return;
} else if (ret != 0) {
"EPOLL_CTL_MOD EBADF for "
"fde[%p] mpx_fde[%p] fd[%d] - disabling\n",
fde, mpx_fde, fde->fd);
- DLIST_REMOVE(epoll_ev->ev->fd_events, fde);
- fde->wrapper = NULL;
- fde->event_ctx = NULL;
+ tevent_common_fd_disarm(fde);
if (mpx_fde != NULL) {
- DLIST_REMOVE(epoll_ev->ev->fd_events, mpx_fde);
- mpx_fde->wrapper = NULL;
- mpx_fde->event_ctx = NULL;
+ tevent_common_fd_disarm(mpx_fde);
}
return;
} else if (ret != 0) {
void tevent_trace_queue_callback(struct tevent_context *ev,
struct tevent_queue_entry *qe,
enum tevent_event_trace_point);
+
+#include "tevent_dlinklist.h"
+
+static inline void tevent_common_fd_disarm(struct tevent_fd *fde)
+{
+ if (fde->event_ctx != NULL) {
+ tevent_trace_fd_callback(fde->event_ctx, fde,
+ TEVENT_EVENT_TRACE_DETACH);
+ DLIST_REMOVE(fde->event_ctx->fd_events, fde);
+ fde->event_ctx = NULL;
+ }
+ fde->wrapper = NULL;
+}