MCPcopy Create free account
hub / github.com/apache/cloudberry / FreeWaitEventSet

Function FreeWaitEventSet

src/backend/storage/ipc/latch.c:875–909  ·  view source on GitHub ↗

* Free a previously created WaitEventSet. * * Note: preferably, this shouldn't have to free any resources that could be * inherited across an exec(). If it did, we'd likely leak those resources in * many scenarios. For the epoll case, we ensure that by setting EPOLL_CLOEXEC * when the FD is created. For the Windows case, we assume that the handles * involved are non-inheritable. */

Source from the content-addressed store, hash-verified

873 * involved are non-inheritable.
874 */
875void
876FreeWaitEventSet(WaitEventSet *set)
877{
878#if defined(WAIT_USE_EPOLL)
879 close(set->epoll_fd);
880 ReleaseExternalFD();
881#elif defined(WAIT_USE_KQUEUE)
882 close(set->kqueue_fd);
883 ReleaseExternalFD();
884#elif defined(WAIT_USE_WIN32)
885 WaitEvent *cur_event;
886
887 for (cur_event = set->events;
888 cur_event < (set->events + set->nevents);
889 cur_event++)
890 {
891 if (cur_event->events & WL_LATCH_SET)
892 {
893 /* uses the latch's HANDLE */
894 }
895 else if (cur_event->events & WL_POSTMASTER_DEATH)
896 {
897 /* uses PostmasterHandle */
898 }
899 else
900 {
901 /* Clean up the event object we created for the socket */
902 WSAEventSelect(cur_event->fd, NULL, 0);
903 WSACloseEvent(set->handles[cur_event->pos + 1]);
904 }
905 }
906#endif
907
908 pfree(set);
909}
910
911/* ---
912 * Add an event to the set. Possible events are:

Callers 6

CheckCancelOnQDFunction · 0.85
ShutdownLatchSupportFunction · 0.85
WaitLatchOrSocketFunction · 0.85
ResetWaitEventSetFunction · 0.85
PgstatCollectorMainFunction · 0.85
ExecAppendAsyncEventWaitFunction · 0.85

Calls 2

ReleaseExternalFDFunction · 0.85
pfreeFunction · 0.50

Tested by

no test coverage detected