r976: - added -W for workgroup to locktest
authorAndrew Tridgell <tridge@samba.org>
Wed, 2 Jun 2004 08:33:29 +0000 (08:33 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 17:56:24 +0000 (12:56 -0500)
 - retry connections a few times when reconnecting
(This used to be commit d0d0734845e37a2639ade2545bccef1615e17d63)

source4/torture/locktest.c

index 10238c75a544ec588bf4516d53adbda8d413fd8a..383520260c2a9daf8c177ae71a5fdb414083cd1f 100644 (file)
@@ -108,6 +108,7 @@ static struct cli_state *connect_one(char *share, int snum)
        fstring server, myname;
        uint_t flags = 0;
        NTSTATUS status;
+       int retries = 10;
 
        fstrcpy(server,share+2);
        share = strchr_m(server,'\\');
@@ -119,12 +120,17 @@ static struct cli_state *connect_one(char *share, int snum)
 
        if (use_kerberos)
                flags |= CLI_FULL_CONNECTION_USE_KERBEROS;
-       
-       status = cli_full_connection(&c, myname,
-                                    server, NULL,  
-                                    share, "?????", 
-                                    username[snum], lp_workgroup(), 
-                                    password[snum], flags, NULL);
+
+       do {
+               status = cli_full_connection(&c, myname,
+                                            server, NULL,  
+                                            share, "?????", 
+                                            username[snum], lp_workgroup(), 
+                                            password[snum], flags, NULL);
+               if (!NT_STATUS_IS_OK(status)) {
+                       sleep(2);
+               }
+       } while (!NT_STATUS_IS_OK(status) && retries--);
 
        if (!NT_STATUS_IS_OK(status)) {
                return NULL;
@@ -485,7 +491,7 @@ static void usage(void)
 
        seed = time(NULL);
 
-       while ((opt = getopt(argc, argv, "U:s:ho:aAW:OkR:B:M:EZ")) != EOF) {
+       while ((opt = getopt(argc, argv, "U:s:ho:aAW:OkR:B:M:EZW:")) != EOF) {
                switch (opt) {
                case 'k':
 #ifdef HAVE_KRB5
@@ -542,6 +548,9 @@ static void usage(void)
                case 'E':
                        exact_error_codes = True;
                        break;
+               case 'W':
+                       lp_set_cmdline("workgroup", optarg);
+                       break;
                case 'h':
                        usage();
                        exit(1);