mirror of
https://github.com/darlinghq/darling-libkqueue.git
synced 2024-11-26 21:20:38 +00:00
Fix kqueue_close_cb logic to use EV_RECEIPT
Using this flag tells kevent to keep processing even when an error is encountered adding an event. This means that it will actually check both EVFILT_READ and EVFILT_WRITE now. With the old code, we were leaking descriptors created for EVFILT_WRITE.
This commit is contained in:
parent
f721a1d2d8
commit
f3f8cb99b0
@ -139,16 +139,17 @@ static void _kqueue_close_cb(int kqfd, void* kqptr, void* private)
|
||||
struct kqueue* kq = (struct kqueue*) kqptr;
|
||||
int closing_fd = (int) private;
|
||||
struct kevent64_s ev[2];
|
||||
struct kevent64_s results[2];
|
||||
|
||||
ev[0].ident = closing_fd;
|
||||
ev[0].flags = EV_DELETE;
|
||||
ev[0].flags = EV_DELETE | EV_RECEIPT;
|
||||
ev[0].filter = EVFILT_READ;
|
||||
ev[1].ident = closing_fd;
|
||||
ev[1].flags = EV_DELETE;
|
||||
ev[1].flags = EV_DELETE | EV_RECEIPT;
|
||||
ev[1].filter = EVFILT_WRITE;
|
||||
|
||||
// We don't care if it fails or not...
|
||||
kevent64(kqfd, ev, 2, NULL, 0, 0, NULL);
|
||||
kevent64(kqfd, ev, 2, results, 2, KEVENT_FLAG_ERROR_EVENTS, NULL);
|
||||
}
|
||||
|
||||
void VISIBLE
|
||||
|
Loading…
Reference in New Issue
Block a user