From 0af00edf672eda7556f12745c80873376b85676f Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 10 Jan 2000 14:41:20 +0000 Subject: I'm currently designing a new locking system (using a tdb database!) that will make us match NT semantics exactly and do away with the horrible fd multiplexing in smbd. this is some diag stuff to get me started. - added the ability to do read or write locks in clientgen.c - added a LOCK4 test to smbtorture. This produces a report on the server and its locking capabilities. For example, NT4 gives this: the same process cannot set overlapping write locks the same process can set overlapping read locks a different connection cannot set overlapping write locks a different connection can set overlapping read locks a different pid cannot set overlapping write locks a different pid can set overlapping read locks the same process can set the same read lock twice the same process cannot set the same write lock twice the same process cannot override a read lock with a write lock the same process can override a write lock with a read lock a different pid cannot override a write lock with a read lock the same process cannot coalesce read locks this server does strict write locking this server does strict read locking whereas Samba currently gives this: the same process can set overlapping write locks the same process can set overlapping read locks a different connection cannot set overlapping write locks a different connection can set overlapping read locks a different pid can set overlapping write locks a different pid can set overlapping read locks the same process can set the same read lock twice the same process can set the same write lock twice the same process can override a read lock with a write lock the same process can override a write lock with a read lock a different pid can override a write lock with a read lock the same process can coalesce read locks this server does strict write locking this server does strict read locking win95 gives this - I don't understand why! the same process cannot set overlapping write locks the same process cannot set overlapping read locks a different connection cannot set overlapping write locks a different connection cannot set overlapping read locks a different pid cannot set overlapping write locks a different pid cannot set overlapping read locks the same process cannot set the same read lock twice the same process cannot set the same write lock twice the same process cannot override a read lock with a write lock the same process cannot override a write lock with a read lock a different pid cannot override a write lock with a read lock the same process cannot coalesce read locks this server does strict write locking this server does strict read locking (This used to be commit 49637936b6e9478df248c4ef73d818870c73b597) --- source3/utils/torture.c | 150 +++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 129 insertions(+), 21 deletions(-) (limited to 'source3/utils') diff --git a/source3/utils/torture.c b/source3/utils/torture.c index 4375cbe231..b9f0d76581 100644 --- a/source3/utils/torture.c +++ b/source3/utils/torture.c @@ -168,7 +168,7 @@ static BOOL check_error(struct cli_state *c, static BOOL wait_lock(struct cli_state *c, int fnum, uint32 offset, uint32 len) { - while (!cli_lock(c, fnum, offset, len, -1)) { + while (!cli_lock(c, fnum, offset, len, -1, F_WRLCK)) { if (!check_error(c, ERRDOS, ERRlock, 0)) return False; } return True; @@ -242,7 +242,7 @@ static BOOL rw_torture(struct cli_state *c) printf("unlink failed (%s)\n", cli_errstr(c)); } - if (!cli_unlock(c, fnum2, n*sizeof(int), sizeof(int), -1)) { + if (!cli_unlock(c, fnum2, n*sizeof(int), sizeof(int), -1, F_WRLCK)) { printf("unlock failed (%s)\n", cli_errstr(c)); } } @@ -436,13 +436,13 @@ static void run_locktest1(int dummy) return; } - if (!cli_lock(&cli1, fnum1, 0, 4, 0)) { + if (!cli_lock(&cli1, fnum1, 0, 4, 0, F_WRLCK)) { printf("lock1 failed (%s)\n", cli_errstr(&cli1)); return; } - if (cli_lock(&cli2, fnum3, 0, 4, 0)) { + if (cli_lock(&cli2, fnum3, 0, 4, 0, F_WRLCK)) { printf("lock2 succeeded! This is a locking bug\n"); return; } else { @@ -452,7 +452,7 @@ static void run_locktest1(int dummy) printf("Testing lock timeouts\n"); t1 = time(NULL); - if (cli_lock(&cli2, fnum3, 0, 4, 10*1000)) { + if (cli_lock(&cli2, fnum3, 0, 4, 10*1000, F_WRLCK)) { printf("lock3 succeeded! This is a locking bug\n"); return; } else { @@ -469,7 +469,7 @@ static void run_locktest1(int dummy) return; } - if (cli_lock(&cli2, fnum3, 0, 4, 0)) { + if (cli_lock(&cli2, fnum3, 0, 4, 0, F_WRLCK)) { printf("lock4 succeeded! This is a locking bug\n"); return; } else { @@ -550,12 +550,12 @@ static void run_locktest2(int dummy) cli_setpid(&cli, 1); - if (!cli_lock(&cli, fnum1, 0, 4, 0)) { + if (!cli_lock(&cli, fnum1, 0, 4, 0, F_WRLCK)) { printf("lock1 failed (%s)\n", cli_errstr(&cli)); return; } - if (cli_lock(&cli, fnum2, 0, 4, 0)) { + if (cli_lock(&cli, fnum2, 0, 4, 0, F_WRLCK)) { printf("lock2 succeeded! This is a locking bug\n"); } else { if (!check_error(&cli, ERRDOS, ERRlock, 0)) return; @@ -563,11 +563,11 @@ static void run_locktest2(int dummy) cli_setpid(&cli, 2); - if (cli_unlock(&cli, fnum1, 0, 4, 0)) { + if (cli_unlock(&cli, fnum1, 0, 4, 0, F_WRLCK)) { printf("unlock1 succeeded! This is a locking bug\n"); } - if (cli_lock(&cli, fnum3, 0, 4, 0)) { + if (cli_lock(&cli, fnum3, 0, 4, 0, F_WRLCK)) { printf("lock3 succeeded! This is a locking bug\n"); } else { if (!check_error(&cli, ERRDOS, ERRlock, 0)) return; @@ -633,14 +633,14 @@ static void run_locktest3(int dummy) for (offset=i=0;i