mirror of
https://git.postgresql.org/git/postgresql.git
synced 2025-01-06 15:24:56 +08:00
Allow parent's WaitEventSets to be freed after fork().
An epoll fd belonging to the parent should be closed in the child. A kqueue fd is automatically closed by fork(), but we should still adjust our counter. For poll and Windows systems, nothing special is required. On all systems we free the memory. No caller yet, but we'll need this if we start using WaitEventSet in the postmaster as planned. Reviewed-by: Andres Freund <andres@anarazel.de> Discussion: https://postgr.es/m/CA%2BhUKG%2BZ-HpOj1JsO9eWUP%2Bar7npSVinsC_npxSy%2BjdOMsx%3DGg%40mail.gmail.com
This commit is contained in:
parent
1f0019de2f
commit
b5d0f8ec01
@ -869,6 +869,23 @@ FreeWaitEventSet(WaitEventSet *set)
|
|||||||
pfree(set);
|
pfree(set);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Free a previously created WaitEventSet in a child process after a fork().
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
FreeWaitEventSetAfterFork(WaitEventSet *set)
|
||||||
|
{
|
||||||
|
#if defined(WAIT_USE_EPOLL)
|
||||||
|
close(set->epoll_fd);
|
||||||
|
ReleaseExternalFD();
|
||||||
|
#elif defined(WAIT_USE_KQUEUE)
|
||||||
|
/* kqueues are not normally inherited by child processes */
|
||||||
|
ReleaseExternalFD();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
pfree(set);
|
||||||
|
}
|
||||||
|
|
||||||
/* ---
|
/* ---
|
||||||
* Add an event to the set. Possible events are:
|
* Add an event to the set. Possible events are:
|
||||||
* - WL_LATCH_SET: Wait for the latch to be set
|
* - WL_LATCH_SET: Wait for the latch to be set
|
||||||
|
@ -175,6 +175,7 @@ extern void ShutdownLatchSupport(void);
|
|||||||
|
|
||||||
extern WaitEventSet *CreateWaitEventSet(MemoryContext context, int nevents);
|
extern WaitEventSet *CreateWaitEventSet(MemoryContext context, int nevents);
|
||||||
extern void FreeWaitEventSet(WaitEventSet *set);
|
extern void FreeWaitEventSet(WaitEventSet *set);
|
||||||
|
extern void FreeWaitEventSetAfterFork(WaitEventSet *set);
|
||||||
extern int AddWaitEventToSet(WaitEventSet *set, uint32 events, pgsocket fd,
|
extern int AddWaitEventToSet(WaitEventSet *set, uint32 events, pgsocket fd,
|
||||||
Latch *latch, void *user_data);
|
Latch *latch, void *user_data);
|
||||||
extern void ModifyWaitEvent(WaitEventSet *set, int pos, uint32 events, Latch *latch);
|
extern void ModifyWaitEvent(WaitEventSet *set, int pos, uint32 events, Latch *latch);
|
||||||
|
Loading…
Reference in New Issue
Block a user