Commit f7102b04 authored by Robert Haas's avatar Robert Haas

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.
parent fd0f651a
...@@ -795,6 +795,24 @@ dsm_pin_mapping(dsm_segment *seg) ...@@ -795,6 +795,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. * Keep a dynamic shared memory segment until postmaster shutdown.
* *
......
...@@ -37,6 +37,7 @@ extern void dsm_detach(dsm_segment *seg); ...@@ -37,6 +37,7 @@ extern void dsm_detach(dsm_segment *seg);
/* Resource management functions. */ /* Resource management functions. */
extern void dsm_pin_mapping(dsm_segment *seg); extern void dsm_pin_mapping(dsm_segment *seg);
extern void dsm_unpin_mapping(dsm_segment *seg);
extern void dsm_pin_segment(dsm_segment *seg); extern void dsm_pin_segment(dsm_segment *seg);
extern dsm_segment *dsm_find_mapping(dsm_handle h); extern dsm_segment *dsm_find_mapping(dsm_handle h);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment