s3:tevent_wait: simplify the code by using tevent_req_defer_callback()
authorStefan Metzmacher <metze@samba.org>
Thu, 18 Sep 2014 20:54:23 +0000 (22:54 +0200)
committerStefan Metzmacher <metze@samba.org>
Tue, 19 May 2015 14:37:52 +0000 (16:37 +0200)
This way a user of this could also use tevent_req_error() or wrappers.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
Autobuild-User(master): Stefan Metzmacher <metze@samba.org>
Autobuild-Date(master): Tue May 19 16:37:52 CEST 2015 on sn-devel-104

source3/lib/tevent_wait.c

index 81fb213251974c23b8d572b2159dc4d2521365f1..31bb581d52a42f9d10ddbc70b5d728bd646a95d4 100644 (file)
@@ -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);
 }