summaryrefslogtreecommitdiff
path: root/source4/libcli/smb_composite
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2011-11-29 11:57:11 +0100
committerStefan Metzmacher <metze@samba.org>2011-11-30 13:41:08 +0100
commitb51c92a903877015acf268ab8ff0e07d3a82b295 (patch)
treea421de0a5672a3d4e41f0b9e67eac93f5b064312 /source4/libcli/smb_composite
parent706e10820d490e0865b73f66a8665951aa6a71e3 (diff)
downloadsamba-b51c92a903877015acf268ab8ff0e07d3a82b295.tar.gz
samba-b51c92a903877015acf268ab8ff0e07d3a82b295.tar.bz2
samba-b51c92a903877015acf268ab8ff0e07d3a82b295.zip
s4:libcli: convert smbcli_transport_connect_* to tevent_req
metze
Diffstat (limited to 'source4/libcli/smb_composite')
-rw-r--r--source4/libcli/smb_composite/connect.c40
1 files changed, 26 insertions, 14 deletions
diff --git a/source4/libcli/smb_composite/connect.c b/source4/libcli/smb_composite/connect.c
index d36bf26914..306b96c167 100644
--- a/source4/libcli/smb_composite/connect.c
+++ b/source4/libcli/smb_composite/connect.c
@@ -52,11 +52,13 @@ struct connect_state {
struct smb_composite_sesssetup *io_setup;
struct smbcli_request *req;
struct composite_context *creq;
+ struct tevent_req *subreq;
};
static void request_handler(struct smbcli_request *);
static void composite_handler(struct composite_context *);
+static void subreq_handler(struct tevent_req *subreq);
/*
a tree connect request has completed
@@ -301,7 +303,8 @@ static NTSTATUS connect_session_request(struct composite_context *c,
struct connect_state *state = talloc_get_type(c->private_data, struct connect_state);
NTSTATUS status;
- status = smbcli_transport_connect_recv(state->req);
+ status = smbcli_transport_connect_recv(state->subreq);
+ TALLOC_FREE(state->subreq);
NT_STATUS_NOT_OK_RETURN(status);
/* next step is a negprot */
@@ -317,6 +320,7 @@ static NTSTATUS connect_socket(struct composite_context *c,
struct connect_state *state = talloc_get_type(c->private_data, struct connect_state);
NTSTATUS status;
struct nbt_name calling, called;
+ uint32_t timeout_msec = io->in.options.request_timeout * 1000;
status = smbcli_sock_connect_recv(state->creq, state, &state->sock);
NT_STATUS_NOT_OK_RETURN(status);
@@ -340,21 +344,18 @@ static NTSTATUS connect_socket(struct composite_context *c,
nbt_choose_called_name(state, &called, io->in.called_name, NBT_NAME_SERVER);
- /* we have a connected socket - next step is a session
- request, if needed. Port 445 doesn't need it, so it goes
- straight to the negprot */
- if (state->sock->port == 445) {
- status = nbt_name_dup(state->transport, &called,
- &state->transport->called);
- NT_STATUS_NOT_OK_RETURN(status);
- return connect_send_negprot(c, io);
- }
+ status = nbt_name_dup(state->transport, &called,
+ &state->transport->called);
+ NT_STATUS_NOT_OK_RETURN(status);
- state->req = smbcli_transport_connect_send(state->transport, &calling, &called);
- NT_STATUS_HAVE_NO_MEMORY(state->req);
+ state->subreq = smbcli_transport_connect_send(state,
+ state->transport->ev,
+ state->transport->socket,
+ timeout_msec,
+ &calling, &called);
+ NT_STATUS_HAVE_NO_MEMORY(state->subreq);
- state->req->async.fn = request_handler;
- state->req->async.private_data = c;
+ tevent_req_set_callback(state->subreq, subreq_handler, c);
state->stage = CONNECT_SESSION_REQUEST;
return NT_STATUS_OK;
@@ -421,6 +422,17 @@ static void composite_handler(struct composite_context *creq)
}
/*
+ handler for completion of a tevent_req sub-request
+*/
+static void subreq_handler(struct tevent_req *subreq)
+{
+ struct composite_context *c =
+ tevent_req_callback_data(subreq,
+ struct composite_context);
+ state_handler(c);
+}
+
+/*
a function to establish a smbcli_tree from scratch
*/
struct composite_context *smb_composite_connect_send(struct smb_composite_connect *io,