mirror of
https://github.com/samba-team/samba.git
synced 2025-01-25 06:04:04 +03:00
tevent: add tevent_context destructor that unlinks the events from the context
metze
This commit is contained in:
parent
e240ca5bdd
commit
b09718fef2
@ -136,6 +136,35 @@ const char **tevent_backend_list(TALLOC_CTX *mem_ctx)
|
||||
return list;
|
||||
}
|
||||
|
||||
int tevent_common_context_destructor(struct tevent_context *ev)
|
||||
{
|
||||
struct tevent_fd *fd;
|
||||
struct tevent_timer *te;
|
||||
struct tevent_signal *se;
|
||||
|
||||
if (ev->pipe_fde) {
|
||||
talloc_free(ev->pipe_fde);
|
||||
ev->pipe_fde = NULL;
|
||||
}
|
||||
|
||||
for (fd=ev->fd_events; fd; fd = fd->next) {
|
||||
fd->event_ctx = NULL;
|
||||
DLIST_REMOVE(ev->fd_events, fd);
|
||||
}
|
||||
|
||||
for (te=ev->timer_events; te; te = te->next) {
|
||||
te->event_ctx = NULL;
|
||||
DLIST_REMOVE(ev->timer_events, te);
|
||||
}
|
||||
|
||||
for (se=ev->signal_events; se; se = se->next) {
|
||||
se->event_ctx = NULL;
|
||||
DLIST_REMOVE(ev->signal_events, se);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
create a event_context structure for a specific implemementation.
|
||||
This must be the first events call, and all subsequent calls pass
|
||||
@ -156,6 +185,8 @@ static struct tevent_context *tevent_context_init_ops(TALLOC_CTX *mem_ctx,
|
||||
ev = talloc_zero(mem_ctx, struct tevent_context);
|
||||
if (!ev) return NULL;
|
||||
|
||||
talloc_set_destructor(ev, tevent_common_context_destructor);
|
||||
|
||||
ev->ops = ops;
|
||||
|
||||
ret = ev->ops->context_init(ev);
|
||||
|
@ -152,6 +152,8 @@ struct tevent_context {
|
||||
|
||||
bool tevent_register_backend(const char *name, const struct tevent_ops *ops);
|
||||
|
||||
int tevent_common_context_destructor(struct tevent_context *ev);
|
||||
|
||||
int tevent_common_fd_destructor(struct tevent_fd *fde);
|
||||
struct tevent_fd *tevent_common_add_fd(struct tevent_context *ev,
|
||||
TALLOC_CTX *mem_ctx,
|
||||
|
Loading…
x
Reference in New Issue
Block a user