diff options
author | Andrew Tridgell <tridge@samba.org> | 2000-01-14 00:50:48 +0000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2000-01-14 00:50:48 +0000 |
commit | 2afd5d5eb5c176f09a9f4f00ea3b517e89ef0ddf (patch) | |
tree | e217622062ac847e81b944e1bf111f67c1c75c2a | |
parent | cdb8c99fce9b24d18f664f9ed42062f8a945e395 (diff) | |
download | samba-2afd5d5eb5c176f09a9f4f00ea3b517e89ef0ddf.tar.gz samba-2afd5d5eb5c176f09a9f4f00ea3b517e89ef0ddf.tar.bz2 samba-2afd5d5eb5c176f09a9f4f00ea3b517e89ef0ddf.zip |
some more work on the byte range locking
note the ugly global_smbpid - I hope that won't bethere for long, I
just didn't want to do two lots of major surgery at the one time.
Using global_smbpid avoids the big change of getting rid of our
inbuf/outbuf interface to reply routines. I'll do that once the
locking stuff passes all tests.
(This used to be commit f8bebf91abcaa5bda3ec8701f9242f220da8943a)
-rw-r--r-- | source3/locking/locking.c | 14 | ||||
-rw-r--r-- | source3/smbd/process.c | 9 | ||||
-rw-r--r-- | source3/utils/torture.c | 30 |
3 files changed, 31 insertions, 22 deletions
diff --git a/source3/locking/locking.c b/source3/locking/locking.c index a0d140bffd..e95ec08c58 100644 --- a/source3/locking/locking.c +++ b/source3/locking/locking.c @@ -38,6 +38,8 @@ extern int DEBUGLEVEL; /* the locking database handle */ static TDB_CONTEXT *tdb; +int global_smbpid; + /**************************************************************************** Utility function called to see if a file region is locked. ****************************************************************************/ @@ -53,8 +55,8 @@ BOOL is_locked(files_struct *fsp,connection_struct *conn, if (!lp_locking(snum) || !lp_strict_locking(snum)) return(False); - return !brl_locktest(fsp->fd_ptr->inode, fsp->fd_ptr->dev, - 1, getpid(), conn->cnum, + return !brl_locktest(fsp->fd_ptr->dev, fsp->fd_ptr->inode, + global_smbpid, getpid(), conn->cnum, offset, count, lock_type); } @@ -81,8 +83,8 @@ BOOL do_lock(files_struct *fsp,connection_struct *conn, lock_type, (double)offset, (double)count, fsp->fsp_name )); if (OPEN_FSP(fsp) && fsp->can_lock && (fsp->conn == conn)) { - ok = brl_lock(fsp->fd_ptr->inode, fsp->fd_ptr->dev, - 1, getpid(), conn->cnum, + ok = brl_lock(fsp->fd_ptr->dev, fsp->fd_ptr->inode, + global_smbpid, getpid(), conn->cnum, offset, count, lock_type); } @@ -112,8 +114,8 @@ BOOL do_unlock(files_struct *fsp,connection_struct *conn, (double)offset, (double)count, fsp->fsp_name )); if (OPEN_FSP(fsp) && fsp->can_lock && (fsp->conn == conn)) { - ok = brl_unlock(fsp->fd_ptr->inode, fsp->fd_ptr->dev, - 1, getpid(), conn->cnum, + ok = brl_unlock(fsp->fd_ptr->dev, fsp->fd_ptr->inode, + global_smbpid, getpid(), conn->cnum, offset, count); } diff --git a/source3/smbd/process.c b/source3/smbd/process.c index 04432adb96..d3551b96b1 100644 --- a/source3/smbd/process.c +++ b/source3/smbd/process.c @@ -25,7 +25,7 @@ extern int DEBUGLEVEL; struct timeval smb_last_time; -char *InBuffer = NULL; +static char *InBuffer = NULL; char *OutBuffer = NULL; char *last_inbuf = NULL; @@ -420,6 +420,7 @@ static int switch_message(int type,char *inbuf,char *outbuf,int size,int bufsize sizeof(smb_messages) / sizeof(struct smb_message_struct); int match; extern int Client; + extern int global_smbpid; if (pid == (pid_t)-1) pid = getpid(); @@ -438,6 +439,10 @@ static int switch_message(int type,char *inbuf,char *outbuf,int size,int bufsize if (smb_messages[match].code == type) break; + /* yuck! this is an interim measure before we get rid of our + current inbuf/outbuf system */ + global_smbpid = SVAL(inbuf,smb_pid); + if (match == num_smb_messages) { DEBUG(0,("Unknown message type %d!\n",type)); @@ -841,7 +846,7 @@ void check_reload(int t) } /**************************************************************************** - Process any timeout housekeeping. Return False if the caler should exit. + Process any timeout housekeeping. Return False if the caller should exit. ****************************************************************************/ static BOOL timeout_processing(int deadtime, int *select_timeout, time_t *last_timeout_processing_time) diff --git a/source3/utils/torture.c b/source3/utils/torture.c index e905216d38..ba510c0b58 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, F_WRLCK)) { + while (!cli_lock(c, fnum, offset, len, -1, WRITE_LOCK)) { if (!check_error(c, ERRDOS, ERRlock, 0)) return False; } return True; @@ -436,13 +436,13 @@ static void run_locktest1(int dummy) return; } - if (!cli_lock(&cli1, fnum1, 0, 4, 0, F_WRLCK)) { + if (!cli_lock(&cli1, fnum1, 0, 4, 0, WRITE_LOCK)) { printf("lock1 failed (%s)\n", cli_errstr(&cli1)); return; } - if (cli_lock(&cli2, fnum3, 0, 4, 0, F_WRLCK)) { + if (cli_lock(&cli2, fnum3, 0, 4, 0, WRITE_LOCK)) { 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, F_WRLCK)) { + if (cli_lock(&cli2, fnum3, 0, 4, 10*1000, WRITE_LOCK)) { 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, F_WRLCK)) { + if (cli_lock(&cli2, fnum3, 0, 4, 0, WRITE_LOCK)) { printf("lock4 succeeded! This is a locking bug\n"); return; } else { @@ -550,12 +550,14 @@ static void run_locktest2(int dummy) cli_setpid(&cli, 1); - if (!cli_lock(&cli, fnum1, 0, 4, 0, F_WRLCK)) { + sleep(10); + + if (!cli_lock(&cli, fnum1, 0, 4, 0, WRITE_LOCK)) { printf("lock1 failed (%s)\n", cli_errstr(&cli)); return; } - if (cli_lock(&cli, fnum2, 0, 4, 0, F_WRLCK)) { + if (cli_lock(&cli, fnum2, 0, 4, 0, WRITE_LOCK)) { printf("lock2 succeeded! This is a locking bug\n"); } else { if (!check_error(&cli, ERRDOS, ERRlock, 0)) return; @@ -567,7 +569,7 @@ static void run_locktest2(int dummy) printf("unlock1 succeeded! This is a locking bug\n"); } - if (cli_lock(&cli, fnum3, 0, 4, 0, F_WRLCK)) { + if (cli_lock(&cli, fnum3, 0, 4, 0, WRITE_LOCK)) { printf("lock3 succeeded! This is a locking bug\n"); } else { if (!check_error(&cli, ERRDOS, ERRlock, 0)) return; @@ -633,14 +635,14 @@ static void run_locktest3(int dummy) for (offset=i=0;i<numops;i++) { NEXT_OFFSET; - if (!cli_lock(&cli1, fnum1, offset-1, 1, 0, F_WRLCK)) { + if (!cli_lock(&cli1, fnum1, offset-1, 1, 0, WRITE_LOCK)) { printf("lock1 %d failed (%s)\n", i, cli_errstr(&cli1)); return; } - if (!cli_lock(&cli2, fnum2, offset-2, 1, 0, F_WRLCK)) { + if (!cli_lock(&cli2, fnum2, offset-2, 1, 0, WRITE_LOCK)) { printf("lock2 %d failed (%s)\n", i, cli_errstr(&cli1)); @@ -651,22 +653,22 @@ static void run_locktest3(int dummy) for (offset=i=0;i<numops;i++) { NEXT_OFFSET; - if (cli_lock(&cli1, fnum1, offset-2, 1, 0, F_WRLCK)) { + if (cli_lock(&cli1, fnum1, offset-2, 1, 0, WRITE_LOCK)) { printf("error: lock1 %d succeeded!\n", i); return; } - if (cli_lock(&cli2, fnum2, offset-1, 1, 0, F_WRLCK)) { + if (cli_lock(&cli2, fnum2, offset-1, 1, 0, WRITE_LOCK)) { printf("error: lock2 %d succeeded!\n", i); return; } - if (cli_lock(&cli1, fnum1, offset-1, 1, 0, F_WRLCK)) { + if (cli_lock(&cli1, fnum1, offset-1, 1, 0, WRITE_LOCK)) { printf("error: lock3 %d succeeded!\n", i); return; } - if (cli_lock(&cli2, fnum2, offset-2, 1, 0, F_WRLCK)) { + if (cli_lock(&cli2, fnum2, offset-2, 1, 0, WRITE_LOCK)) { printf("error: lock4 %d succeeded!\n", i); return; } |