summaryrefslogtreecommitdiffstats
path: root/source3/locking/locking.c
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2001-08-22 01:01:37 +0000
committerJeremy Allison <jra@samba.org>2001-08-22 01:01:37 +0000
commit85e063f5b8b9ac872dc5e30da99b34230434df84 (patch)
tree3ef37602acb9bad140786280f30b3243044baa06 /source3/locking/locking.c
parente4275a35a64fde95a3b59307572d44c8d53909ad (diff)
downloadsamba-85e063f5b8b9ac872dc5e30da99b34230434df84.tar.gz
samba-85e063f5b8b9ac872dc5e30da99b34230434df84.tar.xz
samba-85e063f5b8b9ac872dc5e30da99b34230434df84.zip
Tidyup fixes for fcntl spin problem.
Jeremy. (This used to be commit 27d3dd0e7cb777ef6b21d6966c07045c2940fd37)
Diffstat (limited to 'source3/locking/locking.c')
-rw-r--r--source3/locking/locking.c41
1 files changed, 30 insertions, 11 deletions
diff --git a/source3/locking/locking.c b/source3/locking/locking.c
index fea821baa17..80537c8bc1b 100644
--- a/source3/locking/locking.c
+++ b/source3/locking/locking.c
@@ -299,7 +299,7 @@ BOOL locking_init(int read_only)
return True;
tdb = tdb_open_log(lock_path("locking.tdb"),
- 0, TDB_CLEAR_IF_FIRST|USE_TDB_MMAP_FLAG,
+ 0, USE_TDB_MMAP_FLAG|(read_only?0x0:TDB_CLEAR_IF_FIRST),
read_only?O_RDONLY:O_RDWR|O_CREAT,
0644);
@@ -365,18 +365,35 @@ static TDB_DATA locking_key_fsp(files_struct *fsp)
return locking_key(fsp->dev, fsp->inode);
}
+#ifndef LOCK_SHARE_ENTRY_SPIN_COUNT
+#define LOCK_SHARE_ENTRY_SPIN_COUNT 100
+#endif
+
/*******************************************************************
Lock a hash bucket entry.
******************************************************************/
+
BOOL lock_share_entry(connection_struct *conn,
SMB_DEV_T dev, SMB_INO_T inode)
{
+#if 1 /* JRATEST */
+ int count = 0;
+ for (count = 0; count < LOCK_SHARE_ENTRY_SPIN_COUNT; count++)
+ if (tdb_chainlock(tdb, locking_key(dev, inode)) == 0)
+ return True;
+ else
+ DEBUG(0,("lock_share_entry: locking (%d) for dev = %x, inode = %.0f failed with error %s\n",
+ count, (unsigned int)dev, (double)inode, strerror(errno) ));
+ return False;
+#else
return tdb_chainlock(tdb, locking_key(dev, inode)) == 0;
+#endif
}
/*******************************************************************
Unlock a hash bucket entry.
******************************************************************/
+
void unlock_share_entry(connection_struct *conn,
SMB_DEV_T dev, SMB_INO_T inode)
{
@@ -389,7 +406,18 @@ void unlock_share_entry(connection_struct *conn,
BOOL lock_share_entry_fsp(files_struct *fsp)
{
+#if 1 /* JRATEST */
+ int count = 0;
+ for (count = 0; count < LOCK_SHARE_ENTRY_SPIN_COUNT; count++)
+ if (tdb_chainlock(tdb, locking_key(fsp->dev, fsp->inode)) == 0)
+ return True;
+ else
+ DEBUG(0,("lock_share_entry_fsp: locking (%d) for dev = %x, inode = %.0f failed with error %s\n",
+ count, (unsigned int)fsp->dev, (double)fsp->inode, strerror(errno) ));
+ return False;
+#else
return tdb_chainlock(tdb, locking_key(fsp->dev, fsp->inode)) == 0;
+#endif
}
/*******************************************************************
@@ -465,7 +493,7 @@ BOOL share_modes_identical( share_mode_entry *e1, share_mode_entry *e2)
Ignore if no entry deleted.
********************************************************************/
-static ssize_t del_share_entry( SMB_DEV_T dev, SMB_INO_T inode,
+ssize_t del_share_entry( SMB_DEV_T dev, SMB_INO_T inode,
share_mode_entry *entry, share_mode_entry **ppse)
{
TDB_DATA dbuf;
@@ -706,15 +734,6 @@ BOOL downgrade_share_oplock(files_struct *fsp)
}
/*******************************************************************
- Delete an exclusive share oplock owned by a defunct smbd..
-********************************************************************/
-
-BOOL clear_share_entry(SMB_DEV_T dev, SMB_INO_T inode, share_mode_entry *entry)
-{
- return mod_share_mode(dev, inode, entry, remove_share_oplock_fn, NULL);
-}
-
-/*******************************************************************
Get/Set the delete on close flag in a set of share modes.
Return False on fail, True on success.
********************************************************************/