* 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. */
| 873 | * involved are non-inheritable. |
| 874 | */ |
| 875 | void |
| 876 | FreeWaitEventSet(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: |
no test coverage detected