From e28124601045b01c238558d9d1281e41d719a12e Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 13 Jun 2000 15:47:23 +0000 Subject: allow for lots of connections per server (This used to be commit 4bbc218922d2b1f40d50a611a389c9956851050f) --- source3/utils/locktest.c | 151 ++++++++++++++++++++++++----------------------- 1 file changed, 76 insertions(+), 75 deletions(-) diff --git a/source3/utils/locktest.c b/source3/utils/locktest.c index 9bccf24443..78627c22ad 100644 --- a/source3/utils/locktest.c +++ b/source3/utils/locktest.c @@ -41,11 +41,12 @@ static BOOL use_oplocks; */ #define READ_PCT 50 -#define LOCK_PCT 25 -#define UNLOCK_PCT 65 +#define LOCK_PCT 35 +#define UNLOCK_PCT 55 #define RANGE_MULTIPLE 1 -#define NCONNECTIONS 2 -#define NFILES 2 +#define NSERVERS 2 +#define NCONNECTIONS 6 +#define NFILES 4 #define LOCK_TIMEOUT 0 #define NASTY_POSIX_LOCK_HACK 0 @@ -94,6 +95,14 @@ static void print_brl(SMB_DEV_T dev, SMB_INO_T ino, int pid, } + +static void show_locks(void) +{ + brl_forall(print_brl); + system("cat /proc/locks"); +} + + /***************************************************** return a connection to a server *******************************************************/ @@ -195,15 +204,12 @@ struct cli_state *connect_one(char *share) } -static void reconnect(struct cli_state *cli[2][2], int fnum[2][2][2], - char *share1, char *share2) +static void reconnect(struct cli_state *cli[NSERVERS][NCONNECTIONS], int fnum[NSERVERS][NCONNECTIONS][NFILES], + char *share[NSERVERS]) { int server, conn, f; - char *share[2]; - share[0] = share1; - share[1] = share2; - for (server=0;server<2;server++) + for (server=0;serverconn; @@ -235,7 +241,8 @@ static BOOL test_one(struct cli_state *cli[2][2], unsigned r1 = rec->r1; unsigned r2 = rec->r2; unsigned op; - BOOL ret1, ret2; + int server; + BOOL ret[NSERVERS]; if (r1 < READ_PCT) { op = READ_LOCK; @@ -245,70 +252,64 @@ static BOOL test_one(struct cli_state *cli[2][2], if (r2 < LOCK_PCT) { /* set a lock */ - ret1 = cli_lock(cli[0][conn], - fnum[0][conn][f], - start, len, LOCK_TIMEOUT, op); - ret2 = cli_lock(cli[1][conn], - fnum[1][conn][f], - start, len, LOCK_TIMEOUT, op); - if (showall || ret1 != ret2) { + for (server=0;server %u:%u\n", conn, f, start, start+len-1, len, op==READ_LOCK?"READ_LOCK":"WRITE_LOCK", - ret1, ret2); + ret[0], ret[1]); } - if (showall) brl_forall(print_brl); - if (ret1 != ret2) return False; + if (showall || ret[0] != ret[1]) show_locks(); + if (ret[0] != ret[1]) return False; } else if (r2 < LOCK_PCT+UNLOCK_PCT) { /* unset a lock */ - ret1 = cli_unlock(cli[0][conn], - fnum[0][conn][f], - start, len); - ret2 = cli_unlock(cli[1][conn], - fnum[1][conn][f], - start, len); - if (showall || (!hide_unlock_fails && (ret1 != ret2))) { + for (server=0;server %u:%u\n", conn, f, start, start+len-1, len, - ret1, ret2); + ret[0], ret[1]); } - if (showall) brl_forall(print_brl); - if (!hide_unlock_fails && ret1 != ret2) return False; + if (showall || ret[0] != ret[1]) show_locks(); + if (!hide_unlock_fails && ret[0] != ret[1]) return False; } else { /* reopen the file */ - cli_close(cli[0][conn], fnum[0][conn][f]); - cli_close(cli[1][conn], fnum[1][conn][f]); - fnum[0][conn][f] = cli_open(cli[0][conn], FILENAME, - O_RDWR|O_CREAT, - DENY_NONE); - fnum[1][conn][f] = cli_open(cli[1][conn], FILENAME, - O_RDWR|O_CREAT, - DENY_NONE); - if (fnum[0][conn][f] == -1) { - printf("failed to reopen on share1\n"); - return False; + for (server=0;server