| 1499 | } |
| 1500 | |
| 1501 | void Lock::setLockAttachment(Jrd::Attachment* attachment) |
| 1502 | { |
| 1503 | if (get_owner_type(lck_type) == LCK_OWNER_database) |
| 1504 | return; |
| 1505 | |
| 1506 | Attachment* att = lck_attachment ? lck_attachment->getHandle() : NULL; |
| 1507 | if (att == attachment) |
| 1508 | return; |
| 1509 | |
| 1510 | // If lock has no attachment it must not be a part of linked list |
| 1511 | fb_assert(!lck_attachment ? !lck_prior && !lck_next : true); |
| 1512 | |
| 1513 | // Delist in old attachment |
| 1514 | if (att) |
| 1515 | { |
| 1516 | // Check that attachment seems to be valid, check works only when DEBUG_GDS_ALLOC is defined |
| 1517 | fb_assert(att->att_flags != 0xEEEEEEEE); |
| 1518 | |
| 1519 | if (lck_prior) |
| 1520 | { |
| 1521 | fb_assert(lck_prior->lck_next == this); |
| 1522 | lck_prior->lck_next = lck_next; |
| 1523 | #ifdef DEBUG_LCK_LIST |
| 1524 | lck_prior->lck_next_type = lck_next ? lck_next->lck_type : 0; |
| 1525 | #endif |
| 1526 | } |
| 1527 | else |
| 1528 | { |
| 1529 | fb_assert(att->att_long_locks == this); |
| 1530 | att->att_long_locks = lck_next; |
| 1531 | #ifdef DEBUG_LCK_LIST |
| 1532 | att->att_long_locks_type = lck_next ? lck_next->lck_type : 0; |
| 1533 | #endif |
| 1534 | } |
| 1535 | |
| 1536 | if (lck_next) |
| 1537 | { |
| 1538 | fb_assert(lck_next->lck_prior == this); |
| 1539 | lck_next->lck_prior = lck_prior; |
| 1540 | #ifdef DEBUG_LCK_LIST |
| 1541 | lck_next->lck_prev_type = lck_prior ? lck_prior->lck_type : 0; |
| 1542 | #endif |
| 1543 | } |
| 1544 | |
| 1545 | lck_next = NULL; |
| 1546 | lck_prior = NULL; |
| 1547 | } |
| 1548 | |
| 1549 | // Enlist in new attachment |
| 1550 | if (attachment) |
| 1551 | { |
| 1552 | // Check that attachment seems to be valid, check works only when DEBUG_GDS_ALLOC is defined |
| 1553 | fb_assert(attachment->att_flags != 0xEEEEEEEE); |
| 1554 | |
| 1555 | lck_next = attachment->att_long_locks; |
| 1556 | lck_prior = NULL; |
| 1557 | attachment->att_long_locks = this; |
| 1558 |
no test coverage detected