mirror of
https://github.com/darlinghq/darling-libkqueue.git
synced 2024-11-26 21:20:38 +00:00
Prevent fd leaks in EVFILT_READ/WRITE
This commit is contained in:
parent
cf2248b1ed
commit
d534499fdb
@ -228,7 +228,11 @@ int
|
||||
evfilt_read_knote_delete(struct filter *filt, struct knote *kn)
|
||||
{
|
||||
if (kn->kev.flags & EV_DISABLE)
|
||||
return (0);
|
||||
{
|
||||
(void) __close_for_kqueue(kn->kdata.kn_dupfd);
|
||||
kn->kdata.kn_dupfd = -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ((kn->kn_flags & KNFL_REGULAR_FILE) && (kn->kdata.kn_eventfd != -1)) {
|
||||
if (epoll_ctl(kn->kn_epollfd, EPOLL_CTL_DEL, kn->kdata.kn_eventfd, NULL) < 0) {
|
||||
|
@ -120,7 +120,11 @@ int
|
||||
evfilt_socket_knote_delete(struct filter *filt, struct knote *kn)
|
||||
{
|
||||
if (kn->kev.flags & EV_DISABLE)
|
||||
{
|
||||
(void) __close_for_kqueue(kn->kdata.kn_dupfd);
|
||||
kn->kdata.kn_dupfd = -1;
|
||||
return (0);
|
||||
}
|
||||
else {
|
||||
if (epoll_ctl(kn->kn_epollfd, EPOLL_CTL_DEL, kn->kdata.kn_dupfd, NULL) < 0) {
|
||||
dbg_perror("epoll_ctl(2)");
|
||||
|
Loading…
Reference in New Issue
Block a user