summaryrefslogtreecommitdiff
path: root/source3/libsmb
diff options
context:
space:
mode:
authorVolker Lendecke <vl@sernet.de>2008-12-01 08:23:35 +0100
committerVolker Lendecke <vl@samba.org>2008-12-08 22:09:33 +0100
commit7fbb64d726f23da49cd2f07e1a678ed575b70bfa (patch)
tree8b58be1fa57d5763f4b6be67105f05aeae644072 /source3/libsmb
parentf9aa69ae352f7f441b04976575b96ecc8b844dbd (diff)
downloadsamba-7fbb64d726f23da49cd2f07e1a678ed575b70bfa.tar.gz
samba-7fbb64d726f23da49cd2f07e1a678ed575b70bfa.tar.bz2
samba-7fbb64d726f23da49cd2f07e1a678ed575b70bfa.zip
Simplify async programming a bit with helper routines
Introduce async_req_is_error() and async_req_simple_recv()
Diffstat (limited to 'source3/libsmb')
-rw-r--r--source3/libsmb/clientgen.c7
-rw-r--r--source3/libsmb/clifile.c11
-rw-r--r--source3/libsmb/clireadwrite.c11
-rw-r--r--source3/libsmb/clitrans.c6
4 files changed, 14 insertions, 21 deletions
diff --git a/source3/libsmb/clientgen.c b/source3/libsmb/clientgen.c
index 8a5aedfde5..d94427809c 100644
--- a/source3/libsmb/clientgen.c
+++ b/source3/libsmb/clientgen.c
@@ -732,12 +732,7 @@ struct async_req *cli_echo_send(TALLOC_CTX *mem_ctx, struct event_context *ev,
NTSTATUS cli_echo_recv(struct async_req *req)
{
- SMB_ASSERT(req->state >= ASYNC_REQ_DONE);
- if (req->state == ASYNC_REQ_ERROR) {
- return req->status;
- }
-
- return NT_STATUS_OK;
+ return async_req_simple_recv(req);
}
/**
diff --git a/source3/libsmb/clifile.c b/source3/libsmb/clifile.c
index a9e81082ea..733abb6510 100644
--- a/source3/libsmb/clifile.c
+++ b/source3/libsmb/clifile.c
@@ -908,9 +908,8 @@ NTSTATUS cli_open_recv(struct async_req *req, int *fnum)
uint8_t *bytes;
NTSTATUS status;
- SMB_ASSERT(req->state >= ASYNC_REQ_DONE);
- if (req->state == ASYNC_REQ_ERROR) {
- return req->status;
+ if (async_req_is_error(req, &status)) {
+ return status;
}
status = cli_pull_reply(req, &wct, &vwv, &num_bytes, &bytes);
@@ -985,10 +984,10 @@ NTSTATUS cli_close_recv(struct async_req *req)
uint16_t *vwv;
uint16_t num_bytes;
uint8_t *bytes;
+ NTSTATUS status;
- SMB_ASSERT(req->state >= ASYNC_REQ_DONE);
- if (req->state == ASYNC_REQ_ERROR) {
- return req->status;
+ if (async_req_is_error(req, &status)) {
+ return status;
}
return cli_pull_reply(req, &wct, &vwv, &num_bytes, &bytes);
diff --git a/source3/libsmb/clireadwrite.c b/source3/libsmb/clireadwrite.c
index cc982683d0..ecf49396d1 100644
--- a/source3/libsmb/clireadwrite.c
+++ b/source3/libsmb/clireadwrite.c
@@ -112,9 +112,8 @@ NTSTATUS cli_read_andx_recv(struct async_req *req, ssize_t *received,
NTSTATUS status;
size_t size;
- SMB_ASSERT(req->state >= ASYNC_REQ_DONE);
- if (req->state == ASYNC_REQ_ERROR) {
- return req->status;
+ if (async_req_is_error(req, &status)) {
+ return status;
}
status = cli_pull_reply(req, &wct, &vwv, &num_bytes, &bytes);
@@ -405,10 +404,10 @@ NTSTATUS cli_pull_recv(struct async_req *req, SMB_OFF_T *received)
{
struct cli_pull_state *state = talloc_get_type_abort(
req->private_data, struct cli_pull_state);
+ NTSTATUS status;
- SMB_ASSERT(req->state >= ASYNC_REQ_DONE);
- if (req->state == ASYNC_REQ_ERROR) {
- return req->status;
+ if (async_req_is_error(req, &status)) {
+ return status;
}
*received = state->pushed;
return NT_STATUS_OK;
diff --git a/source3/libsmb/clitrans.c b/source3/libsmb/clitrans.c
index bbdfb75fcd..120b6c0e29 100644
--- a/source3/libsmb/clitrans.c
+++ b/source3/libsmb/clitrans.c
@@ -1316,10 +1316,10 @@ NTSTATUS cli_trans_recv(struct async_req *req, TALLOC_CTX *mem_ctx,
req->private_data, struct cli_request);
struct cli_trans_state *state = talloc_get_type_abort(
cli_req->recv_helper.priv, struct cli_trans_state);
+ NTSTATUS status;
- SMB_ASSERT(req->state >= ASYNC_REQ_DONE);
- if (req->state == ASYNC_REQ_ERROR) {
- return req->status;
+ if (async_req_is_error(req, &status)) {
+ return status;
}
if (setup != NULL) {