- if (tdb->transaction->global_lock_taken) {
- tdb_brunlock(tdb, F_WRLCK, GLOBAL_LOCK, 1);
- tdb->transaction->global_lock_taken = false;
- }
-
- /* remove any global lock created during the transaction */
- if (tdb->global_lock.count != 0) {
- tdb_brunlock(tdb, tdb->global_lock.ltype,
- FREELIST_TOP, 4*tdb->header.hash_size);
- tdb->global_lock.count = 0;
- }
-
- /* remove any locks created during the transaction */
- if (tdb->num_locks != 0) {
- for (i=0;i<tdb->num_lockrecs;i++) {
- tdb_brunlock(tdb, tdb->lockrecs[i].ltype,
- FREELIST_TOP+4*tdb->lockrecs[i].list, 1);
- }
- tdb->num_locks = 0;
- tdb->num_lockrecs = 0;
- SAFE_FREE(tdb->lockrecs);
- }
+ /* This also removes the OPEN_LOCK, if we have it. */
+ tdb_release_extra_locks(tdb);