Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb5d0f8e

Browse files
committed
Allow parent's WaitEventSets to be freed after fork().
An epoll fd belonging to the parent should be closed in the child. Akqueue fd is automatically closed by fork(), but we should still adjustour 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 thepostmaster 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
1 parent1f0019d commitb5d0f8e

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

‎src/backend/storage/ipc/latch.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -869,6 +869,23 @@ FreeWaitEventSet(WaitEventSet *set)
869869
pfree(set);
870870
}
871871

872+
/*
873+
* Free a previously created WaitEventSet in a child process after a fork().
874+
*/
875+
void
876+
FreeWaitEventSetAfterFork(WaitEventSet*set)
877+
{
878+
#if defined(WAIT_USE_EPOLL)
879+
close(set->epoll_fd);
880+
ReleaseExternalFD();
881+
#elif defined(WAIT_USE_KQUEUE)
882+
/* kqueues are not normally inherited by child processes */
883+
ReleaseExternalFD();
884+
#endif
885+
886+
pfree(set);
887+
}
888+
872889
/* ---
873890
* Add an event to the set. Possible events are:
874891
* - WL_LATCH_SET: Wait for the latch to be set

‎src/include/storage/latch.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ extern void ShutdownLatchSupport(void);
175175

176176
externWaitEventSet*CreateWaitEventSet(MemoryContextcontext,intnevents);
177177
externvoidFreeWaitEventSet(WaitEventSet*set);
178+
externvoidFreeWaitEventSetAfterFork(WaitEventSet*set);
178179
externintAddWaitEventToSet(WaitEventSet*set,uint32events,pgsocketfd,
179180
Latch*latch,void*user_data);
180181
externvoidModifyWaitEvent(WaitEventSet*set,intpos,uint32events,Latch*latch);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp