r2981: Fix incorrect locks/unlocks in tdb_lockkeys()/tdb_unlockkeys().
authorJeremy Allison <jra@samba.org>
Fri, 15 Oct 2004 00:03:26 +0000 (00:03 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 17:59:54 +0000 (12:59 -0500)
Spotted by Taj Khattra <taj.khattra@gmail.com>.
Jeremy.
(This used to be commit a7d92301bbf45cb9e475e4876fdbb37644ad5871)

source4/lib/tdb/common/tdb.c

index 4ae23bead712abc0e571c453643be1d64dfcba56..c1deef80cd34142b20f6311e8c86df8a49f833c6 100644 (file)
@@ -2037,13 +2037,13 @@ int tdb_lockkeys(TDB_CONTEXT *tdb, u32 number, TDB_DATA keys[])
        }
        /* Finally, lock in order */
        for (i = 0; i < number; i++)
-               if (tdb_lock(tdb, i, F_WRLCK))
+               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, j, F_WRLCK);
+                       tdb_unlock(tdb, BUCKET(tdb->lockedkeys[j+1]), F_WRLCK);
                SAFE_FREE(tdb->lockedkeys);
                return TDB_ERRCODE(TDB_ERR_NOLOCK, -1);
        }
@@ -2057,7 +2057,7 @@ void tdb_unlockkeys(TDB_CONTEXT *tdb)
        if (!tdb->lockedkeys)
                return;
        for (i = 0; i < tdb->lockedkeys[0]; i++)
-               tdb_unlock(tdb, tdb->lockedkeys[i+1], F_WRLCK);
+               tdb_unlock(tdb, BUCKET(tdb->lockedkeys[i+1]), F_WRLCK);
        SAFE_FREE(tdb->lockedkeys);
 }