Skip to content

Commit

Permalink
tevent_poll: Use the poll_event_context_destructor always
Browse files Browse the repository at this point in the history
This is in preparation for the next patch to NULL out the event_ctx
pointers in the poll_ev->fresh list

Signed-off-by: Volker Lendecke <[email protected]>
Reviewed-by: Stefan Metzmacher <[email protected]>
Reviewed-by: Jeremy Allison <[email protected]>
  • Loading branch information
vlendec authored and jrasamba committed Feb 3, 2013
1 parent e330985 commit 3ce58cb
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions lib/tevent/tevent_poll.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,18 @@ struct poll_event_context {
int exit_code;
};

static int poll_event_mt_destructor(struct poll_event_context *poll_ev)
static int poll_event_context_destructor(struct poll_event_context *poll_ev)
{
if (poll_ev->signal_fd != -1) {
close(poll_ev->signal_fd);
poll_ev->signal_fd = -1;
if (poll_ev->signal_fd == -1) {
/*
* Non-threaded, no signal pipe
*/
return 0;
}

close(poll_ev->signal_fd);
poll_ev->signal_fd = -1;

if (poll_ev->num_fds == 0) {
return 0;
}
Expand All @@ -85,6 +91,7 @@ static int poll_event_context_init(struct tevent_context *ev)
poll_ev->ev = ev;
poll_ev->signal_fd = -1;
ev->additional_data = poll_ev;
talloc_set_destructor(poll_ev, poll_event_context_destructor);
return 0;
}

Expand Down Expand Up @@ -140,7 +147,7 @@ static int poll_event_context_init_mt(struct tevent_context *ev)

poll_ev->num_fds = 1;

talloc_set_destructor(poll_ev, poll_event_mt_destructor);
talloc_set_destructor(poll_ev, poll_event_context_destructor);

return 0;
}
Expand Down

0 comments on commit 3ce58cb

Please sign in to comment.