diff options
author | Stefan Metzmacher <metze@samba.org> | 2011-08-11 12:16:02 +0200 |
---|---|---|
committer | Stefan Metzmacher <metze@samba.org> | 2011-08-12 11:08:00 +0200 |
commit | 4335a4f1c6ad4e8dfcd4cc1bcd8b3ec2f258a4d8 (patch) | |
tree | 6acdefdbbf641a37e7833b1b1b90f8ce7ee523b5 /source3/libsmb | |
parent | ca567117b028d8954453585bfb753e7f01c98319 (diff) | |
download | samba-4335a4f1c6ad4e8dfcd4cc1bcd8b3ec2f258a4d8.tar.gz samba-4335a4f1c6ad4e8dfcd4cc1bcd8b3ec2f258a4d8.tar.bz2 samba-4335a4f1c6ad4e8dfcd4cc1bcd8b3ec2f258a4d8.zip |
s3:libsmb: split out cli_state_receive_next() from cli_smb_req_set_pending()
metze
Diffstat (limited to 'source3/libsmb')
-rw-r--r-- | source3/libsmb/async_smb.c | 27 |
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); |