[SCM] Samba Shared Repository - branch master updated -
release-4-0-0alpha7-266-g9579a6f
Stefan Metzmacher
metze at samba.org
Tue Mar 10 14:18:59 GMT 2009
The branch, master has been updated
via 9579a6f193f570e4ce2af80f4aac7c2f25ae5b22 (commit)
via c2993f74af4e17790f8afbf16ba1c6884afa4ad4 (commit)
from 7fc8086e11497c96be72859a510f72cb3c4104d5 (commit)
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 9579a6f193f570e4ce2af80f4aac7c2f25ae5b22
Author: Stefan Metzmacher <metze at samba.org>
Date: Tue Mar 10 12:34:20 2009 +0100
s3:libsmb: add an option to cli_push to let the caller provide the buffers
metze
commit c2993f74af4e17790f8afbf16ba1c6884afa4ad4
Author: Stefan Metzmacher <metze at samba.org>
Date: Tue Mar 10 12:32:48 2009 +0100
s3:libsmb: only treat a return 0 as end of file
metze
-----------------------------------------------------------------------
Summary of changes:
source3/client/client.c | 10 ++++++----
source3/include/proto.h | 9 +++++++--
source3/libsmb/clireadwrite.c | 38 ++++++++++++++++++++++++++------------
source3/torture/torture.c | 8 +++++---
4 files changed, 44 insertions(+), 21 deletions(-)
Changeset truncated at 500 lines:
diff --git a/source3/client/client.c b/source3/client/client.c
index aaa9e35..67a2458 100644
--- a/source3/client/client.c
+++ b/source3/client/client.c
@@ -220,7 +220,9 @@ struct push_state {
SMB_OFF_T nread;
};
-static size_t push_source(uint8_t *buf, size_t n, void *priv)
+static size_t push_source(uint8_t *inbuf, size_t n,
+ const uint8_t **outbuf,
+ void *priv)
{
struct push_state *state = (struct push_state *)priv;
int result;
@@ -229,7 +231,7 @@ static size_t push_source(uint8_t *buf, size_t n, void *priv)
return 0;
}
- result = readfile(buf, n, state->f);
+ result = readfile(inbuf, n, state->f);
state->nread += result;
return result;
}
@@ -1681,8 +1683,8 @@ static int do_put(const char *rname, const char *lname, bool reput)
state.f = f;
state.nread = 0;
- status = cli_push(targetcli, fnum, 0, 0, io_bufsize, push_source,
- &state);
+ status = cli_push(targetcli, fnum, 0, 0, io_bufsize,
+ false, push_source, &state);
if (!NT_STATUS_IS_OK(status)) {
d_fprintf(stderr, "cli_push returned %s\n", nt_errstr(status));
}
diff --git a/source3/include/proto.h b/source3/include/proto.h
index a1cafb6..794a006 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -2790,13 +2790,18 @@ struct async_req *cli_push_send(TALLOC_CTX *mem_ctx, struct event_context *ev,
struct cli_state *cli,
uint16_t fnum, uint16_t mode,
off_t start_offset, size_t window_size,
- size_t (*source)(uint8_t *buf, size_t n,
+ bool caller_buffers,
+ size_t (*source)(uint8_t *inbuf, size_t n,
+ const uint8_t **outbuf,
void *priv),
void *priv);
NTSTATUS cli_push_recv(struct async_req *req);
NTSTATUS cli_push(struct cli_state *cli, uint16_t fnum, uint16_t mode,
off_t start_offset, size_t window_size,
- size_t (*source)(uint8_t *buf, size_t n, void *priv),
+ bool caller_buffers,
+ size_t (*source)(uint8_t *inbuf, size_t n,
+ const uint8_t **outbuf,
+ void *priv),
void *priv);
/* The following definitions come from libsmb/clisecdesc.c */
diff --git a/source3/libsmb/clireadwrite.c b/source3/libsmb/clireadwrite.c
index 764ef63..7e7cf0d 100644
--- a/source3/libsmb/clireadwrite.c
+++ b/source3/libsmb/clireadwrite.c
@@ -930,8 +930,11 @@ struct cli_push_state {
uint16_t mode;
off_t start_offset;
size_t window_size;
+ bool caller_buffers;
- size_t (*source)(uint8_t *buf, size_t n, void *priv);
+ size_t (*source)(uint8_t *inbuf, size_t n,
+ const uint8_t **outbuf,
+ void *priv);
void *priv;
bool eof;
@@ -963,18 +966,24 @@ static bool cli_push_write_setup(struct async_req *req,
substate->req = req;
substate->idx = idx;
substate->ofs = state->next_offset;
- substate->buf = talloc_array(substate, uint8_t, state->chunk_size);
- if (!substate->buf) {
- talloc_free(substate);
- return false;
+ if (state->caller_buffers) {
+ substate->buf = NULL;
+ } else {
+ substate->buf = talloc_array(substate, uint8_t,
+ state->chunk_size);
+ if (!substate->buf) {
+ talloc_free(substate);
+ return false;
+ }
}
+
+ /* source function can overwrite substate->buf... */
substate->size = state->source(substate->buf,
state->chunk_size,
+ (const uint8_t **)&substate->buf,
state->priv);
- if (substate->size < state->chunk_size) {
- state->eof = true;
- }
if (substate->size == 0) {
+ state->eof = true;
/* nothing to send */
talloc_free(substate);
return true;
@@ -1004,7 +1013,9 @@ struct async_req *cli_push_send(TALLOC_CTX *mem_ctx, struct event_context *ev,
struct cli_state *cli,
uint16_t fnum, uint16_t mode,
off_t start_offset, size_t window_size,
- size_t (*source)(uint8_t *buf, size_t n,
+ bool caller_buffers,
+ size_t (*source)(uint8_t *inbuf, size_t n,
+ const uint8_t **outbuf,
void *priv),
void *priv)
{
@@ -1021,6 +1032,7 @@ struct async_req *cli_push_send(TALLOC_CTX *mem_ctx, struct event_context *ev,
state->fnum = fnum;
state->start_offset = start_offset;
state->mode = mode;
+ state->caller_buffers = caller_buffers;
state->source = source;
state->priv = priv;
state->eof = false;
@@ -1051,7 +1063,6 @@ struct async_req *cli_push_send(TALLOC_CTX *mem_ctx, struct event_context *ev,
}
if (state->eof) {
- state->num_reqs = i+1;
break;
}
}
@@ -1111,7 +1122,10 @@ NTSTATUS cli_push_recv(struct async_req *req)
NTSTATUS cli_push(struct cli_state *cli, uint16_t fnum, uint16_t mode,
off_t start_offset, size_t window_size,
- size_t (*source)(uint8_t *buf, size_t n, void *priv),
+ bool caller_buffers,
+ size_t (*source)(uint8_t *inbuf, size_t n,
+ const uint8_t **outbuf,
+ void *priv),
void *priv)
{
TALLOC_CTX *frame = talloc_stackframe();
@@ -1132,7 +1146,7 @@ NTSTATUS cli_push(struct cli_state *cli, uint16_t fnum, uint16_t mode,
}
req = cli_push_send(frame, ev, cli, fnum, mode, start_offset,
- window_size, source, priv);
+ window_size, caller_buffers, source, priv);
if (req == NULL) {
goto nomem;
}
diff --git a/source3/torture/torture.c b/source3/torture/torture.c
index db89b05..a563557 100644
--- a/source3/torture/torture.c
+++ b/source3/torture/torture.c
@@ -5004,7 +5004,9 @@ static bool run_chain1(int dummy)
return True;
}
-static size_t null_source(uint8_t *buf, size_t n, void *priv)
+static size_t null_source(uint8_t *inbuf, size_t n,
+ const uint8_t *outbuf,
+ void *priv)
{
size_t *to_pull = (size_t *)priv;
size_t thistime = *to_pull;
@@ -5014,7 +5016,7 @@ static size_t null_source(uint8_t *buf, size_t n, void *priv)
return 0;
}
- memset(buf, 0, thistime);
+ memset(inbuf, 0, thistime);
*to_pull -= thistime;
return thistime;
}
@@ -5057,7 +5059,7 @@ static bool run_windows_write(int dummy)
}
status = cli_push(cli1, fnum, 0, i * torture_blocksize, torture_blocksize,
- null_source, &to_pull);
+ false, null_source, &to_pull);
if (!NT_STATUS_IS_OK(status)) {
printf("cli_push returned: %s\n", nt_errstr(status));
goto fail;
--
Samba Shared Repository
More information about the samba-cvs
mailing list