summaryrefslogtreecommitdiff
path: root/source3/rpc_client
diff options
context:
space:
mode:
Diffstat (limited to 'source3/rpc_client')
-rw-r--r--source3/rpc_client/cli_pipe.c18
-rw-r--r--source3/rpc_client/rpc_transport_np.c119
-rw-r--r--source3/rpc_client/rpc_transport_smbd.c237
3 files changed, 184 insertions, 190 deletions
diff --git a/source3/rpc_client/cli_pipe.c b/source3/rpc_client/cli_pipe.c
index 6b83c170f5..a8cc33f585 100644
--- a/source3/rpc_client/cli_pipe.c
+++ b/source3/rpc_client/cli_pipe.c
@@ -2291,19 +2291,24 @@ NTSTATUS rpc_api_pipe_req(TALLOC_CTX *mem_ctx, struct rpc_pipe_client *cli,
TALLOC_CTX *frame = talloc_stackframe();
struct event_context *ev;
struct tevent_req *req;
- NTSTATUS status = NT_STATUS_NO_MEMORY;
+ NTSTATUS status = NT_STATUS_OK;
ev = event_context_init(frame);
if (ev == NULL) {
+ status = NT_STATUS_NO_MEMORY;
goto fail;
}
req = rpc_api_pipe_req_send(frame, ev, cli, op_num, in_data);
if (req == NULL) {
+ status = NT_STATUS_NO_MEMORY;
goto fail;
}
- tevent_req_poll(req, ev);
+ if (!tevent_req_poll(req, ev)) {
+ status = map_nt_error_from_unix(errno);
+ goto fail;
+ }
status = rpc_api_pipe_req_recv(req, mem_ctx, out_data);
fail:
@@ -2905,19 +2910,24 @@ NTSTATUS rpc_pipe_bind(struct rpc_pipe_client *cli,
TALLOC_CTX *frame = talloc_stackframe();
struct event_context *ev;
struct tevent_req *req;
- NTSTATUS status = NT_STATUS_NO_MEMORY;
+ NTSTATUS status = NT_STATUS_OK;
ev = event_context_init(frame);
if (ev == NULL) {
+ status = NT_STATUS_NO_MEMORY;
goto fail;
}
req = rpc_pipe_bind_send(frame, ev, cli, auth);
if (req == NULL) {
+ status = NT_STATUS_NO_MEMORY;
goto fail;
}
- tevent_req_poll(req, ev);
+ if (!tevent_req_poll(req, ev)) {
+ status = map_nt_error_from_unix(errno);
+ goto fail;
+ }
status = rpc_pipe_bind_recv(req);
fail:
diff --git a/source3/rpc_client/rpc_transport_np.c b/source3/rpc_client/rpc_transport_np.c
index 8b45cb4e9c..40d68dd2ea 100644
--- a/source3/rpc_client/rpc_transport_np.c
+++ b/source3/rpc_client/rpc_transport_np.c
@@ -49,7 +49,7 @@ struct rpc_np_write_state {
size_t written;
};
-static void rpc_np_write_done(struct async_req *subreq);
+static void rpc_np_write_done(struct tevent_req *subreq);
static struct tevent_req *rpc_np_write_send(TALLOC_CTX *mem_ctx,
struct event_context *ev,
@@ -58,8 +58,7 @@ static struct tevent_req *rpc_np_write_send(TALLOC_CTX *mem_ctx,
{
struct rpc_transport_np_state *np_transport = talloc_get_type_abort(
priv, struct rpc_transport_np_state);
- struct tevent_req *req;
- struct async_req *subreq;
+ struct tevent_req *req, *subreq;
struct rpc_np_write_state *state;
req = tevent_req_create(mem_ctx, &state, struct rpc_np_write_state);
@@ -72,21 +71,17 @@ static struct tevent_req *rpc_np_write_send(TALLOC_CTX *mem_ctx,
np_transport->fnum,
8, /* 8 means message mode. */
data, 0, size);
- if (subreq == NULL) {
- goto fail;
+ if (tevent_req_nomem(subreq, req)) {
+ return tevent_req_post(req, ev);
}
- subreq->async.fn = rpc_np_write_done;
- subreq->async.priv = req;
+ tevent_req_set_callback(subreq, rpc_np_write_done, req);
return req;
- fail:
- TALLOC_FREE(req);
- return NULL;
}
-static void rpc_np_write_done(struct async_req *subreq)
+static void rpc_np_write_done(struct tevent_req *subreq)
{
- struct tevent_req *req = talloc_get_type_abort(
- subreq->async.priv, struct tevent_req);
+ struct tevent_req *req = tevent_req_callback_data(
+ subreq, struct tevent_req);
struct rpc_np_write_state *state = tevent_req_data(
req, struct rpc_np_write_state);
NTSTATUS status;
@@ -119,7 +114,7 @@ struct rpc_np_read_state {
ssize_t received;
};
-static void rpc_np_read_done(struct async_req *subreq);
+static void rpc_np_read_done(struct tevent_req *subreq);
static struct tevent_req *rpc_np_read_send(TALLOC_CTX *mem_ctx,
struct event_context *ev,
@@ -128,8 +123,7 @@ static struct tevent_req *rpc_np_read_send(TALLOC_CTX *mem_ctx,
{
struct rpc_transport_np_state *np_transport = talloc_get_type_abort(
priv, struct rpc_transport_np_state);
- struct tevent_req *req;
- struct async_req *subreq;
+ struct tevent_req *req, *subreq;
struct rpc_np_read_state *state;
req = tevent_req_create(mem_ctx, &state, struct rpc_np_read_state);
@@ -144,18 +138,17 @@ static struct tevent_req *rpc_np_read_send(TALLOC_CTX *mem_ctx,
if (subreq == NULL) {
goto fail;
}
- subreq->async.fn = rpc_np_read_done;
- subreq->async.priv = req;
+ tevent_req_set_callback(subreq, rpc_np_read_done, req);
return req;
fail:
TALLOC_FREE(req);
return NULL;
}
-static void rpc_np_read_done(struct async_req *subreq)
+static void rpc_np_read_done(struct tevent_req *subreq)
{
- struct tevent_req *req = talloc_get_type_abort(
- subreq->async.priv, struct tevent_req);
+ struct tevent_req *req = tevent_req_callback_data(
+ subreq, struct tevent_req);
struct rpc_np_read_state *state = tevent_req_data(
req, struct rpc_np_read_state);
NTSTATUS status;
@@ -204,7 +197,7 @@ struct rpc_np_trans_state {
uint32_t rdata_len;
};
-static void rpc_np_trans_done(struct async_req *subreq);
+static void rpc_np_trans_done(struct tevent_req *subreq);
static struct tevent_req *rpc_np_trans_send(TALLOC_CTX *mem_ctx,
struct event_context *ev,
@@ -214,8 +207,7 @@ static struct tevent_req *rpc_np_trans_send(TALLOC_CTX *mem_ctx,
{
struct rpc_transport_np_state *np_transport = talloc_get_type_abort(
priv, struct rpc_transport_np_state);
- struct tevent_req *req;
- struct async_req *subreq;
+ struct tevent_req *req, *subreq;
struct rpc_np_trans_state *state;
req = tevent_req_create(mem_ctx, &state, struct rpc_np_trans_state);
@@ -233,8 +225,7 @@ static struct tevent_req *rpc_np_trans_send(TALLOC_CTX *mem_ctx,
if (subreq == NULL) {
goto fail;
}
- subreq->async.fn = rpc_np_trans_done;
- subreq->async.priv = req;
+ tevent_req_set_callback(subreq, rpc_np_trans_done, req);
return req;
fail:
@@ -242,10 +233,10 @@ static struct tevent_req *rpc_np_trans_send(TALLOC_CTX *mem_ctx,
return NULL;
}
-static void rpc_np_trans_done(struct async_req *subreq)
+static void rpc_np_trans_done(struct tevent_req *subreq)
{
- struct tevent_req *req = talloc_get_type_abort(
- subreq->async.priv, struct tevent_req);
+ struct tevent_req *req = tevent_req_callback_data(
+ subreq, struct tevent_req);
struct rpc_np_trans_state *state = tevent_req_data(
req, struct rpc_np_trans_state);
NTSTATUS status;
@@ -280,29 +271,30 @@ struct rpc_transport_np_init_state {
struct rpc_transport_np_state *transport_np;
};
-static void rpc_transport_np_init_pipe_open(struct async_req *subreq);
+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, *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;
@@ -314,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);
}
- subreq->async.fn = rpc_transport_np_init_pipe_open;
- subreq->async.priv = result;
- return result;
-
- fail:
- TALLOC_FREE(result);
- return NULL;
+ tevent_req_set_callback(subreq, rpc_transport_np_init_pipe_open,
+ req);
+ return req;
}
-static void rpc_transport_np_init_pipe_open(struct async_req *subreq)
+static void rpc_transport_np_init_pipe_open(struct tevent_req *subreq)
{
- struct async_req *req = talloc_get_type_abort(
- subreq->async.priv, 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;
}
@@ -375,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) {
@@ -390,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 bde8d04208..171048ae29 100644
--- a/source3/rpc_client/rpc_transport_smbd.c
+++ b/source3/rpc_client/rpc_transport_smbd.c
@@ -88,6 +88,7 @@ static void rpc_cli_smbd_stdout_reader(struct event_context *ev,
TALLOC_FREE(fde);
return;
}
+ buf[nread] = '\0';
if (conn->stdout_callback.fn != NULL) {
conn->stdout_callback.fn(buf, nread,
@@ -127,102 +128,95 @@ struct get_anon_ipc_state {
struct cli_state *cli;
};
-static void get_anon_ipc_negprot_done(struct async_req *subreq);
-static void get_anon_ipc_sesssetup_done(struct async_req *subreq);
-static void get_anon_ipc_tcon_done(struct async_req *subreq);
+static void get_anon_ipc_negprot_done(struct tevent_req *subreq);
+static void get_anon_ipc_sesssetup_done(struct tevent_req *subreq);
+static void get_anon_ipc_tcon_done(struct tevent_req *subreq);
-static struct async_req *get_anon_ipc_send(TALLOC_CTX *mem_ctx,
- struct event_context *ev,
- struct cli_state *cli)
+static struct tevent_req *get_anon_ipc_send(TALLOC_CTX *mem_ctx,
+ struct event_context *ev,
+ struct cli_state *cli)
{
- struct async_req *result, *subreq;
+ struct tevent_req *req, *subreq;
struct get_anon_ipc_state *state;
- if (!async_req_setup(mem_ctx, &result, &state,
- struct get_anon_ipc_state)) {
+ req = tevent_req_create(mem_ctx, &state, struct get_anon_ipc_state);
+ if (req == NULL) {
return NULL;
}
-
state->ev = ev;
state->cli = cli;
subreq = cli_negprot_send(state, ev, cli);
- if (subreq == NULL) {
- goto fail;
+ if (tevent_req_nomem(subreq, req)) {
+ return tevent_req_post(req, ev);
}
- subreq->async.fn = get_anon_ipc_negprot_done;
- subreq->async.priv = result;
- return result;
- fail:
- TALLOC_FREE(result);
- return NULL;
+ tevent_req_set_callback(subreq, get_anon_ipc_negprot_done, req);
+ return req;
}
-static void get_anon_ipc_negprot_done(struct async_req *subreq)
+static void get_anon_ipc_negprot_done(struct tevent_req *subreq)
{
- struct async_req *req = talloc_get_type_abort(
- subreq->async.priv, struct async_req);
- struct get_anon_ipc_state *state = talloc_get_type_abort(
- req->private_data, struct get_anon_ipc_state);
+ struct tevent_req *req = tevent_req_callback_data(
+ subreq, struct tevent_req);
+ struct get_anon_ipc_state *state = tevent_req_data(
+ req, struct get_anon_ipc_state);
NTSTATUS status;
status = cli_negprot_recv(subreq);
TALLOC_FREE(subreq);
if (!NT_STATUS_IS_OK(status)) {
- async_req_nterror(req, status);
+ tevent_req_nterror(req, status);
return;
}
subreq = cli_session_setup_guest_send(state, state->ev, state->cli);
- if (async_req_nomem(subreq, req)) {
+ if (tevent_req_nomem(subreq, req)) {
return;
}
- subreq->async.fn = get_anon_ipc_sesssetup_done;
- subreq->async.priv = req;
+ tevent_req_set_callback(subreq, get_anon_ipc_sesssetup_done, req);
}
-static void get_anon_ipc_sesssetup_done(struct async_req *subreq)
+static void get_anon_ipc_sesssetup_done(struct tevent_req *subreq)
{
- struct async_req *req = talloc_get_type_abort(
- subreq->async.priv, struct async_req);
- struct get_anon_ipc_state *state = talloc_get_type_abort(
- req->private_data, struct get_anon_ipc_state);
+ struct tevent_req *req = tevent_req_callback_data(
+ subreq, struct tevent_req);
+ struct get_anon_ipc_state *state = tevent_req_data(
+ req, struct get_anon_ipc_state);
NTSTATUS status;
status = cli_session_setup_guest_recv(subreq);
TALLOC_FREE(subreq);
if (!NT_STATUS_IS_OK(status)) {
- async_req_nterror(req, status);
+ tevent_req_nterror(req, status);
return;
}
subreq = cli_tcon_andx_send(state, state->ev, state->cli,
"IPC$", "IPC", NULL, 0);
- if (async_req_nomem(subreq, req)) {
+ if (tevent_req_nomem(subreq, req)) {
return;
}
- subreq->async.fn = get_anon_ipc_tcon_done;
- subreq->async.priv = req;
+ tevent_req_set_callback(subreq, get_anon_ipc_tcon_done, req);
}
-static void get_anon_ipc_tcon_done(struct async_req *subreq)
+static void get_anon_ipc_tcon_done(struct tevent_req *subreq)
{
- struct async_req *req = talloc_get_type_abort(
- subreq->async.priv, struct async_req);
+ struct tevent_req *req = tevent_req_callback_data(
+ subreq, struct tevent_req);
NTSTATUS status;
status = cli_tcon_andx_recv(subreq);
TALLOC_FREE(subreq);
if (!NT_STATUS_IS_OK(status)) {
- async_req_nterror(req, status);
+ tevent_req_nterror(req, status);
return;
}
- async_req_done(req);
+ tevent_req_done(req);
}
-static NTSTATUS get_anon_ipc_recv(struct async_req *req)
+static NTSTATUS get_anon_ipc_recv(struct tevent_req *req)
{
- return async_req_simple_recv_ntstatus(req);
+ return tevent_req_simple_recv_ntstatus(req);
}
struct rpc_cli_smbd_conn_init_state {
@@ -230,16 +224,16 @@ struct rpc_cli_smbd_conn_init_state {
struct rpc_cli_smbd_conn *conn;
};
-static void rpc_cli_smbd_conn_init_done(struct async_req *subreq);
+static void rpc_cli_smbd_conn_init_done(struct tevent_req *subreq);
-struct async_req *rpc_cli_smbd_conn_init_send(TALLOC_CTX *mem_ctx,
- struct event_context *ev,
- void (*stdout_callback)(char *buf,
- size_t len,
- void *priv),
- void *priv)
+struct tevent_req *rpc_cli_smbd_conn_init_send(TALLOC_CTX *mem_ctx,
+ struct event_context *ev,
+ void (*stdout_callback)(char *buf,
+ size_t len,
+ void *priv),
+ void *priv)
{
- struct async_req *result, *subreq;
+ struct tevent_req *req, *subreq;
struct rpc_cli_smbd_conn_init_state *state;
int smb_sock[2];
int stdout_pipe[2];
@@ -249,20 +243,21 @@ struct async_req *rpc_cli_smbd_conn_init_send(TALLOC_CTX *mem_ctx,
smb_sock[0] = smb_sock[1] = stdout_pipe[0] = stdout_pipe[1] = -1;
- if (!async_req_setup(mem_ctx, &result, &state,
- struct rpc_cli_smbd_conn_init_state)) {
+ req = tevent_req_create(mem_ctx, &state,
+ struct rpc_cli_smbd_conn_init_state);
+ if (req == NULL) {
return NULL;
}
state->ev = ev;
state->conn = talloc(state, struct rpc_cli_smbd_conn);
- if (state->conn == NULL) {
- goto nomem;
+ if (tevent_req_nomem(state->conn, req)) {
+ return tevent_req_post(req, ev);
}
state->conn->cli = cli_initialise();
- if (state->conn->cli == NULL) {
- goto nomem;
+ if (tevent_req_nomem(state->conn->cli, req)) {
+ return tevent_req_post(req, ev);
}
state->conn->stdout_fd = -1;
state->conn->stdout_callback.fn = stdout_callback;
@@ -309,7 +304,8 @@ struct async_req *rpc_cli_smbd_conn_init_send(TALLOC_CTX *mem_ctx,
printf("no memory");
exit(1);
}
- if (asprintf(&smbd_cmd, "%s -F -S", smbd_cmd) == -1) {
+ if (asprintf(&smbd_cmd, "%s -F -S -d %d", smbd_cmd,
+ DEBUGLEVEL) == -1) {
printf("no memory");
exit(1);
}
@@ -328,21 +324,19 @@ struct async_req *rpc_cli_smbd_conn_init_send(TALLOC_CTX *mem_ctx,
stdout_pipe[1] = -1;
subreq = get_anon_ipc_send(state, ev, state->conn->cli);
- if (subreq == NULL) {
- goto nomem;
+ if (tevent_req_nomem(subreq, req)) {
+ return tevent_req_post(req, ev);
}
- if (event_add_fd(ev, subreq, state->conn->stdout_fd, EVENT_FD_READ,
+ if (event_add_fd(ev, state, state->conn->stdout_fd, EVENT_FD_READ,
rpc_cli_smbd_stdout_reader, state->conn) == NULL) {
- goto nomem;
+ status = NT_STATUS_NO_MEMORY;
+ goto post_status;
}
- subreq->async.fn = rpc_cli_smbd_conn_init_done;
- subreq->async.priv = result;
- return result;
+ tevent_req_set_callback(subreq, rpc_cli_smbd_conn_init_done, req);
+ return req;
- nomem:
- status = NT_STATUS_NO_MEMORY;
post_status:
if (smb_sock[0] != -1) {
close(smb_sock[0]);
@@ -356,37 +350,34 @@ struct async_req *rpc_cli_smbd_conn_init_send(TALLOC_CTX *mem_ctx,
if (stdout_pipe[1] != -1) {
close(stdout_pipe[1]);
}
- if (async_post_ntstatus(result, ev, status)) {
- return result;
- }
- TALLOC_FREE(result);
- return NULL;
+ tevent_req_nterror(req, status);
+ return tevent_req_post(req, ev);
}
-static void rpc_cli_smbd_conn_init_done(struct async_req *subreq)
+static void rpc_cli_smbd_conn_init_done(struct tevent_req *subreq)
{
- struct async_req *req = talloc_get_type_abort(
- subreq->async.priv, struct async_req);
+ struct tevent_req *req = tevent_req_callback_data(
+ subreq, struct tevent_req);
NTSTATUS status;
status = get_anon_ipc_recv(subreq);
TALLOC_FREE(subreq);
if (!NT_STATUS_IS_OK(status)) {
- async_req_nterror(req, status);
+ tevent_req_nterror(req, status);
return;
}
- async_req_done(req);
+ tevent_req_done(req);
}
-NTSTATUS rpc_cli_smbd_conn_init_recv(struct async_req *req,
+NTSTATUS rpc_cli_smbd_conn_init_recv(struct tevent_req *req,
TALLOC_CTX *mem_ctx,
struct rpc_cli_smbd_conn **pconn)
{
- struct rpc_cli_smbd_conn_init_state *state = talloc_get_type_abort(
- req->private_data, struct rpc_cli_smbd_conn_init_state);
+ struct rpc_cli_smbd_conn_init_state *state = tevent_req_data(
+ req, struct rpc_cli_smbd_conn_init_state);
NTSTATUS status;
- if (async_req_is_nterror(req, &status)) {
+ if (tevent_req_is_nterror(req, &status)) {
return status;
}
*pconn = talloc_move(mem_ctx, &state->conn);
@@ -402,7 +393,7 @@ NTSTATUS rpc_cli_smbd_conn_init(TALLOC_CTX *mem_ctx,
{
TALLOC_CTX *frame = talloc_stackframe();
struct event_context *ev;
- struct async_req *req;
+ struct tevent_req *req;
NTSTATUS status;
ev = event_context_init(frame);
@@ -417,8 +408,9 @@ NTSTATUS rpc_cli_smbd_conn_init(TALLOC_CTX *mem_ctx,
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_cli_smbd_conn_init_recv(req, mem_ctx, pconn);
@@ -456,7 +448,7 @@ static struct tevent_req *rpc_smbd_write_send(TALLOC_CTX *mem_ctx,
goto fail;
}
- if (event_add_fd(ev, subreq, transp->conn->stdout_fd, EVENT_FD_READ,
+ if (event_add_fd(ev, state, transp->conn->stdout_fd, EVENT_FD_READ,
rpc_cli_smbd_stdout_reader, transp->conn) == NULL) {
goto fail;
}
@@ -527,7 +519,7 @@ static struct tevent_req *rpc_smbd_read_send(TALLOC_CTX *mem_ctx,
goto fail;
}
- if (event_add_fd(ev, subreq, transp->conn->stdout_fd, EVENT_FD_READ,
+ if (event_add_fd(ev, state, transp->conn->stdout_fd, EVENT_FD_READ,
rpc_cli_smbd_stdout_reader, transp->conn) == NULL) {
goto fail;
}
@@ -573,53 +565,55 @@ 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 tevent_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 tevent_req *req, *subreq;
struct rpc_transport_smbd_init_state *state;
- if (!async_req_setup(mem_ctx, &result, &state,
- struct rpc_transport_smbd_init_state)) {
+ req = tevent_req_create(mem_ctx, &state,
+ struct rpc_transport_smbd_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_smbd = talloc(state->transport,
struct rpc_transport_smbd_state);
- if (state->transport_smbd == NULL) {
- goto fail;
+ if (tevent_req_nomem(state->transport_smbd, req)) {
+ return tevent_req_post(req, ev);
}
state->transport_smbd->conn = conn;
state->transport->priv = state->transport_smbd;
+ if (event_add_fd(ev, state, conn->stdout_fd, EVENT_FD_READ,
+ rpc_cli_smbd_stdout_reader, conn) == NULL) {
+ tevent_req_nterror(req, NT_STATUS_NO_MEMORY);
+ return tevent_req_post(req, ev);
+ }
+
subreq = rpc_transport_np_init_send(state, ev, conn->cli,
abstract_syntax);
- if (subreq == NULL) {
- goto fail;
+ if (tevent_req_nomem(subreq, req)) {
+ return tevent_req_post(req, ev);
}
- subreq->async.fn = rpc_transport_smbd_init_done;
- subreq->async.priv = result;
- return result;
-
- fail:
- TALLOC_FREE(result);
- return NULL;
+ tevent_req_set_callback(subreq, rpc_transport_smbd_init_done, req);
+ return req;
}
-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 rpc_transport_smbd_init_state *state = talloc_get_type_abort(
- req->private_data, struct rpc_transport_smbd_init_state);
+ struct tevent_req *req = tevent_req_callback_data(
+ subreq, struct tevent_req);
+ struct rpc_transport_smbd_init_state *state = tevent_req_data(
+ req, struct rpc_transport_smbd_init_state);
NTSTATUS status;
status = rpc_transport_np_init_recv(
@@ -627,21 +621,21 @@ static void rpc_transport_smbd_init_done(struct async_req *subreq)
&state->transport_smbd->sub_transp);
TALLOC_FREE(subreq);
if (!NT_STATUS_IS_OK(status)) {
- async_req_nterror(req, status);
+ tevent_req_nterror(req, status);
return;
}
- async_req_done(req);
+ tevent_req_done(req);
}
-NTSTATUS rpc_transport_smbd_init_recv(struct async_req *req,
+NTSTATUS rpc_transport_smbd_init_recv(struct tevent_req *req,
TALLOC_CTX *mem_ctx,
struct rpc_cli_transport **presult)
{
- struct rpc_transport_smbd_init_state *state = talloc_get_type_abort(
- req->private_data, struct rpc_transport_smbd_init_state);
+ struct rpc_transport_smbd_init_state *state = tevent_req_data(
+ req, struct rpc_transport_smbd_init_state);
NTSTATUS status;
- if (async_req_is_nterror(req, &status)) {
+ if (tevent_req_is_nterror(req, &status)) {
return status;
}
@@ -663,7 +657,7 @@ NTSTATUS rpc_transport_smbd_init(TALLOC_CTX *mem_ctx,
{
TALLOC_CTX *frame = talloc_stackframe();
struct event_context *ev;
- struct async_req *req;
+ struct tevent_req *req;
NTSTATUS status;
ev = event_context_init(frame);
@@ -678,8 +672,9 @@ NTSTATUS rpc_transport_smbd_init(TALLOC_CTX *mem_ctx,
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_smbd_init_recv(req, mem_ctx, presult);