- tdb_brunlock(tdb, tdb->lockrecs[i].ltype,
- tdb->lockrecs[i].off, 1);
+ struct tdb_lock_type *lck = &tdb->lockrecs[i];
+
+ /* Don't release transaction or active locks! */
+ if (tdb->transaction && lck->off == TRANSACTION_LOCK) {
+ tdb->lockrecs[extra++] = *lck;
+ } else if (lck->off == ACTIVE_LOCK) {
+ tdb->lockrecs[extra++] = *lck;
+ } else {
+ tdb_brunlock(tdb, lck->ltype, lck->off, 1);
+ }
+ }
+ tdb->num_lockrecs = extra;
+ if (tdb->num_lockrecs == 0) {
+ SAFE_FREE(tdb->lockrecs);