mirror of
https://github.com/samba-team/samba.git
synced 2024-12-23 17:34:34 +03:00
r2979: Fix incorrect locks/unlocks in tdb_lockkeys()/tdb_unlockkeys().
Spotted by Taj Khattra <taj.khattra@gmail.com>. Jeremy.
This commit is contained in:
parent
4fd314243e
commit
365b203164
@ -1811,7 +1811,7 @@ TDB_CONTEXT *tdb_open_ex(const char *name, int hash_size, int tdb_flags,
|
|||||||
if (tdb_already_open(st.st_dev, st.st_ino)) {
|
if (tdb_already_open(st.st_dev, st.st_ino)) {
|
||||||
TDB_LOG((tdb, 2, "tdb_open_ex: "
|
TDB_LOG((tdb, 2, "tdb_open_ex: "
|
||||||
"%s (%d,%d) is already open in this process\n",
|
"%s (%d,%d) is already open in this process\n",
|
||||||
name, st.st_dev, st.st_ino));
|
name, (int)st.st_dev, (int)st.st_ino));
|
||||||
errno = EBUSY;
|
errno = EBUSY;
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
@ -1982,13 +1982,13 @@ int tdb_lockkeys(TDB_CONTEXT *tdb, u32 number, TDB_DATA keys[])
|
|||||||
}
|
}
|
||||||
/* Finally, lock in order */
|
/* Finally, lock in order */
|
||||||
for (i = 0; i < number; i++)
|
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;
|
break;
|
||||||
|
|
||||||
/* If error, release locks we have... */
|
/* If error, release locks we have... */
|
||||||
if (i < number) {
|
if (i < number) {
|
||||||
for ( j = 0; j < i; j++)
|
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);
|
SAFE_FREE(tdb->lockedkeys);
|
||||||
return TDB_ERRCODE(TDB_ERR_NOLOCK, -1);
|
return TDB_ERRCODE(TDB_ERR_NOLOCK, -1);
|
||||||
}
|
}
|
||||||
@ -2002,7 +2002,7 @@ void tdb_unlockkeys(TDB_CONTEXT *tdb)
|
|||||||
if (!tdb->lockedkeys)
|
if (!tdb->lockedkeys)
|
||||||
return;
|
return;
|
||||||
for (i = 0; i < tdb->lockedkeys[0]; i++)
|
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);
|
SAFE_FREE(tdb->lockedkeys);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user