Fix smbtorture so it can handle collisions etc ...
authorRichard Sharpe <sharpe@samba.org>
Wed, 17 Apr 2002 22:50:02 +0000 (22:50 +0000)
committerRichard Sharpe <sharpe@samba.org>
Wed, 17 Apr 2002 22:50:02 +0000 (22:50 +0000)
source/torture/nbio.c
source/torture/torture.c

index 0d6955c879ac9bad39cca71fef2c6a99cb0bb12f..bf9305f8e8993b7360bd3229dbc86d9486b9c4a9 100644 (file)
@@ -79,6 +79,16 @@ void nbio_shmem(int n)
        }
 }
 
+static int ne_find_handle(int handle)
+{
+       int i;
+       children[nbio_id].line = line_count;
+       for (i=0;i<MAX_FILES;i++) {
+               if (ftable[i].handle == handle) return i;
+       }
+       return -1;
+}
+
 static int find_handle(int handle)
 {
        int i;
@@ -127,7 +137,7 @@ void nb_unlink(char *fname)
 
 
 void nb_createx(char *fname, 
-               unsigned create_options, unsigned create_disposition, int handle)
+               unsigned create_options, unsigned create_disposition, int handle, int no_err)
 {
        int fd, i;
        uint32 desired_access;
@@ -147,7 +157,7 @@ void nb_createx(char *fname,
        if (fd == -1 && handle != -1) {
                printf("ERROR: cli_nt_create_full failed for %s - %s\n",
                       fname, cli_errstr(c));
-               exit(1);
+               if (!no_err) exit(1);
        }
        if (fd != -1 && handle == -1) {
                printf("ERROR: cli_nt_create_full succeeded for %s\n", fname);
@@ -196,10 +206,15 @@ void nb_readx(int handle, int offset, int size, int ret_size)
        children[nbio_id].bytes_in += ret_size;
 }
 
-void nb_close(int handle)
+void nb_close(int handle, int no_err)
 {
        int i;
-       i = find_handle(handle);
+       if (no_err) {
+               i = ne_find_handle(handle);
+               if (i < 0) return;
+       }
+       else
+               i = find_handle(handle);
        if (!cli_close(c, ftable[i].fd)) {
                printf("(%d) close failed on handle %d\n", line_count, handle);
                exit(1);
index 23624d07333a51aa78f8c9f234fde13b882e1110..cce39d21129102d0a02198c31e7ae54f12f2f0a2 100644 (file)
@@ -707,9 +707,9 @@ static BOOL run_netbench(int client)
 
                if (!strcmp(params[0],"NTCreateX")) {
                        nb_createx(params[1], ival(params[2]), ival(params[3]), 
-                                  ival(params[4]));
+                                  ival(params[4]),ival(params[5]));
                } else if (!strcmp(params[0],"Close")) {
-                       nb_close(ival(params[1]));
+                       nb_close(ival(params[1]),ival(params[2]));
                } else if (!strcmp(params[0],"Rename")) {
                        nb_rename(params[1], params[2]);
                } else if (!strcmp(params[0],"Unlink")) {