diff options
author | Stefan Metzmacher <metze@samba.org> | 2014-01-08 10:31:15 +0100 |
---|---|---|
committer | Stefan Metzmacher <metze@samba.org> | 2014-01-17 12:38:08 +0100 |
commit | c84fe17ba954d2784cc1ac5f9e1f3a8302ca951d (patch) | |
tree | 410df24847bd436f857d1a9655794f6844c73734 /source3 | |
parent | f08c0b2ef1bb92928ae86ba9d1c276a8e117367c (diff) | |
download | samba-c84fe17ba954d2784cc1ac5f9e1f3a8302ca951d.tar.gz |
s3:lib/fncall: make use of tevent_req_set_cleanup_fn()
This is more better than a custom tevent_req destructor.
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Diffstat (limited to 'source3')
-rw-r--r-- | source3/lib/fncall.c | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/source3/lib/fncall.c b/source3/lib/fncall.c index fb3d5c9887c..7f728ba0158 100644 --- a/source3/lib/fncall.c +++ b/source3/lib/fncall.c @@ -122,7 +122,8 @@ static int fncall_next_job_id(struct fncall_context *ctx) } static void fncall_unset_pending(struct tevent_req *req); -static int fncall_destructor(struct tevent_req *req); +static void fncall_cleanup(struct tevent_req *req, + enum tevent_req_state req_state); static bool fncall_set_pending(struct tevent_req *req, struct fncall_context *ctx, @@ -141,12 +142,12 @@ static bool fncall_set_pending(struct tevent_req *req, pending[num_pending] = req; num_pending += 1; ctx->pending = pending; - talloc_set_destructor(req, fncall_destructor); + tevent_req_set_cleanup_fn(req, fncall_cleanup); /* * Make sure that the orphaned array of fncall_state structs has * enough space. A job can change from pending to orphaned in - * fncall_destructor, and to fail in a talloc destructor should be + * fncall_cleanup, and to fail in a talloc destructor should be * avoided if possible. */ @@ -184,6 +185,8 @@ static void fncall_unset_pending(struct tevent_req *req) int num_pending = talloc_array_length(ctx->pending); int i; + tevent_req_set_cleanup_fn(req, NULL); + if (num_pending == 1) { TALLOC_FREE(ctx->fde); TALLOC_FREE(ctx->pending); @@ -205,16 +208,24 @@ static void fncall_unset_pending(struct tevent_req *req) num_pending - 1); } -static int fncall_destructor(struct tevent_req *req) +static void fncall_cleanup(struct tevent_req *req, + enum tevent_req_state req_state) { struct fncall_state *state = tevent_req_data( req, struct fncall_state); struct fncall_context *ctx = state->ctx; + switch (req_state) { + case TEVENT_REQ_RECEIVED: + break; + default: + return; + } + fncall_unset_pending(req); if (state->done) { - return 0; + return; } /* @@ -223,8 +234,6 @@ static int fncall_destructor(struct tevent_req *req) */ ctx->orphaned[ctx->num_orphaned] = talloc_move(ctx->orphaned, &state); ctx->num_orphaned += 1; - - return 0; } struct tevent_req *fncall_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev, |