diff options
author | Robert Haas <rhaas@postgresql.org> | 2014-10-30 14:55:23 -0400 |
---|---|---|
committer | Robert Haas <rhaas@postgresql.org> | 2014-10-30 14:55:23 -0400 |
commit | f7102b04638a882b38cbba7670471a073a939865 (patch) | |
tree | f04bc3dc8078c2e21aa82fa6860f31ad50172d89 /src/backend/storage/ipc/dsm.c | |
parent | fd0f651a867ce4a25160e37bcb9085f3b3209bf8 (diff) | |
download | postgresql-f7102b04638a882b38cbba7670471a073a939865.tar.gz |
Extend dsm API with a new function dsm_unpin_mapping.
This reassociates a dynamic shared memory handle previous passed to
dsm_pin_mapping with the current resource owner, so that it will be
cleaned up at the end of the current query.
Patch by me. Review of the function name by Andres Freund, Amit
Kapila, Jim Nasby, Petr Jelinek, and Álvaro Herrera.
Diffstat (limited to 'src/backend/storage/ipc/dsm.c')
-rw-r--r-- | src/backend/storage/ipc/dsm.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/backend/storage/ipc/dsm.c b/src/backend/storage/ipc/dsm.c index 7ce45caaf9..6ff1c7ea2a 100644 --- a/src/backend/storage/ipc/dsm.c +++ b/src/backend/storage/ipc/dsm.c @@ -796,6 +796,24 @@ dsm_pin_mapping(dsm_segment *seg) } /* + * Arrange to remove a dynamic shared memory mapping at cleanup time. + * + * dsm_pin_mapping() can be used to preserve a mapping for the entire + * lifetime of a process; this function reverses that decision, making + * the segment owned by the current resource owner. This may be useful + * just before performing some operation that will invalidate the segment + * for future use by this backend. + */ +void +dsm_unpin_mapping(dsm_segment *seg) +{ + Assert(seg->resowner == NULL); + ResourceOwnerEnlargeDSMs(CurrentResourceOwner); + seg->resowner = CurrentResourceOwner; + ResourceOwnerRememberDSM(seg->resowner, seg); +} + +/* * Keep a dynamic shared memory segment until postmaster shutdown. * * This function should not be called more than once per segment; |