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.
This commit is contained in:
parent
fd0f651a86
commit
f7102b0463
|
@ -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.
|
||||
*
|
||||
|
|
|
@ -37,6 +37,7 @@ extern void dsm_detach(dsm_segment *seg);
|
|||
|
||||
/* Resource management functions. */
|
||||
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 dsm_segment *dsm_find_mapping(dsm_handle h);
|
||||
|
||||
|
|
Loading…
Reference in New Issue