- if (tdb->file->allrecord_lock.count &&
- (ltype == tdb->file->allrecord_lock.ltype || ltype == F_RDLCK)) {
- return 0;
+ if (tdb->file->allrecord_lock.count) {
+ if (!check_lock_pid(tdb, "tdb1_lock_list", true)) {
+ tdb->last_error = TDB_ERR_LOCK;
+ return -1;
+ }
+ if (tdb->file->allrecord_lock.owner != tdb) {
+ tdb->last_error = owner_conflict(tdb, "tdb1_lock_list");
+ return -1;
+ }
+ if (ltype == tdb->file->allrecord_lock.ltype
+ || ltype == F_RDLCK) {
+ return 0;
+ }
+ tdb->last_error = tdb_logerr(tdb, TDB_ERR_LOCK,
+ TDB_LOG_USE_ERROR,
+ "tdb1_lock_list:"
+ " already have read lock");
+ return -1;