summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2009-04-08 21:33:01 +0200
committerVolker Lendecke <vl@samba.org>2009-04-08 22:17:03 +0200
commitf3d33cd81d53050f53fc46239bbb7f559dffd42c (patch)
tree99fb8c3469dc5021251397aff41a777fccc69667 /source3
parentcc98d3ae9f5c1aa29a6ccda2f88351431849e9fd (diff)
downloadsamba-f3d33cd81d53050f53fc46239bbb7f559dffd42c.tar.gz
samba-f3d33cd81d53050f53fc46239bbb7f559dffd42c.tar.bz2
samba-f3d33cd81d53050f53fc46239bbb7f559dffd42c.zip
Convert rpc_transport_np_init to tevent_req
Diffstat (limited to 'source3')
-rw-r--r--source3/include/proto.h10
-rw-r--r--source3/rpc_client/rpc_transport_np.c65
-rw-r--r--source3/rpc_client/rpc_transport_smbd.c14
3 files changed, 43 insertions, 46 deletions
diff --git a/source3/include/proto.h b/source3/include/proto.h
index b22bb06512..ad607cee69 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -5391,11 +5391,11 @@ NTSTATUS rpc_pipe_open_local(TALLOC_CTX *mem_ctx,
/* The following definitions come from rpc_client/rpc_transport_np.c */
-struct async_req *rpc_transport_np_init_send(TALLOC_CTX *mem_ctx,
- struct event_context *ev,
- struct cli_state *cli,
- const struct ndr_syntax_id *abstract_syntax);
-NTSTATUS rpc_transport_np_init_recv(struct async_req *req,
+struct tevent_req *rpc_transport_np_init_send(TALLOC_CTX *mem_ctx,
+ struct event_context *ev,
+ struct cli_state *cli,
+ const struct ndr_syntax_id *abstract_syntax);
+NTSTATUS rpc_transport_np_init_recv(struct tevent_req *req,
TALLOC_CTX *mem_ctx,
struct rpc_cli_transport **presult);
NTSTATUS rpc_transport_np_init(TALLOC_CTX *mem_ctx, struct cli_state *cli,
diff --git a/source3/rpc_client/rpc_transport_np.c b/source3/rpc_client/rpc_transport_np.c
index 730a309acf..40d68dd2ea 100644
--- a/source3/rpc_client/rpc_transport_np.c
+++ b/source3/rpc_client/rpc_transport_np.c
@@ -273,28 +273,28 @@ struct rpc_transport_np_init_state {
static void rpc_transport_np_init_pipe_open(struct tevent_req *subreq);
-struct async_req *rpc_transport_np_init_send(TALLOC_CTX *mem_ctx,
- struct event_context *ev,
- struct cli_state *cli,
- const struct ndr_syntax_id *abstract_syntax)
+struct tevent_req *rpc_transport_np_init_send(TALLOC_CTX *mem_ctx,
+ struct event_context *ev,
+ struct cli_state *cli,
+ const struct ndr_syntax_id *abstract_syntax)
{
- struct async_req *result;
- struct tevent_req *subreq;
+ struct tevent_req *req, *subreq;
struct rpc_transport_np_init_state *state;
- if (!async_req_setup(mem_ctx, &result, &state,
- struct rpc_transport_np_init_state)) {
+ req = tevent_req_create(mem_ctx, &state,
+ struct rpc_transport_np_init_state);
+ if (req == NULL) {
return NULL;
}
state->transport = talloc(state, struct rpc_cli_transport);
- if (state->transport == NULL) {
- goto fail;
+ if (tevent_req_nomem(state->transport, req)) {
+ return tevent_req_post(req, ev);
}
state->transport_np = talloc(state->transport,
struct rpc_transport_np_state);
- if (state->transport_np == NULL) {
- goto fail;
+ if (tevent_req_nomem(state->transport_np, req)) {
+ return tevent_req_post(req, ev);
}
state->transport->priv = state->transport_np;
@@ -306,47 +306,43 @@ struct async_req *rpc_transport_np_init_send(TALLOC_CTX *mem_ctx,
state, ev, cli, state->transport_np->pipe_name, 0,
DESIRED_ACCESS_PIPE, 0, FILE_SHARE_READ|FILE_SHARE_WRITE,
FILE_OPEN, 0, 0);
- if (subreq == NULL) {
- goto fail;
+ if (tevent_req_nomem(subreq, req)) {
+ return tevent_req_post(req, ev);
}
tevent_req_set_callback(subreq, rpc_transport_np_init_pipe_open,
- result);
- return result;
-
- fail:
- TALLOC_FREE(result);
- return NULL;
+ req);
+ return req;
}
static void rpc_transport_np_init_pipe_open(struct tevent_req *subreq)
{
- struct async_req *req = tevent_req_callback_data(
- subreq, struct async_req);
- struct rpc_transport_np_init_state *state = talloc_get_type_abort(
- req->private_data, struct rpc_transport_np_init_state);
+ struct tevent_req *req = tevent_req_callback_data(
+ subreq, struct tevent_req);
+ struct rpc_transport_np_init_state *state = tevent_req_data(
+ req, struct rpc_transport_np_init_state);
NTSTATUS status;
status = cli_ntcreate_recv(subreq, &state->transport_np->fnum);
TALLOC_FREE(subreq);
if (!NT_STATUS_IS_OK(status)) {
- async_req_nterror(req, status);
+ tevent_req_nterror(req, status);
return;
}
talloc_set_destructor(state->transport_np,
rpc_transport_np_state_destructor);
- async_req_done(req);
+ tevent_req_done(req);
}
-NTSTATUS rpc_transport_np_init_recv(struct async_req *req,
+NTSTATUS rpc_transport_np_init_recv(struct tevent_req *req,
TALLOC_CTX *mem_ctx,
struct rpc_cli_transport **presult)
{
- struct rpc_transport_np_init_state *state = talloc_get_type_abort(
- req->private_data, struct rpc_transport_np_init_state);
+ struct rpc_transport_np_init_state *state = tevent_req_data(
+ req, struct rpc_transport_np_init_state);
NTSTATUS status;
- if (async_req_is_nterror(req, &status)) {
+ if (tevent_req_is_nterror(req, &status)) {
return status;
}
@@ -367,8 +363,8 @@ NTSTATUS rpc_transport_np_init(TALLOC_CTX *mem_ctx, struct cli_state *cli,
{
TALLOC_CTX *frame = talloc_stackframe();
struct event_context *ev;
- struct async_req *req;
- NTSTATUS status;
+ struct tevent_req *req;
+ NTSTATUS status = NT_STATUS_OK;
ev = event_context_init(frame);
if (ev == NULL) {
@@ -382,8 +378,9 @@ NTSTATUS rpc_transport_np_init(TALLOC_CTX *mem_ctx, struct cli_state *cli,
goto fail;
}
- while (req->state < ASYNC_REQ_DONE) {
- event_loop_once(ev);
+ if (!tevent_req_poll(req, ev)) {
+ status = map_nt_error_from_unix(errno);
+ goto fail;
}
status = rpc_transport_np_init_recv(req, mem_ctx, presult);
diff --git a/source3/rpc_client/rpc_transport_smbd.c b/source3/rpc_client/rpc_transport_smbd.c
index 5a5433fb1c..16ec17e132 100644
--- a/source3/rpc_client/rpc_transport_smbd.c
+++ b/source3/rpc_client/rpc_transport_smbd.c
@@ -573,14 +573,15 @@ struct rpc_transport_smbd_init_state {
struct rpc_transport_smbd_state *transport_smbd;
};
-static void rpc_transport_smbd_init_done(struct async_req *subreq);
+static void rpc_transport_smbd_init_done(struct tevent_req *subreq);
struct async_req *rpc_transport_smbd_init_send(TALLOC_CTX *mem_ctx,
struct event_context *ev,
struct rpc_cli_smbd_conn *conn,
const struct ndr_syntax_id *abstract_syntax)
{
- struct async_req *result, *subreq;
+ struct async_req *result;
+ struct tevent_req *subreq;
struct rpc_transport_smbd_init_state *state;
if (!async_req_setup(mem_ctx, &result, &state,
@@ -610,8 +611,7 @@ struct async_req *rpc_transport_smbd_init_send(TALLOC_CTX *mem_ctx,
if (subreq == NULL) {
goto fail;
}
- subreq->async.fn = rpc_transport_smbd_init_done;
- subreq->async.priv = result;
+ tevent_req_set_callback(subreq, rpc_transport_smbd_init_done, result);
return result;
fail:
@@ -619,10 +619,10 @@ struct async_req *rpc_transport_smbd_init_send(TALLOC_CTX *mem_ctx,
return NULL;
}
-static void rpc_transport_smbd_init_done(struct async_req *subreq)
+static void rpc_transport_smbd_init_done(struct tevent_req *subreq)
{
- struct async_req *req = talloc_get_type_abort(
- subreq->async.priv, struct async_req);
+ struct async_req *req = tevent_req_callback_data(
+ subreq, struct async_req);
struct rpc_transport_smbd_init_state *state = talloc_get_type_abort(
req->private_data, struct rpc_transport_smbd_init_state);
NTSTATUS status;