s3: libsmb: Rename cli_close_create() -> cli_smb1_close_create().
authorJeremy Allison <jra@samba.org>
Wed, 22 Nov 2017 00:47:48 +0000 (00:47 +0000)
committerRalph Boehme <slow@samba.org>
Wed, 6 Dec 2017 14:02:16 +0000 (15:02 +0100)
Move cli_smb1_close_done() next to its caller. This is SMB1 specific.
Prepare to wrap cli_close_send/cli_close_recv to handle SMB2.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=13159

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Böhme <slow@samba.org>
source3/libsmb/clifile.c
source3/libsmb/proto.h
source3/torture/test_chain3.c
source3/torture/torture.c

index e942b27e1751ed4cd911018bac198686ee2b04e3..2e3c2426030b9ddea82f470c2703a15dccbea991 100644 (file)
@@ -2770,22 +2770,22 @@ NTSTATUS cli_open(struct cli_state *cli, const char *fname, int flags,
  Close a file.
 ****************************************************************************/
 
-struct cli_close_state {
+struct cli_smb1_close_state {
        uint16_t vwv[3];
 };
 
-static void cli_close_done(struct tevent_req *subreq);
+static void cli_smb1_close_done(struct tevent_req *subreq);
 
-struct tevent_req *cli_close_create(TALLOC_CTX *mem_ctx,
+struct tevent_req *cli_smb1_close_create(TALLOC_CTX *mem_ctx,
                                struct tevent_context *ev,
                                struct cli_state *cli,
                                uint16_t fnum,
                                struct tevent_req **psubreq)
 {
        struct tevent_req *req, *subreq;
-       struct cli_close_state *state;
+       struct cli_smb1_close_state *state;
 
-       req = tevent_req_create(mem_ctx, &state, struct cli_close_state);
+       req = tevent_req_create(mem_ctx, &state, struct cli_smb1_close_state);
        if (req == NULL) {
                return NULL;
        }
@@ -2799,11 +2799,25 @@ struct tevent_req *cli_close_create(TALLOC_CTX *mem_ctx,
                TALLOC_FREE(req);
                return NULL;
        }
-       tevent_req_set_callback(subreq, cli_close_done, req);
+       tevent_req_set_callback(subreq, cli_smb1_close_done, req);
        *psubreq = subreq;
        return req;
 }
 
+static void cli_smb1_close_done(struct tevent_req *subreq)
+{
+       struct tevent_req *req = tevent_req_callback_data(
+               subreq, struct tevent_req);
+       NTSTATUS status;
+
+       status = cli_smb_recv(subreq, NULL, NULL, 0, NULL, NULL, NULL, NULL);
+       TALLOC_FREE(subreq);
+       if (tevent_req_nterror(req, status)) {
+               return;
+       }
+       tevent_req_done(req);
+}
+
 struct tevent_req *cli_close_send(TALLOC_CTX *mem_ctx,
                                struct tevent_context *ev,
                                struct cli_state *cli,
@@ -2812,7 +2826,7 @@ struct tevent_req *cli_close_send(TALLOC_CTX *mem_ctx,
        struct tevent_req *req, *subreq;
        NTSTATUS status;
 
-       req = cli_close_create(mem_ctx, ev, cli, fnum, &subreq);
+       req = cli_smb1_close_create(mem_ctx, ev, cli, fnum, &subreq);
        if (req == NULL) {
                return NULL;
        }
@@ -2824,20 +2838,6 @@ struct tevent_req *cli_close_send(TALLOC_CTX *mem_ctx,
        return req;
 }
 
-static void cli_close_done(struct tevent_req *subreq)
-{
-       struct tevent_req *req = tevent_req_callback_data(
-               subreq, struct tevent_req);
-       NTSTATUS status;
-
-       status = cli_smb_recv(subreq, NULL, NULL, 0, NULL, NULL, NULL, NULL);
-       TALLOC_FREE(subreq);
-       if (tevent_req_nterror(req, status)) {
-               return;
-       }
-       tevent_req_done(req);
-}
-
 NTSTATUS cli_close_recv(struct tevent_req *req)
 {
        return tevent_req_simple_recv_ntstatus(req);
index 4ae566cca1c249b4a1b9f0a068c1d4328e6d27cd..d82de56a23853623488a4bad94b7325de4518675 100644 (file)
@@ -423,7 +423,7 @@ struct tevent_req *cli_openx_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev
 NTSTATUS cli_openx_recv(struct tevent_req *req, uint16_t *fnum);
 NTSTATUS cli_openx(struct cli_state *cli, const char *fname, int flags, int share_mode, uint16_t *pfnum);
 NTSTATUS cli_open(struct cli_state *cli, const char *fname, int flags, int share_mode, uint16_t *pfnum);
-struct tevent_req *cli_close_create(TALLOC_CTX *mem_ctx,
+struct tevent_req *cli_smb1_close_create(TALLOC_CTX *mem_ctx,
                                    struct tevent_context *ev,
                                    struct cli_state *cli, uint16_t fnum,
                                    struct tevent_req **psubreq);
index cad1a3fb40788fe738a8d9ef8237f314abd6ab89..eff39de8702570770410b1d1ca8df3a568a6d643 100644 (file)
@@ -70,7 +70,7 @@ static struct tevent_req *chain3_andx_send(TALLOC_CTX *mem_ctx,
        }
        tevent_req_set_callback(subreq, chain3_andx_write_done, req);
 
-       subreq = cli_close_create(state, ev, cli, 0, &smbreqs[2]);
+       subreq = cli_smb1_close_create(state, ev, cli, 0, &smbreqs[2]);
        if (tevent_req_nomem(subreq, req)) {
                return tevent_req_post(req, ev);
        }
index cf8b03ca111d5ac2a0d1be23bec701d12a1e04ea..87276c09cb348db512eb313f33786b65d24296d3 100644 (file)
@@ -8066,7 +8066,7 @@ static bool run_chain1(int dummy)
        if (reqs[1] == NULL) return false;
        tevent_req_set_callback(reqs[1], chain1_write_completion, NULL);
 
-       reqs[2] = cli_close_create(talloc_tos(), evt, cli1, 0, &smbreqs[2]);
+       reqs[2] = cli_smb1_close_create(talloc_tos(), evt, cli1, 0, &smbreqs[2]);
        if (reqs[2] == NULL) return false;
        tevent_req_set_callback(reqs[2], chain1_close_completion, &done);