mirror of
https://github.com/samba-team/samba.git
synced 2024-12-22 13:34:15 +03:00
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 <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
This commit is contained in:
parent
9ee3422a70
commit
4e1cc54c22
@ -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);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user