summaryrefslogtreecommitdiff
path: root/source3/libsmb
diff options
context:
space:
mode:
Diffstat (limited to 'source3/libsmb')
-rw-r--r--source3/libsmb/async_smb.c27
1 files changed, 25 insertions, 2 deletions
diff --git a/source3/libsmb/async_smb.c b/source3/libsmb/async_smb.c
index b2856f6779..60ba1e550f 100644
--- a/source3/libsmb/async_smb.c
+++ b/source3/libsmb/async_smb.c
@@ -187,7 +187,8 @@ static int cli_smb_req_destructor(struct tevent_req *req)
return 0;
}
-static void cli_smb_received(struct tevent_req *subreq);
+static bool cli_state_receive_next(struct cli_state *cli);
+static void cli_state_notify_pending(struct cli_state *cli, NTSTATUS status);
bool cli_smb_req_set_pending(struct tevent_req *req)
{
@@ -209,10 +210,33 @@ bool cli_smb_req_set_pending(struct tevent_req *req)
cli->conn.pending = pending;
talloc_set_destructor(req, cli_smb_req_destructor);
+ if (!cli_state_receive_next(cli)) {
+ cli_smb_req_unset_pending(req);
+ return false;
+ }
+
+ return true;
+}
+
+static void cli_smb_received(struct tevent_req *subreq);
+
+static bool cli_state_receive_next(struct cli_state *cli)
+{
+ size_t num_pending = talloc_array_length(cli->conn.pending);
+ struct tevent_req *req;
+ struct cli_smb_state *state;
+
if (cli->conn.read_smb_req != NULL) {
return true;
}
+ if (num_pending == 0) {
+ return true;
+ }
+
+ req = cli->conn.pending[0];
+ state = tevent_req_data(req, struct cli_smb_state);
+
/*
* We're the first ones, add the read_smb request that waits for the
* answer from the server
@@ -220,7 +244,6 @@ bool cli_smb_req_set_pending(struct tevent_req *req)
cli->conn.read_smb_req = read_smb_send(cli->conn.pending, state->ev,
cli->conn.fd);
if (cli->conn.read_smb_req == NULL) {
- cli_smb_req_unset_pending(req);
return false;
}
tevent_req_set_callback(cli->conn.read_smb_req, cli_smb_received, cli);