s3:libsmb: align chunk_size for cli_pull/push() to a page size of 1024 bytes
authorStefan Metzmacher <metze@samba.org>
Mon, 12 Sep 2011 00:48:25 +0000 (02:48 +0200)
committerJeremy Allison <jra@samba.org>
Wed, 14 Sep 2011 20:12:16 +0000 (13:12 -0700)
s3:libsmb: align chunk_size for cli_pull/push() to a page size of 1024 bytes

metze

Signed-off-by: Jeremy Allison <jra@samba.org>
source3/libsmb/clireadwrite.c

index fe966ca8dff9042b3c16320019bb5c461aa26e28..bbe6a8127621545dd901533f04a4fcb44cde82cc 100644 (file)
@@ -476,6 +476,7 @@ struct tevent_req *cli_pull_send(TALLOC_CTX *mem_ctx,
        struct tevent_req *req;
        struct cli_pull_state *state;
        int i;
+       size_t page_size = 1024;
 
        req = tevent_req_create(mem_ctx, &state, struct cli_pull_state);
        if (req == NULL) {
@@ -501,6 +502,9 @@ struct tevent_req *cli_pull_send(TALLOC_CTX *mem_ctx,
        }
 
        state->chunk_size = cli_read_max_bufsize(cli);
+       if (state->chunk_size > page_size) {
+               state->chunk_size &= ~(page_size - 1);
+       }
 
        state->max_reqs = cli_state_max_requests(cli);
 
@@ -1171,6 +1175,7 @@ struct tevent_req *cli_push_send(TALLOC_CTX *mem_ctx, struct event_context *ev,
        struct tevent_req *req;
        struct cli_push_state *state;
        uint32_t i;
+       size_t page_size = 1024;
 
        req = tevent_req_create(mem_ctx, &state, struct cli_push_state);
        if (req == NULL) {
@@ -1188,6 +1193,9 @@ struct tevent_req *cli_push_send(TALLOC_CTX *mem_ctx, struct event_context *ev,
        state->next_offset = start_offset;
 
        state->chunk_size = cli_write_max_bufsize(cli, mode, 14);
+       if (state->chunk_size > page_size) {
+               state->chunk_size &= ~(page_size - 1);
+       }
 
        state->max_reqs = cli_state_max_requests(cli);