s3:libsmb: let cli_smb_chain_send() also return NTSTATUS
authorStefan Metzmacher <metze@samba.org>
Tue, 12 May 2009 12:47:02 +0000 (14:47 +0200)
committerStefan Metzmacher <metze@samba.org>
Wed, 13 May 2009 16:27:50 +0000 (18:27 +0200)
metze

source3/include/async_smb.h
source3/libsmb/async_smb.c
source3/torture/torture.c

index c27dd2b..03dd274 100644 (file)
@@ -49,7 +49,7 @@ struct tevent_req *cli_smb_req_create(TALLOC_CTX *mem_ctx,
                                      struct iovec *bytes_iov);
 NTSTATUS cli_smb_req_send(struct tevent_req *req);
 size_t cli_smb_wct_ofs(struct tevent_req **reqs, int num_reqs);
-bool cli_smb_chain_send(struct tevent_req **reqs, int num_reqs);
+NTSTATUS cli_smb_chain_send(struct tevent_req **reqs, int num_reqs);
 uint8_t *cli_smb_inbuf(struct tevent_req *req);
 bool cli_has_async_calls(struct cli_state *cli);
 void cli_smb_req_unset_pending(struct tevent_req *req);
index 77ef877..7474959 100644 (file)
@@ -951,7 +951,7 @@ size_t cli_smb_wct_ofs(struct tevent_req **reqs, int num_reqs)
        return wct_ofs;
 }
 
-bool cli_smb_chain_send(struct tevent_req **reqs, int num_reqs)
+NTSTATUS cli_smb_chain_send(struct tevent_req **reqs, int num_reqs)
 {
        struct cli_smb_state *first_state = tevent_req_data(
                reqs[0], struct cli_smb_state);
@@ -973,13 +973,14 @@ bool cli_smb_chain_send(struct tevent_req **reqs, int num_reqs)
 
        iov = talloc_array(last_state, struct iovec, iovlen);
        if (iov == NULL) {
-               goto fail;
+               return NT_STATUS_NO_MEMORY;
        }
 
        first_state->chained_requests = (struct tevent_req **)talloc_memdup(
                last_state, reqs, sizeof(*reqs) * num_reqs);
        if (first_state->chained_requests == NULL) {
-               goto fail;
+               TALLOC_FREE(iov);
+               return NT_STATUS_NO_MEMORY;
        }
 
        wct_offset = smb_wct - 4;
@@ -994,7 +995,9 @@ bool cli_smb_chain_send(struct tevent_req **reqs, int num_reqs)
                if (i < num_reqs-1) {
                        if (!is_andx_req(CVAL(state->header, smb_com))
                            || CVAL(state->header, smb_wct) < 2) {
-                               goto fail;
+                               TALLOC_FREE(iov);
+                               TALLOC_FREE(first_state->chained_requests);
+                               return NT_STATUS_INVALID_PARAMETER;
                        }
                }
 
@@ -1042,12 +1045,12 @@ bool cli_smb_chain_send(struct tevent_req **reqs, int num_reqs)
 
        status = cli_smb_req_iov_send(reqs[0], last_state, iov, iovlen);
        if (!NT_STATUS_IS_OK(status)) {
-               goto fail;
+               TALLOC_FREE(iov);
+               TALLOC_FREE(first_state->chained_requests);
+               return status;
        }
-       return true;
- fail:
-       TALLOC_FREE(iov);
-       return false;
+
+       return NT_STATUS_OK;
 }
 
 uint8_t *cli_smb_inbuf(struct tevent_req *req)
index 53a39c6..578f6a3 100644 (file)
@@ -4959,6 +4959,7 @@ static bool run_chain1(int dummy)
        struct tevent_req *reqs[3], *smbreqs[3];
        bool done = false;
        const char *str = "foobar";
+       NTSTATUS status;
 
        printf("starting chain1 test\n");
        if (!torture_open_connection(&cli1, 0)) {
@@ -4983,7 +4984,8 @@ static bool run_chain1(int dummy)
        if (reqs[2] == NULL) return false;
        tevent_req_set_callback(reqs[2], chain1_close_completion, &done);
 
-       if (!cli_smb_chain_send(smbreqs, ARRAY_SIZE(smbreqs))) {
+       status = cli_smb_chain_send(smbreqs, ARRAY_SIZE(smbreqs));
+       if (!NT_STATUS_IS_OK(status)) {
                return false;
        }
 
@@ -5017,6 +5019,7 @@ static bool run_chain2(int dummy)
        struct event_context *evt = event_context_init(NULL);
        struct tevent_req *reqs[2], *smbreqs[2];
        bool done = false;
+       NTSTATUS status;
 
        printf("starting chain2 test\n");
        if (!torture_open_connection(&cli1, 0)) {
@@ -5035,7 +5038,8 @@ static bool run_chain2(int dummy)
        if (reqs[1] == NULL) return false;
        tevent_req_set_callback(reqs[1], chain2_tcon_completion, &done);
 
-       if (!cli_smb_chain_send(smbreqs, ARRAY_SIZE(smbreqs))) {
+       status = cli_smb_chain_send(smbreqs, ARRAY_SIZE(smbreqs));
+       if (!NT_STATUS_IS_OK(status)) {
                return false;
        }