From 4e1cc54c222f6274f28fec39579655b62ab73f2c Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 18 Sep 2014 22:54:23 +0200 Subject: [PATCH] s3:tevent_wait: simplify the code by using tevent_req_defer_callback() This way a user of this could also use tevent_req_error() or wrappers. Signed-off-by: Stefan Metzmacher Reviewed-by: Michael Adam Autobuild-User(master): Stefan Metzmacher Autobuild-Date(master): Tue May 19 16:37:52 CEST 2015 on sn-devel-104 --- source3/lib/tevent_wait.c | 27 +++------------------------ 1 file changed, 3 insertions(+), 24 deletions(-) diff --git a/source3/lib/tevent_wait.c b/source3/lib/tevent_wait.c index 81fb2132519..31bb581d52a 100644 --- a/source3/lib/tevent_wait.c +++ b/source3/lib/tevent_wait.c @@ -24,8 +24,7 @@ #include "lib/util/tevent_unix.h" struct tevent_wait_state { - struct tevent_immediate *im; - struct tevent_context *ev; + uint8_t _dummy_; }; struct tevent_req *tevent_wait_send(TALLOC_CTX *mem_ctx, @@ -38,37 +37,17 @@ struct tevent_req *tevent_wait_send(TALLOC_CTX *mem_ctx, if (req == NULL) { return NULL; } - state->ev = ev; - state->im = tevent_create_immediate(state); - if (tevent_req_nomem(state->im, req)) { - return tevent_req_post(req, ev); - } + + tevent_req_defer_callback(req, ev); return req; } -static void tevent_wait_trigger(struct tevent_context *ctx, - struct tevent_immediate *im, - void *private_data); - void tevent_wait_done(struct tevent_req *req) { - struct tevent_wait_state *state; - if (req == NULL) { return; } - state = tevent_req_data(req, struct tevent_wait_state); - tevent_schedule_immediate(state->im, state->ev, - tevent_wait_trigger, req); -} - -static void tevent_wait_trigger(struct tevent_context *ctx, - struct tevent_immediate *im, - void *private_data) -{ - struct tevent_req *req = talloc_get_type_abort( - private_data, struct tevent_req); tevent_req_done(req); }