diff options
author | Jeremy Allison <jra@samba.org> | 2000-04-27 23:28:56 +0000 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2000-04-27 23:28:56 +0000 |
commit | 6baa96bb466915cc17e8cbad50254d6bd47b967b (patch) | |
tree | cb2ca759fdfb972790e0798e96357333657c2c1c /source/locking/locking.c | |
parent | 2746e5602e493e5b022764b4b839eb4d2f14363b (diff) | |
download | samba-6baa96bb466915cc17e8cbad50254d6bd47b967b.tar.gz samba-6baa96bb466915cc17e8cbad50254d6bd47b967b.tar.xz samba-6baa96bb466915cc17e8cbad50254d6bd47b967b.zip |
Ok - this is more subtle than it looks :-).
When a file is being closed, once it passes the fnum and tid tests then
the locking context should be ignored when removing all locks. This is
what is done in the brl close case, but when you have outstanding
POSIX locks, then you cannot remove all the brl locks in one go, you
have to get the lock list and call do_unlock individually. As this
uses global_smbpid as the locking context, you need to make sure
that this is set correctly for the specific lock being removed. I
now do this by storing the smbpid in each entry in the unlock list returned from
the query call. I removed the smbpid from fsp (not needed) and
things seem ok (even with the stupid smbpid tricks that smbtorture plays :-).
Jeremy.
Diffstat (limited to 'source/locking/locking.c')
-rw-r--r-- | source/locking/locking.c | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/source/locking/locking.c b/source/locking/locking.c index b6b34138e36..088693b6d42 100644 --- a/source/locking/locking.c +++ b/source/locking/locking.c @@ -37,6 +37,7 @@ #include "includes.h" extern int DEBUGLEVEL; +int global_smbpid; /* the locking database handle */ static TDB_CONTEXT *tdb; @@ -567,7 +568,7 @@ BOOL is_locked(files_struct *fsp,connection_struct *conn, return(False); ret = !brl_locktest(fsp->dev, fsp->inode, - fsp->smbpid, getpid(), conn->cnum, + global_smbpid, getpid(), conn->cnum, offset, count, lock_type); /* @@ -605,7 +606,7 @@ BOOL do_lock(files_struct *fsp,connection_struct *conn, if (OPEN_FSP(fsp) && fsp->can_lock && (fsp->conn == conn)) { ok = brl_lock(fsp->dev, fsp->inode, fsp->fnum, - fsp->smbpid, getpid(), conn->cnum, + global_smbpid, getpid(), conn->cnum, offset, count, lock_type); @@ -625,7 +626,7 @@ BOOL do_lock(files_struct *fsp,connection_struct *conn, * lock entry. */ (void)brl_unlock(fsp->dev, fsp->inode, fsp->fnum, - fsp->smbpid, getpid(), conn->cnum, + global_smbpid, getpid(), conn->cnum, offset, count); } } @@ -674,7 +675,7 @@ BOOL do_unlock(files_struct *fsp,connection_struct *conn, pid = getpid(); ok = brl_unlock(fsp->dev, fsp->inode, fsp->fnum, - fsp->smbpid, pid, conn->cnum, offset, count); + global_smbpid, pid, conn->cnum, offset, count); if (!ok) { DEBUG(10,("do_unlock: returning ERRlock.\n" )); @@ -705,6 +706,7 @@ BOOL do_unlock(files_struct *fsp,connection_struct *conn, ZERO_STRUCTP(ul); ul->start = offset; ul->size = count; + ul->smbpid = global_smbpid; DLIST_ADD(ulist, ul); @@ -770,12 +772,16 @@ void locking_close_file(files_struct *fsp) /* * Now unlock all of them. This will remove the brl entry also - * for each lock. + * for each lock. Note we need to make sure the global_smbpid matches + * the one associated with each lock in case the client plays games + * with smbpids (like smbtorture does :-). */ - for(; ul; ul = ul->next) + for(; ul; ul = ul->next) { + global_smbpid = ul->smbpid; do_unlock(fsp,fsp->conn,ul->size,ul->start,&eclass,&ecode); - + } + talloc_destroy(ul_ctx); } else { |