mirror of
https://github.com/samba-team/samba.git
synced 2025-01-12 09:18:10 +03:00
r2981: Fix incorrect locks/unlocks in tdb_lockkeys()/tdb_unlockkeys().
Spotted by Taj Khattra <taj.khattra@gmail.com>. Jeremy.
This commit is contained in:
parent
a079e044f0
commit
a7d92301bb
@ -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);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user