svn commit: samba r2999 - in branches/SAMBA_3_0/source/tdb: .

jra at samba.org jra at samba.org
Fri Oct 15 19:45:14 GMT 2004


Author: jra
Date: 2004-10-15 19:45:13 +0000 (Fri, 15 Oct 2004)
New Revision: 2999

WebSVN: http://websvn.samba.org/websvn/changeset.php?rep=samba&path=/branches/SAMBA_3_0/source/tdb&rev=2999&nolog=1

Log:
Remove lockedkeys code. Not used.
Jeremy.

Modified:
   branches/SAMBA_3_0/source/tdb/tdb.c
   branches/SAMBA_3_0/source/tdb/tdb.h


Changeset:
Modified: branches/SAMBA_3_0/source/tdb/tdb.c
===================================================================
--- branches/SAMBA_3_0/source/tdb/tdb.c	2004-10-15 19:44:47 UTC (rev 2998)
+++ branches/SAMBA_3_0/source/tdb/tdb.c	2004-10-15 19:45:13 UTC (rev 2999)
@@ -1007,26 +1007,12 @@
 	return TDB_ERRCODE(TDB_ERR_NOEXIST, 0);
 }
 
-/* If they do lockkeys, check that this hash is one they locked */
-static int tdb_keylocked(TDB_CONTEXT *tdb, u32 hash)
-{
-	u32 i;
-	if (!tdb->lockedkeys)
-		return 1;
-	for (i = 0; i < tdb->lockedkeys[0]; i++)
-		if (tdb->lockedkeys[i+1] == hash)
-			return 1;
-	return TDB_ERRCODE(TDB_ERR_NOLOCK, 0);
-}
-
 /* As tdb_find, but if you succeed, keep the lock */
 static tdb_off tdb_find_lock_hash(TDB_CONTEXT *tdb, TDB_DATA key, u32 hash, int locktype,
 			     struct list_struct *rec)
 {
 	u32 rec_ptr;
 
-	if (!tdb_keylocked(tdb, hash))
-		return 0;
 	if (tdb_lock(tdb, BUCKET(hash), locktype) == -1)
 		return 0;
 	if (!(rec_ptr = tdb_find(tdb, key, hash, rec)))
@@ -1228,10 +1214,6 @@
 {
 	int want_next = (tlock->off != 0);
 
-	/* No traversal allows if you've called tdb_lockkeys() */
-	if (tdb->lockedkeys)
-		return TDB_ERRCODE(TDB_ERR_NOLOCK, -1);
-
 	/* Lock each chain from the start one. */
 	for (; tlock->hash < tdb->header.hash_size; tlock->hash++) {
 		if (tdb_lock(tdb, tlock->hash, F_WRLCK) == -1)
@@ -1463,8 +1445,6 @@
 
 	/* find which hash bucket it is in */
 	hash = tdb->hash_fn(&key);
-	if (!tdb_keylocked(tdb, hash))
-		return -1;
 	if (tdb_lock(tdb, BUCKET(hash), F_WRLCK) == -1)
 		return -1;
 
@@ -1581,8 +1561,6 @@
 
 	/* find which hash bucket it is in */
 	hash = tdb->hash_fn(&key);
-	if (!tdb_keylocked(tdb, hash))
-		return -1;
 	if (tdb_lock(tdb, BUCKET(hash), F_WRLCK) == -1)
 		return -1;
 
@@ -1725,7 +1703,6 @@
 	tdb->fd = -1;
 	tdb->name = NULL;
 	tdb->map_ptr = NULL;
-	tdb->lockedkeys = NULL;
 	tdb->flags = tdb_flags;
 	tdb->open_flags = open_flags;
 	tdb->log_fn = log_fn;
@@ -1913,7 +1890,6 @@
 	if (tdb->fd != -1)
 		ret = close(tdb->fd);
 	SAFE_FREE(tdb->locked);
-	SAFE_FREE(tdb->lockedkeys);
 
 	/* Remove from contexts list */
 	for (i = &tdbs; *i; i = &(*i)->next) {
@@ -1937,8 +1913,6 @@
 	/* There are no locks on read-only dbs */
 	if (tdb->read_only)
 		return TDB_ERRCODE(TDB_ERR_LOCK, -1);
-	if (tdb->lockedkeys)
-		return TDB_ERRCODE(TDB_ERR_NOLOCK, -1);
 	for (i = 0; i < tdb->header.hash_size; i++) 
 		if (tdb_lock(tdb, i, F_WRLCK))
 			break;
@@ -1961,51 +1935,6 @@
 		tdb_unlock(tdb, i, F_WRLCK);
 }
 
-int tdb_lockkeys(TDB_CONTEXT *tdb, u32 number, TDB_DATA keys[])
-{
-	u32 i, j, hash;
-
-	/* Can't lock more keys if already locked */
-	if (tdb->lockedkeys)
-		return TDB_ERRCODE(TDB_ERR_NOLOCK, -1);
-	if (!(tdb->lockedkeys = malloc(sizeof(u32) * (number+1))))
-		return TDB_ERRCODE(TDB_ERR_OOM, -1);
-	/* First number in array is # keys */
-	tdb->lockedkeys[0] = number;
-
-	/* Insertion sort by bucket */
-	for (i = 0; i < number; i++) {
-		hash = tdb->hash_fn(&keys[i]);
-		for (j = 0; j < i && BUCKET(tdb->lockedkeys[j+1]) < BUCKET(hash); j++);
-			memmove(&tdb->lockedkeys[j+2], &tdb->lockedkeys[j+1], sizeof(u32) * (i-j));
-		tdb->lockedkeys[j+1] = hash;
-	}
-	/* Finally, lock in order */
-	for (i = 0; i < number; i++)
-		if (tdb_lock(tdb, BUCKET(tdb->lockedkeys[i+1]), F_WRLCK))
-			break;
-
-	/* If error, release locks we have... */
-	if (i < number) {
-		for ( j = 0; j < i; j++)
-			tdb_unlock(tdb, BUCKET(tdb->lockedkeys[j+1]), F_WRLCK);
-		SAFE_FREE(tdb->lockedkeys);
-		return TDB_ERRCODE(TDB_ERR_NOLOCK, -1);
-	}
-	return 0;
-}
-
-/* Unlock the keys previously locked by tdb_lockkeys() */
-void tdb_unlockkeys(TDB_CONTEXT *tdb)
-{
-	u32 i;
-	if (!tdb->lockedkeys)
-		return;
-	for (i = 0; i < tdb->lockedkeys[0]; i++)
-		tdb_unlock(tdb, BUCKET(tdb->lockedkeys[i+1]), F_WRLCK);
-	SAFE_FREE(tdb->lockedkeys);
-}
-
 /* lock/unlock one hash chain. This is meant to be used to reduce
    contention - it cannot guarantee how many records will be locked */
 int tdb_chainlock(TDB_CONTEXT *tdb, TDB_DATA key)

Modified: branches/SAMBA_3_0/source/tdb/tdb.h
===================================================================
--- branches/SAMBA_3_0/source/tdb/tdb.h	2004-10-15 19:44:47 UTC (rev 2998)
+++ branches/SAMBA_3_0/source/tdb/tdb.h	2004-10-15 19:45:13 UTC (rev 2999)
@@ -107,7 +107,6 @@
 	enum TDB_ERROR ecode; /* error code for last tdb error */
 	struct tdb_header header; /* a cached copy of the header */
 	u32 flags; /* the flags passed to tdb_open */
-	u32 *lockedkeys; /* array of locked keys: first is #keys */
 	struct tdb_traverse_lock travlocks; /* current traversal locks */
 	struct tdb_context *next; /* all tdbs to avoid multiple opens */
 	dev_t device;	/* uniquely identifies this tdb */



More information about the samba-cvs mailing list