svn commit: samba r4779 - in branches/SAMBA_4_0/source/torture/raw:
.
tridge at samba.org
tridge at samba.org
Sun Jan 16 12:10:17 GMT 2005
Author: tridge
Date: 2005-01-16 12:10:14 +0000 (Sun, 16 Jan 2005)
New Revision: 4779
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=4779
Log:
demonstrate doing 50 parallel loadfile operations, with a callback for completion
Modified:
branches/SAMBA_4_0/source/torture/raw/composite.c
Changeset:
Modified: branches/SAMBA_4_0/source/torture/raw/composite.c
===================================================================
--- branches/SAMBA_4_0/source/torture/raw/composite.c 2005-01-16 11:45:49 UTC (rev 4778)
+++ branches/SAMBA_4_0/source/torture/raw/composite.c 2005-01-16 12:10:14 UTC (rev 4779)
@@ -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 @@
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 @@
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);
+
+ for (i=0;i<num_ops;i++) {
+ c[i] = smb_composite_loadfile_send(cli->tree, &io2);
+ c[i]->async.fn = loadfile_complete;
+ c[i]->async.private = &count;
}
- if (io2.out.size != len) {
- printf("wrong length in returned data - %d should be %d\n",
- io2.out.size, len);
- 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<num_ops;i++) {
+ status = smb_composite_loadfile_recv(c[i], mem_ctx);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("loadfile[%d] failed - %s\n", i, nt_errstr(status));
+ return False;
+ }
- if (memcmp(io2.out.data, data, len) != 0) {
- printf("wrong data in loadfile!\n");
- return False;
+ if (io2.out.size != len) {
+ printf("wrong length in returned data - %d should be %d\n",
+ io2.out.size, len);
+ return False;
+ }
+
+ if (memcmp(io2.out.data, data, len) != 0) {
+ printf("wrong data in loadfile!\n");
+ return False;
+ }
}
talloc_free(data);
More information about the samba-cvs
mailing list