From ef8130fdbf50384dca3669ab27de4863490d5cb1 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 28 Feb 2013 17:04:00 +0100 Subject: [PATCH] tevent: merge poll_fresh_fde_destructor() into poll_event_fd_destructor() Signed-off-by: Stefan Metzmacher Reviewed-by: Jeremy Allison --- lib/tevent/tevent_poll.c | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/lib/tevent/tevent_poll.c b/lib/tevent/tevent_poll.c index 6e1c5c39f2d..792abefd48c 100644 --- a/lib/tevent/tevent_poll.c +++ b/lib/tevent/tevent_poll.c @@ -219,25 +219,15 @@ static int poll_event_fd_destructor(struct tevent_fd *fde) poll_ev = talloc_get_type_abort( ev->additional_data, struct poll_event_context); - poll_ev->fdes[del_idx] = NULL; - poll_ev->deleted = true; - poll_event_wake_pollthread(poll_ev); -done: - return tevent_common_fd_destructor(fde); -} - -static int poll_fresh_fde_destructor(struct tevent_fd *fde) -{ - struct tevent_context *ev = fde->event_ctx; - struct poll_event_context *poll_ev; + if (del_idx == UINT64_MAX) { - if (ev == NULL) { + DLIST_REMOVE(poll_ev->fresh, fde); goto done; } - poll_ev = talloc_get_type_abort( - ev->additional_data, struct poll_event_context); - DLIST_REMOVE(poll_ev->fresh, fde); + poll_ev->fdes[del_idx] = NULL; + poll_ev->deleted = true; + poll_event_wake_pollthread(poll_ev); done: return tevent_common_fd_destructor(fde); } @@ -270,7 +260,7 @@ _PRIVATE_ void tevent_poll_event_add_fd_internal(struct tevent_context *ev, fde->additional_flags = UINT64_MAX; fde->additional_data = NULL; DLIST_ADD(poll_ev->fresh, fde); - talloc_set_destructor(fde, poll_fresh_fde_destructor); + talloc_set_destructor(fde, poll_event_fd_destructor); } /* @@ -454,8 +444,6 @@ static bool poll_event_setup_fresh(struct tevent_context *ev, DLIST_REMOVE(poll_ev->fresh, fde); DLIST_ADD(ev->fd_events, fde); - talloc_set_destructor(fde, poll_event_fd_destructor); - poll_ev->num_fds += 1; } return true; -- 2.11.4.GIT