* ResLockRelease -- release a resource lock. * * The "locktag" here consists of the queue-id and the "lockmethod" of * "resource-queue" and an identifier specifying that this is a * resource-locktag. */
| 620 | * resource-locktag. |
| 621 | */ |
| 622 | bool |
| 623 | ResLockRelease(LOCKTAG *locktag, uint32 resPortalId) |
| 624 | { |
| 625 | LOCKMODE lockmode = ExclusiveLock; |
| 626 | LOCK *lock; |
| 627 | PROCLOCK *proclock; |
| 628 | LOCALLOCKTAG localtag; |
| 629 | LOCALLOCK *locallock; |
| 630 | uint32 hashcode; |
| 631 | LWLockId partitionLock; |
| 632 | ResourceOwner owner; |
| 633 | |
| 634 | ResPortalIncrement *incrementSet; |
| 635 | ResPortalTag portalTag; |
| 636 | bool resLockAcquireOrReleaseInterrupted = false; |
| 637 | |
| 638 | /* Check the lock method bits. */ |
| 639 | Assert(locktag->locktag_lockmethodid == RESOURCE_LOCKMETHOD); |
| 640 | |
| 641 | /* Check whether previous ResLockAcquire() was interrupted. */ |
| 642 | if (resLockAcquireStatus != RQA_NOT_STARTED_OR_DONE) |
| 643 | { |
| 644 | elog(LOG, |
| 645 | "Resource queue %d: previous ResLockAcquire() interrupted, " |
| 646 | " status = %d, portal id = %u", |
| 647 | locktag->locktag_field1, |
| 648 | resLockAcquireStatus, |
| 649 | resPortalId); |
| 650 | resLockAcquireOrReleaseInterrupted = true; |
| 651 | } |
| 652 | |
| 653 | /* |
| 654 | * ResLockRelease() might re-enter. |
| 655 | * Check whether previous ResLockRelease() was interrupted. |
| 656 | */ |
| 657 | if (resLockReleaseStatus != RQR_NOT_STARTED_OR_DONE) |
| 658 | { |
| 659 | elog(LOG, |
| 660 | "Resource queue %d: previous ResLockRelease() interrupted, " |
| 661 | " status = %d, portal id = %u", |
| 662 | locktag->locktag_field1, |
| 663 | resLockReleaseStatus, |
| 664 | resPortalId); |
| 665 | resLockAcquireOrReleaseInterrupted = true; |
| 666 | } |
| 667 | resLockReleaseStatus = RQR_STARTED; |
| 668 | |
| 669 | /* Provide a resource owner. */ |
| 670 | owner = CurrentResourceOwner; |
| 671 | |
| 672 | /* |
| 673 | * Find the LOCALLOCK entry for this lock and lockmode |
| 674 | */ |
| 675 | MemSet(&localtag, 0, sizeof(localtag)); /* must clear padding */ |
| 676 | localtag.lock = *locktag; |
| 677 | localtag.mode = lockmode; |
| 678 | |
| 679 | locallock = (LOCALLOCK *) |
no test coverage detected