| 400 | |
| 401 | |
| 402 | void LockManager::shutdownOwner(thread_db* tdbb, SRQ_PTR* owner_handle) |
| 403 | { |
| 404 | /************************************** |
| 405 | * |
| 406 | * s h u t d o w n O w n e r |
| 407 | * |
| 408 | ************************************** |
| 409 | * |
| 410 | * Functional description |
| 411 | * Release the owner block and any outstanding locks. |
| 412 | * The exit handler will unmap the shared memory. |
| 413 | * |
| 414 | **************************************/ |
| 415 | LOCK_TRACE(("LM::fini (%ld)\n", *owner_handle)); |
| 416 | |
| 417 | const SRQ_PTR owner_offset = *owner_handle; |
| 418 | if (!owner_offset) |
| 419 | return; |
| 420 | |
| 421 | LockTableGuard guard(this, FB_FUNCTION, owner_offset); |
| 422 | |
| 423 | own* owner = (own*) SRQ_ABS_PTR(owner_offset); |
| 424 | if (!owner->own_count) |
| 425 | return; |
| 426 | |
| 427 | if (--owner->own_count > 0) |
| 428 | return; |
| 429 | |
| 430 | while (owner->own_ast_count) |
| 431 | { |
| 432 | { // checkout scope |
| 433 | LockTableCheckout checkout(this, FB_FUNCTION); |
| 434 | EngineCheckout cout(tdbb, FB_FUNCTION, EngineCheckout::UNNECESSARY); |
| 435 | Thread::sleep(10); |
| 436 | } |
| 437 | |
| 438 | owner = (own*) SRQ_ABS_PTR(owner_offset); |
| 439 | } |
| 440 | |
| 441 | // This assert expects that all the granted locks have been explicitly |
| 442 | // released before destroying the lock owner. This is not strictly required, |
| 443 | // but it enforces the proper object lifetime discipline through the codebase. |
| 444 | fb_assert(SRQ_EMPTY(owner->own_requests)); |
| 445 | |
| 446 | purge_owner(owner_offset, owner); |
| 447 | |
| 448 | *owner_handle = 0; |
| 449 | } |
| 450 | |
| 451 | |
| 452 | SRQ_PTR LockManager::enqueue(thread_db* tdbb, |