From 79f32d794ab65f8cde07779771d660589edb156a Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 16 Jan 2005 12:10:14 +0000 Subject: r4779: demonstrate doing 50 parallel loadfile operations, with a callback for completion (This used to be commit b8c5269482cd7c2611d785bb8831eebae2f905d2) --- source4/torture/raw/composite.c | 53 +++++++++++++++++++++++++++++++---------- 1 file changed, 40 insertions(+), 13 deletions(-) (limited to 'source4/torture/raw/composite.c') diff --git a/source4/torture/raw/composite.c b/source4/torture/raw/composite.c index 563705740d..f1fb6a9829 100644 --- a/source4/torture/raw/composite.c +++ b/source4/torture/raw/composite.c @@ -26,6 +26,12 @@ #define BASEDIR "\\composite" +static void loadfile_complete(struct smbcli_composite *c) +{ + int *count = c->async.private; + (*count)++; +} + /* test a simple savefile/loadfile combination */ @@ -35,8 +41,11 @@ static BOOL test_loadfile(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) NTSTATUS status; struct smb_composite_savefile io1; struct smb_composite_loadfile io2; + struct smbcli_composite **c; char *data; size_t len = random() % 100000; + const int num_ops = 50; + int i, count=0; data = talloc_array(mem_ctx, uint8_t, len); @@ -56,23 +65,41 @@ static BOOL test_loadfile(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) io2.in.fname = fname; - printf("testing loadfile\n"); + printf("testing parallel loadfile with %d ops\n", num_ops); - status = smb_composite_loadfile(cli->tree, mem_ctx, &io2); - if (!NT_STATUS_IS_OK(status)) { - printf("Loadfile failed: %s\n", nt_errstr(status)); - return False; - } + c = talloc_array(mem_ctx, struct smbcli_composite *, num_ops); - if (io2.out.size != len) { - printf("wrong length in returned data - %d should be %d\n", - io2.out.size, len); - return False; + for (i=0;itree, &io2); + c[i]->async.fn = loadfile_complete; + c[i]->async.private = &count; } - if (memcmp(io2.out.data, data, len) != 0) { - printf("wrong data in loadfile!\n"); - return False; + printf("waiting for completion\n"); + while (count != num_ops) { + event_loop_once(cli->transport->socket->event.ctx); + printf("count=%d\r", count); + fflush(stdout); + } + printf("count=%d\n", count); + + for (i=0;i